]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nosvideo.py
f5ef856db0155dd84f10d5db4a8cef8e6c08213c
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  17 _x 
= lambda p
: xpath_with_ns(p
, {'xspf': 'http://xspf.org/ns/0/'}) 
  20 class NosVideoIE(InfoExtractor
): 
  21     _VALID_URL 
= r
'https?://(?:www\.)?nosvideo\.com/' + \
 
  22                  '(?:embed/|\?v=)(?P<id>[A-Za-z0-9]{12})/?' 
  23     _PLAYLIST_URL 
= 'http://nosvideo.com/xml/{xml_id:s}.xml' 
  24     _FILE_DELETED_REGEX 
= r
'<b>File Not Found</b>' 
  26         'url': 'http://nosvideo.com/?v=mu8fle7g7rpq', 
  27         'md5': '6124ed47130d8be3eacae635b071e6b6', 
  31             'title': 'big_buck_bunny_480p_surround-fix.avi.mp4', 
  32             'thumbnail': 're:^https?://.*\.jpg$', 
  36     def _real_extract(self
, url
): 
  37         video_id 
= self
._match
_id
(url
) 
  42             'method_free': 'Continue to Video', 
  44         req 
= compat_urllib_request
.Request(url
, urlencode_postdata(fields
)) 
  45         req
.add_header('Content-type', 'application/x-www-form-urlencoded') 
  46         webpage 
= self
._download
_webpage
(req
, video_id
, 
  47                                          'Downloading download page') 
  48         if re
.search(self
._FILE
_DELETED
_REGEX
, webpage
) is not None: 
  49             raise ExtractorError('Video %s does not exist' % video_id
, 
  52         xml_id 
= self
._search
_regex
(r
'php\|([^\|]+)\|', webpage
, 'XML ID') 
  53         playlist_url 
= self
._PLAYLIST
_URL
.format(xml_id
=xml_id
) 
  54         playlist 
= self
._download
_xml
(playlist_url
, video_id
) 
  56         track 
= playlist
.find(_x('.//xspf:track')) 
  59                 'XML playlist is missing the \'track\' element', 
  61         title 
= xpath_text(track
, _x('./xspf:title'), 'title') 
  62         url 
= xpath_text(track
, _x('./xspf:file'), 'URL', fatal
=True) 
  63         thumbnail 
= xpath_text(track
, _x('./xspf:image'), 'thumbnail') 
  75             'thumbnail': thumbnail
,