2 Translate Daily Motion video webpages URLs to the corresponding
7 Copyright © 2007-2011 the VideoLAN team
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 function get_prefres()
26 if vlc
.var
and vlc
.var
.inherit
then
27 prefres
= vlc
.var
.inherit(nil, "preferred-resolution")
28 if prefres
== nil then
38 if vlc
.access
~= "http" and vlc
.access
~= "https" then
42 return ( string.match( vlc
.path
, "www.dailymotion.com/video" ) )
47 prefres
= get_prefres()
53 if not line
then break end
54 if string.match( line
, "<meta property=\"og:title\"" ) then
55 _
,_
,name
= string.find( line
, "content=\"(.-)\"" )
56 name
= vlc
.strings
.resolve_xml_special_chars( name
)
58 if string.match( line
, "<meta name=\"description\"" ) then
59 _
,_
,description
= string.find( line
, "content=\"(.-)\"" )
60 if (description
~= nil) then
61 description
= vlc
.strings
.resolve_xml_special_chars( description
)
64 if string.match( line
, "<meta name=\"author\"" ) then
65 _
,_
,artist
= string.find( line
, "content=\"(.-)\"" )
66 artist
= vlc
.strings
.resolve_xml_special_chars( artist
)
68 if string.match( line
, "<link rel=\"thumbnail\" type=\"image/jpeg\"" ) then
69 _
,_
,arturl
= string.find( line
, "href=\"(.-)\"" )
73 page_embed
= string.gsub(vlc
.path
, "dailymotion.com/video/", "dailymotion.com/embed/video/")
74 page_url
= vlc
.stream(vlc
.access
.. "://" .. page_embed
)
75 if not page_url
then return nil end
76 page
= page_url
:read( 65653 )
79 hd1080url
= string.match( page
, "\"stream_h264_hd1080_url\"%s*:%s*\"([^\"]*)\"")
80 hdurl
= string.match( page
, "\"stream_h264_hd_url\"%s*:%s*\"([^\"]*)\"")
81 hqurl
= string.match( page
, "\"stream_h264_hq_url\"%s*:%s*\"([^\"]*)\"")
82 baseurl
= string.match( page
, "\"stream_h264_url\"%s*:%s*\"([^\"]*)\"")
83 ldurl
= string.match( page
, "\"stream_h264_ld_url\"%s*:%s*\"([^\"]*)\"")
84 livehlsurl
= string.match( page
, "\"stream_live_hls_url\"%s*:%s*\"([^\"]*)\"")
88 if hd1080url
then table.insert(arr_videos_urls
,hd1080url
) end
89 if hdurl
then table.insert(arr_videos_urls
,hdurl
) end
90 if hqurl
then table.insert(arr_videos_urls
,hqurl
) end
91 if baseurl
then table.insert(arr_videos_urls
,baseurl
) end
92 if ldurl
then table.insert(arr_videos_urls
,baseurl
) end
96 return { { path
= livehlsurl
:gsub("\\/", "/"); name
= name
; description
= description
; url
= vlc
.path
; arturl
= arturl
; artist
= artist
} }
98 if table.getn(arr_videos_urls
) > 0 then
99 for i
=1 , table.getn(arr_videos_urls
) do
100 video_url_out
= arr_videos_urls
[i
]:gsub("\\/", "/")
105 height
= string.match( video_url_out
, "/cdn/%w+%-%d+x(%d+)/video/" )
106 if not height
or tonumber(height
) <= prefres
then
110 return { { path
= video_url_out
; name
= name
; description
= description
; url
= vlc
.path
; arturl
= arturl
; artist
= artist
} }
112 vlc
.msg
.err("Couldn't extract the video URL from dailymotion")