]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/videoweed.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
12 class VideoweedIE(InfoExtractor
):
16 #_VALID_URL = r'http://(?:(?:www\.)?%(host)s/file/|(?:(?:embed|www)\.)%(host)s/embed\.php\?(?:.*?&)?v=)(?P<videoid>[a-z\d]{13})' % {'host': 'videoweed\.com'}
17 _VALID_URL
=r
'http://(?:www\.)videoweed\.es/file/(?P<id>[^"]+)'
18 _HOST
= 'www.videoweed.es'
20 _FILE_DELETED_REGEX
= r
'>This file no longer exists on our servers.</'
21 _FILEKEY_REGEX
= r
'flashvars\.filekey="(?P<filekey>[^"]+)";'
22 _TITLE_REGEX
= r
'<h1 class="text_shadow">([^<]+)</h1>'
23 _DESCRIPTION_REGEX
= r
'(?s)<div class="v_tab blockborder rounded5" id="v_tab1">\s*<h3>[^<]+</h3><p>([^<]+)</p>'
26 'url': 'http://www.videoweed.es/file/89868b4aa3bdf',
27 'md5': '7205f346a52bbeba427603ba10d4b935',
29 'id': '89868b4aa3bdf',
31 'title': 'law and order svu 103 dvdrip',
34 'skip': '"Invalid token" errors abound (in web interface as well as youtube-dl, there is nothing we can do about it.)'
37 def _real_extract(self
, url
):
38 mobj
= re
.match(self
._VALID
_URL
, url
)
39 video_id
= mobj
.group('id')
41 page
= self
._download
_webpage
(
42 'http://%s/file/%s' % (self
._HOST
, video_id
), video_id
, 'Downloading video page')
44 if re
.search(self
._FILE
_DELETED
_REGEX
, page
) is not None:
45 raise ExtractorError(u
'Video %s does not exist' % video_id
, expected
=True)
47 filekey
= self
._search
_regex
(self
._FILEKEY
_REGEX
, page
, 'filekey')
49 title
= self
._html
_search
_regex
(self
._TITLE
_REGEX
, page
, 'title', fatal
=False)
51 description
= self
._html
_search
_regex
(self
._DESCRIPTION
_REGEX
, page
, 'description', default
='', fatal
=False)
53 api_response
= self
._download
_webpage
(
54 'http://%s/api/player.api.php?key=%s&file=%s' % (self
._HOST
, filekey
, video_id
), video_id
,
55 'Downloading video api response')
57 response
= compat_urlparse
.parse_qs(api_response
)
59 if 'error_msg' in response
:
60 raise ExtractorError('%s returned error: %s' % (self
.IE_NAME
, response
['error_msg'][0]), expected
=True)
62 video_url
= response
['url'][0]
68 'description': description