[grilo-plugins] euronews: Add streaming TV news from Euronews
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] euronews: Add streaming TV news from Euronews
- Date: Tue, 25 Feb 2014 12:49:56 +0000 (UTC)
commit b4a6a0a78c85e269885bea37b60a963bb39e6466
Author: Bastien Nocera <hadess hadess net>
Date: Tue Feb 25 13:47:57 2014 +0100
euronews: Add streaming TV news from Euronews
https://bugzilla.gnome.org/show_bug.cgi?id=724415
src/lua-factory/sources/Makefile.am | 3 +-
src/lua-factory/sources/grl-euronews.lua | 115 ++++++++++++++++++++++++++++++
2 files changed, 117 insertions(+), 1 deletions(-)
---
diff --git a/src/lua-factory/sources/Makefile.am b/src/lua-factory/sources/Makefile.am
index 31faf3b..68fa64f 100644
--- a/src/lua-factory/sources/Makefile.am
+++ b/src/lua-factory/sources/Makefile.am
@@ -7,7 +7,8 @@
lua_sources_DATA = \
grl-metrolyrics.lua \
- grl-radiofrance.lua
+ grl-radiofrance.lua \
+ grl-euronews.lua
lua_sourcesdir = $(datadir)/$(LUA_FACTORY_SOURCE_LOCATION)
diff --git a/src/lua-factory/sources/grl-euronews.lua b/src/lua-factory/sources/grl-euronews.lua
new file mode 100644
index 0000000..b8ad65b
--- /dev/null
+++ b/src/lua-factory/sources/grl-euronews.lua
@@ -0,0 +1,115 @@
+--[[
+ * Copyright (C) 2014 Bastien Nocera
+ *
+ * Contact: Bastien Nocera <hadess hadess net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+--]]
+
+EURONEWS_URL = 'http://euronews.hexaglobe.com/json/'
+
+---------------------------
+-- Source initialization --
+---------------------------
+
+source = {
+ id = "grl-euronews-lua",
+ name = "Euronews",
+ description = "A source for watching Euronews online",
+ supported_keys = { "id", "title", "url", "type" },
+ supported_media = 'video',
+ tags = { 'news', 'tv' }
+}
+
+------------------
+-- Source utils --
+------------------
+
+function grl_source_browse(media_id)
+ if grl.get_options("skip") > 0 then
+ grl.callback()
+ else
+ grl.fetch(EURONEWS_URL, "euronews_fetch_cb")
+ end
+end
+
+------------------------
+-- Callback functions --
+------------------------
+
+-- return all the media found
+function euronews_fetch_cb(results)
+ local json = {}
+
+ json = grl.lua.json.string_to_table(results)
+ if not json or json.stat == "fail" or not json.primary then
+ grl.callback()
+ return
+ end
+
+ for index, item in pairs(json.primary) do
+ local media = create_media(index, item)
+ grl.callback(media, -1)
+ end
+
+ grl.callback()
+end
+
+-------------
+-- Helpers --
+-------------
+
+function get_lang(id)
+ local langs = {}
+ langs.ru = "Russian"
+ langs.hu = "Hungarian"
+ langs.de = "German"
+ langs.fa = "Persian"
+ langs.ua = "Ukrainian"
+ langs.ar = "Arabic"
+ langs.es = "Spanish; Castilian"
+ langs.gr = "Greek, Modern (1453-)"
+ langs.tr = "Turkish"
+ langs.pe = "Persian" -- Duplicate?
+ langs.en = "English"
+ langs.it = "Italian"
+ langs.fr = "French"
+ langs.pt = "Portuguese"
+
+ if not langs[id] then
+ grl.warning('Could not find language ' .. id)
+ return id
+ end
+
+ return grl.dgettext('iso_639', langs[id])
+end
+
+function create_media(lang, item)
+ local media = {}
+
+ media.type = "video"
+ media.id = lang
+ media.title = "Euronews " .. get_lang(lang)
+ media.url = item.rtmp_flash["750"].server ..
+ item.rtmp_flash["750"].name ..
+ " playpath=" .. item.rtmp_flash["750"].name ..
+ " swfVfy=1 " ..
+ "swfUrl=http://euronews.com/media/player_live_1_14.swf "..
+ "live=1"
+
+ return media
+end
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]