]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/firedrive.py
d26145db1cc399e1202ef5ca41ce5a167e4bdaeb
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
10 compat_urllib_request
,
15 class FiredriveIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?firedrive\.com/' + \
17 '(?:file|embed)/(?P<id>[0-9a-zA-Z]+)'
18 _FILE_DELETED_REGEX
= r
'<div class="removed_file_image">'
21 'url': 'https://www.firedrive.com/file/FEB892FA160EBD01',
22 'md5': 'd5d4252f80ebeab4dc2d5ceaed1b7970',
24 'id': 'FEB892FA160EBD01',
26 'title': 'bbb_theora_486kbit.flv',
27 'thumbnail': 're:^http://.*\.jpg$',
31 def _real_extract(self
, url
):
32 mobj
= re
.match(self
._VALID
_URL
, url
)
33 video_id
= mobj
.group('id')
35 url
= 'http://firedrive.com/file/%s' % video_id
37 webpage
= self
._download
_webpage
(url
, video_id
)
39 if re
.search(self
._FILE
_DELETED
_REGEX
, webpage
) is not None:
40 raise ExtractorError('Video %s does not exist' % video_id
,
43 fields
= dict(re
.findall(r
'''(?x)<input\s+
50 post
= compat_urllib_parse
.urlencode(fields
)
51 req
= compat_urllib_request
.Request(url
, post
)
52 req
.add_header('Content-type', 'application/x-www-form-urlencoded')
54 # Apparently, this header is required for confirmation to work.
55 req
.add_header('Host', 'www.firedrive.com')
57 webpage
= self
._download
_webpage
(req
, video_id
,
58 'Downloading video page')
60 title
= self
._search
_regex
(r
'class="external_title_left">(.+)</div>',
62 thumbnail
= self
._search
_regex
(r
'image:\s?"(//[^\"]+)', webpage
,
63 'thumbnail', fatal
=False)
64 if thumbnail
is not None:
65 thumbnail
= 'http:' + thumbnail
67 ext
= self
._search
_regex
(r
'type:\s?\'([^
\']+)\',',
68 webpage, 'extension
', fatal=False)
69 video_url = self._search_regex(
70 r'file:\s?
\'(http
[^
\']+)\',', webpage, 'file url
')
81 'thumbnail
': thumbnail,