]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/shared.py
1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
15 class SharedIE(InfoExtractor
):
16 _VALID_URL
= r
'http://shared\.sx/(?P<id>[\da-z]{10})'
19 'url': 'http://shared.sx/0060718775',
20 'md5': '53e1c58fc3e777ae1dfe9e57ba2f9c72',
24 'title': 'Big Buck Bunny Trailer',
28 def _real_extract(self
, url
):
29 mobj
= re
.match(self
._VALID
_URL
, url
)
30 video_id
= mobj
.group('id')
32 page
= self
._download
_webpage
(url
, video_id
)
34 if re
.search(r
'>File does not exist<', page
) is not None:
35 raise ExtractorError('Video %s does not exist' % video_id
, expected
=True)
37 download_form
= dict(re
.findall(r
'<input type="hidden" name="([^"]+)" value="([^"]*)"', page
))
39 request
= compat_urllib_request
.Request(url
, compat_urllib_parse
.urlencode(download_form
))
40 request
.add_header('Content-Type', 'application/x-www-form-urlencoded')
42 video_page
= self
._download
_webpage
(request
, video_id
, 'Downloading video page')
44 video_url
= self
._html
_search
_regex
(r
'data-url="([^"]+)"', video_page
, 'video URL')
45 title
= base64
.b64decode(self
._html
_search
_meta
('full:title', page
, 'title')).decode('utf-8')
46 filesize
= int_or_none(self
._html
_search
_meta
('full:size', page
, 'file size', fatal
=False))
47 thumbnail
= self
._html
_search
_regex
(
48 r
'data-poster="([^"]+)"', video_page
, 'thumbnail', fatal
=False, default
=None)
56 'thumbnail': thumbnail
,