]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/firedrive.py
6d73c8a4a32f83975025a0b1ed932fc291176f8a
   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+ 
  49         post 
= compat_urllib_parse
.urlencode(fields
) 
  50         req 
= compat_urllib_request
.Request(url
, post
) 
  51         req
.add_header('Content-type', 'application/x-www-form-urlencoded') 
  53         # Apparently, this header is required for confirmation to work. 
  54         req
.add_header('Host', 'www.firedrive.com') 
  56         webpage 
= self
._download
_webpage
(req
, video_id
, 
  57                                          'Downloading video page') 
  59         title 
= self
._search
_regex
(r
'class="external_title_left">(.+)</div>', 
  61         thumbnail 
= self
._search
_regex
(r
'image:\s?"(//[^\"]+)', webpage
, 
  62                                        'thumbnail', fatal
=False) 
  63         if thumbnail 
is not None: 
  64             thumbnail 
= 'http:' + thumbnail
 
  66         ext 
= self
._search
_regex
(r
'type:\s?\'([^
\']+)\',', 
  67                                  webpage, 'extension
', fatal=False) 
  68         video_url = self._search_regex( 
  69             r'file:\s?
\'(http
[^
\']+)\',', webpage, 'file url
') 
  80             'thumbnail
': thumbnail,