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