[vlc-commits] commit: Add an SD for channels.com (nice content). ( Rémi Duraffort )
git at videolan.org
git at videolan.org
Tue Nov 2 20:35:02 CET 2010
vlc/vlc-1.1 | branch: master | Rémi Duraffort <ivoire at videolan.org> | Mon Oct 25 23:17:09 2010 +0200| [a2e72b6382ab590e6cbd9b096e55772f6dc9d4e2] | committer: Rémi Duraffort
Add an SD for channels.com (nice content).
(cherry picked from commit ab20299e91701579af48e15316f8c016317e987f)
Signed-off-by: Rémi Duraffort <ivoire at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=a2e72b6382ab590e6cbd9b096e55772f6dc9d4e2
---
share/lua/playlist/metachannels.lua | 55 +++++++++++++++++++++++++++++++++++
share/lua/sd/metachannels.lua | 45 ++++++++++++++++++++++++++++
2 files changed, 100 insertions(+), 0 deletions(-)
diff --git a/share/lua/playlist/metachannels.lua b/share/lua/playlist/metachannels.lua
new file mode 100644
index 0000000..2e2b7d6
--- /dev/null
+++ b/share/lua/playlist/metachannels.lua
@@ -0,0 +1,55 @@
+--[[
+ $Id$
+
+ Copyright © 2010 VideoLAN and AUTHORS
+
+ Authors: Rémi Duraffort <ivoire at videolan dot org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+--]]
+
+require "simplexml"
+
+function probe()
+ return vlc.access == 'http' and string.match( vlc.path, 'metachannels.com' )
+end
+
+function parse()
+ local webpage = ''
+ while true do
+ local line = vlc.readline()
+ if line == nil then break end
+ webpage = webpage .. line
+ end
+
+ local feed = simplexml.parse_string( webpage )
+ local channel = feed.children[1]
+
+ -- list all children that are items
+ local tracks = {}
+ for _,item in ipairs( channel.children ) do
+ if( item.name == 'item' ) then
+ simplexml.add_name_maps( item )
+ local url = string.gsub( item.children_map['link'][1].children[1], '&', '&' )
+ table.insert( tracks, { path = url,
+ title = item.children_map['title'][1].children[1],
+ arturl = item.children_map['media:thumbnail'][1].attributes['url'],
+ options = {':play-and-pause'} } )
+ end
+ end
+
+ return tracks
+end
+
diff --git a/share/lua/sd/metachannels.lua b/share/lua/sd/metachannels.lua
new file mode 100644
index 0000000..9c17b04
--- /dev/null
+++ b/share/lua/sd/metachannels.lua
@@ -0,0 +1,45 @@
+--[[
+ $Id$
+
+ Copyright © 2010 VideoLAN and AUTHORS
+
+ Authors: Rémi Duraffort <ivoire at videolan dot org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+--]]
+
+require "simplexml"
+
+function descriptor()
+ return { title="Channels.com" }
+end
+
+function main()
+ -- get the primary feed and parse the <channel> tag
+ local feed = simplexml.parse_url( "http://metachannels.com/meta_channels?device=vlc&lang=en,es,fr,de,it,other&format=rss&adult_ok=y" )
+ local channel = feed.children[1]
+
+ -- list all children that are items
+ for _,item in ipairs( channel.children ) do
+ if( item.name == 'item' ) then
+ simplexml.add_name_maps( item )
+ local url = string.gsub( item.children_map['link'][1].children[1], '&', '&' )
+ local node = vlc.sd.add_item( { path = url,
+ title = item.children_map['title'][1].children[1],
+ arturl = item.children_map['image'][1].children_map['url'][1].children[1] } )
+ end
+ end
+end
+
More information about the vlc-commits
mailing list