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