]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hostingbulk.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  17 class HostingBulkIE(InfoExtractor
): 
  19         https?://(?:www\.)?hostingbulk\.com/ 
  20         (?:embed-)?(?P<id>[A-Za-z0-9]{12})(?:-\d+x\d+)?\.html''' 
  21     _FILE_DELETED_REGEX 
= r
'<b>File Not Found</b>' 
  23         'url': 'http://hostingbulk.com/n0ulw1hv20fm.html', 
  24         'md5': '6c8653c8ecf7ebfa83b76e24b7b2fe3f', 
  28             'title': 'md5:5afeba33f48ec87219c269e054afd622', 
  30             'thumbnail': 're:^http://.*\.jpg$', 
  34     def _real_extract(self
, url
): 
  35         video_id 
= self
._match
_id
(url
) 
  36         url 
= 'http://hostingbulk.com/{0:}.html'.format(video_id
) 
  38         # Custom request with cookie to set language to English, so our file 
  39         # deleted regex would work. 
  40         request 
= compat_urllib_request
.Request( 
  41             url
, headers
={'Cookie': 'lang=english'}) 
  42         webpage 
= self
._download
_webpage
(request
, video_id
) 
  44         if re
.search(self
._FILE
_DELETED
_REGEX
, webpage
) is not None: 
  45             raise ExtractorError('Video %s does not exist' % video_id
, 
  48         title 
= self
._html
_search
_regex
(r
'<h3>(.*?)</h3>', webpage
, 'title') 
  49         filesize 
= int_or_none( 
  51                 r
'<small>\((\d+)\sbytes?\)</small>', 
  57         thumbnail 
= self
._search
_regex
( 
  58             r
'<img src="([^"]+)".+?class="pic"', 
  59             webpage
, 'thumbnail', fatal
=False) 
  61         fields 
= dict(re
.findall(r
'''(?x)<input\s+ 
  67         request 
= compat_urllib_request
.Request(url
, urlencode_postdata(fields
)) 
  68         request
.add_header('Content-type', 'application/x-www-form-urlencoded') 
  69         response 
= self
._request
_webpage
(request
, video_id
, 
  70                                          'Submiting download request') 
  71         video_url 
= response
.geturl() 
  82             'thumbnail': thumbnail
,