[vlc-commits] liveleak.lua: update for website changes

Pierre Ynard git at videolan.org
Thu Feb 9 23:34:30 CET 2017


vlc/vlc-2.2 | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Thu Feb  9 23:21:52 2017 +0100| [bdeb7cfd39cf2a2ee426f4b97861bd6f90d54e56] | committer: Pierre Ynard

liveleak.lua: update for website changes

(cherry picked from commit 703ae4c5bcf667c057313175db0894405c92753a)
Signed-off-by: Pierre Ynard <linkfanel at yahoo.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=bdeb7cfd39cf2a2ee426f4b97861bd6f90d54e56
---

 share/lua/playlist/liveleak.lua | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/share/lua/playlist/liveleak.lua b/share/lua/playlist/liveleak.lua
index c7ce695..170f077 100644
--- a/share/lua/playlist/liveleak.lua
+++ b/share/lua/playlist/liveleak.lua
@@ -1,9 +1,10 @@
 --[[
  $Id$
 
- Copyright © 2012 VideoLAN and AUTHORS
+ Copyright © 2012, 2017 VideoLAN and AUTHORS
 
  Authors: Ludovic Fauvet <etix at videolan.org>
+          Pierre Ynard
 
  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
@@ -22,7 +23,7 @@
 
 -- Probe function.
 function probe()
-    return vlc.access == "http"
+    return ( vlc.access == "http" or vlc.access == "https" )
         and string.match( vlc.path, "^www%.liveleak%.com/view" )
 end
 
@@ -46,18 +47,31 @@ function parse()
         -- Try to find the title
         if string.match( line, '<span class="section_title"' ) then
             title = find( line, '<span class="section_title"[^>]*>(.-)<' )
-            title = string.gsub( title, ' ', ' ' )
+            title = vlc.strings.resolve_xml_special_chars( title )
         end
 
         -- Try to find the art
-        if string.match( line, 'image:' ) then
-            art = find( line, 'image: "(.-)"' )
+        if not art then
+            art = string.match( line, '<meta property="og:image" content="([^"]+)"' )
         end
 
         -- Try to find the video
-        if string.match( line, 'file:' ) then
-            video = find( line, 'file: "(.-)"' )
+        if not video and string.match( line, '<source ' ) then
+            -- Apparently the two formats are listed HD first, SD second
+            local prefres = vlc.var.inherit( nil, 'preferred-resolution' )
+            for src in string.gmatch( line, '<source src="([^"]+)"' ) do
+                video = src
+
+                if prefres < 0 then
+                    break
+                end
+                local height = tonumber( string.match( src, '_(%d+)p%.mp4' ) )
+                if ( not height ) or height <= prefres then
+                    break
+                end
+            end
         end
+
     end
     if video then
         table.insert( p, { path = video; name = title; arturl = art; } )



More information about the vlc-commits mailing list