]> git.sesse.net Git - vlc/commitdiff
* youtube_homepage.lua: get the stream's duration.
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 19 May 2007 15:37:06 +0000 (15:37 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 19 May 2007 15:37:06 +0000 (15:37 +0000)
share/luaplaylist/youtube_homepage.lua

index 00a7cdc68316c3baf91829d7da8b2211d3673ad6..100ba896fd0ff9f8a7eba01e073fcad710a5733d 100644 (file)
@@ -8,11 +8,22 @@ function parse()
     do
         line = vlc.readline()
         if not line then break end
-        for path, artist, name in string.gmatch( line, "href=\"(/watch%?v=[^\"]*)\" onclick=\"_hbLink%('([^']*)','Vid[^\']*'%);\">([^<]*)</a><br/>" )
+        for _path, _artist, _name in string.gmatch( line, "href=\"(/watch%?v=[^\"]*)\" onclick=\"_hbLink%('([^']*)','Vid[^\']*'%);\">([^<]*)</a><br/>" )
         do
-            path = "http://www.youtube.com" .. path
-            name = vlc.resolve_xml_special_chars( name )
-            table.insert( p, { path = path; name = name; artist = artist } )
+            path = "http://www.youtube.com" .. _path
+            name = vlc.resolve_xml_special_chars( _name )
+            artist = _artist
+        end
+        for _min, _sec in string.gmatch( line, "<span class=\"runtime\">(%d*):(%d*)</span>" )
+        do
+            duration = 60 * _min + _sec
+        end
+        if path and name and artist and duration then
+            table.insert( p, { path = path; name = name; artist = artist; duration = duration } )
+            path = nil
+            name = nil
+            artist = nil
+            duration = nil
         end
     end
     return p