4 Copyright © 2009-2013 the VideoLAN team
6 Authors: Konstantin Pavlov (thresh@videolan.org)
7 François Revol (revol@free.fr)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
28 path
= path
:gsub("^www%.", "")
29 return ( vlc
.access
== "http" or vlc
.access
== "https" )
30 and ( string.match( path
, "^vimeo%.com/%d+$" )
31 or string.match( path
, "^vimeo%.com/channels/(.-)/%d+$" )
32 or string.match( path
, "^player%.vimeo%.com/" ) )
33 -- do not match other addresses,
34 -- else we'll also try to decode the actual video url
39 if not string.match( vlc
.path
, "player%.vimeo%.com" ) then -- Web page URL
41 local line
= vlc
.readline()
42 if not line
then break end
44 -- Get the appropriate ubiquitous meta tag
45 -- <meta name="twitter:player" content="https://player.vimeo.com/video/123456789">
46 local meta
= string.match( line
, "(<meta[^>]- name=\"twitter:player\"[^>]->)" )
48 local path
= string.match( meta
, " content=\"(.-)\"" )
50 path
= vlc
.strings
.resolve_xml_special_chars( path
)
51 return { { path
= path
} }
56 vlc
.msg
.err( "Couldn't extract vimeo video URL, please check for updates to this script" )
61 local prefres
= vlc
.var
.inherit(nil, "preferred-resolution")
63 local line
= vlc
.readline() -- data is on one line only
65 for stream
in string.gmatch( line
, "{([^}]*\"profile\":[^}]*)}" ) do
66 local url
= string.match( stream
, "\"url\":\"(.-)\"" )
68 -- Apparently the different formats available are listed
69 -- in uncertain order of quality, so compare with what
71 local height
= string.match( stream
, "\"height\":(%d+)" )
72 height
= tonumber( height
)
74 -- Better than nothing
75 if not path
or ( height
and ( not bestres
76 -- Better quality within limits
77 or ( ( prefres
< 0 or height
<= prefres
) and height
> bestres
)
78 -- Lower quality more suited to limits
79 or ( prefres
> -1 and bestres
> prefres
and height
< bestres
)
88 vlc
.msg
.err( "Couldn't extract vimeo video URL, please check for updates to this script" )
92 local name
= string.match( line
, "\"title\":\"(.-)\"" )
93 local artist
= string.match( line
, "\"owner\":{[^}]-\"name\":\"(.-)\"" )
94 local arturl
= string.match( line
, "\"thumbs\":{\"[^\"]+\":\"(.-)\"" )
95 local duration
= string.match( line
, "\"duration\":(%d+)[,}]" )
97 return { { path
= path
; name
= name
; artist
= artist
; arturl
= arturl
; duration
= duration
} }