From: Antoine Cellerier Date: Sat, 19 May 2007 00:49:30 +0000 (+0000) Subject: * share/luaplaylist/youtube_homepage.lua: New lua parser script to open youtube home... X-Git-Tag: 0.9.0-test0~7359 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=41697f25906bb631d5689a7cbb9053d597485d34;p=vlc * share/luaplaylist/youtube_homepage.lua: New lua parser script to open youtube home/browse pages. This demos the ability to return more than one item in lua playlist scripts. --- diff --git a/share/Makefile.am b/share/Makefile.am index 5a4282f333..b20e7ed267 100644 --- a/share/Makefile.am +++ b/share/Makefile.am @@ -238,5 +238,6 @@ DIST_lua= \ luaplaylist/README.txt \ luaplaylist/dailymotion.lua \ luaplaylist/youtube.lua \ + luaplaylist/youtube_homepage.lua \ luaplaylist/metacafe.lua \ luaplaylist/googlevideo.lua diff --git a/share/luaplaylist/youtube_homepage.lua b/share/luaplaylist/youtube_homepage.lua new file mode 100644 index 0000000000..de4df97a58 --- /dev/null +++ b/share/luaplaylist/youtube_homepage.lua @@ -0,0 +1,19 @@ +function probe() + return vlc.access == "http" and ( string.match( vlc.path, "youtube.com/$" ) or string.match( vlc.path, "youtube.com/browse" ) ) +end + +function parse() + p = {} + while true + do + line = vlc.readline() + if not line then break end + for path, artist, name in string.gmatch( line, "href=\"(/watch%?v=[^\"]*)\" onclick=\"_hbLink%('([^']*)','Vid[^\']*'%);\">([^<]*)
" ) + do + path = "http://www.youtube.com" .. path + name = vlc.resolve_xml_special_chars( name ) + table.insert( p, { path = path; name = name; artist = artist } ) + end + end + return p +end