[grilo-plugins] euronews: adapt url to YouTube feeds



commit 340da5d552067b8a1738091f6a24b42ff07323b7
Author: Victor Toso <victortoso gnome org>
Date:   Fri May 7 17:12:18 2021 +0200

    euronews: adapt url to YouTube feeds
    
    Euronews seemed to have migrated to YouTube for most of its content.
    At this moment, from the previous list of Feeds, only Persian is not
    exclusive YouTube.
    
    This patch uses the videoId provided by euronews to create an YouTube url.
    
    Fixes: https://gitlab.gnome.org/GNOME/grilo-plugins/-/issues/78

 src/lua-factory/sources/grl-euronews.lua | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/src/lua-factory/sources/grl-euronews.lua b/src/lua-factory/sources/grl-euronews.lua
index d332fc73..d015593c 100644
--- a/src/lua-factory/sources/grl-euronews.lua
+++ b/src/lua-factory/sources/grl-euronews.lua
@@ -82,13 +82,30 @@ function euronews_initial_fetch_cb(results, lang)
   local json = {}
   json = grl.lua.json.string_to_table(results)
 
-  if not json or not json.url then
+  -- pfp: youtube, uses videoId for url
+  -- jw: will provide an url to request video
+  if not json or
+    (json.player ~= "pfp" and json.player ~= "jw") or
+    (json.player == "pfp" and not json.videoId) or
+    (json.player == "jw" and not json.url) then
     local api_url = get_api_url(lang)
     grl.warning ("Initial fetch failed for: " .. api_url)
     callback_done()
     return
   end
 
+  if json.player == "pfp" then
+    item = {}
+    item.primary = string.format("https://www.youtube.com/watch?v=%s";, json.videoId)
+    local media = create_media(lang, item)
+    if media ~= nil then
+      grl.callback(media, -1)
+    end
+
+    callback_done()
+    return
+  end
+
   local streaming_lang = json.url:match("://euronews%-(..)%-p%-api")
   if lang ~= LANG_EN and streaming_lang == LANG_EN then
     grl.debug("Skipping " .. langs[lang] .. " as it redirects to " .. langs[LANG_EN] .. " stream.")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]