]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/moniker.py
   2 from __future__ 
import unicode_literals
 
   7 from .common 
import InfoExtractor
 
  10     compat_urllib_request
, 
  12 from ..utils 
import ExtractorError
 
  15 class MonikerIE(InfoExtractor
): 
  16     IE_DESC 
= 'allmyvideos.net and vidspot.net' 
  17     _VALID_URL 
= r
'https?://(?:www\.)?(?:allmyvideos|vidspot)\.net/(?P<id>[a-zA-Z0-9_-]+)' 
  20         'url': 'http://allmyvideos.net/jih3nce3x6wn', 
  21         'md5': '710883dee1bfc370ecf9fa6a89307c88', 
  25             'title': 'youtube-dl test video', 
  28         'url': 'http://vidspot.net/l2ngsmhs8ci5', 
  29         'md5': '710883dee1bfc370ecf9fa6a89307c88', 
  33             'title': 'youtube-dl test video', 
  36         'url': 'https://www.vidspot.net/l2ngsmhs8ci5', 
  37         'only_matching': True, 
  40     def _real_extract(self
, url
): 
  41         video_id 
= self
._match
_id
(url
) 
  42         orig_webpage 
= self
._download
_webpage
(url
, video_id
) 
  44         if '>File Not Found<' in orig_webpage
: 
  45             raise ExtractorError('Video %s does not exist' % video_id
, expected
=True) 
  47         error 
= self
._search
_regex
( 
  48             r
'class="err">([^<]+)<', orig_webpage
, 'error', default
=None) 
  51                 '%s returned error: %s' % (self
.IE_NAME
, error
), expected
=True) 
  53         fields 
= re
.findall(r
'type="hidden" name="(.+?)"\s* value="?(.+?)">', orig_webpage
) 
  56         post 
= compat_urllib_parse
.urlencode(data
) 
  58             b
'Content-Type': b
'application/x-www-form-urlencoded', 
  60         req 
= compat_urllib_request
.Request(url
, post
, headers
) 
  61         webpage 
= self
._download
_webpage
( 
  62             req
, video_id
, note
='Downloading video page ...') 
  64         title 
= os
.path
.splitext(data
['fname'])[0] 
  66         # Could be several links with different quality 
  67         links 
= re
.findall(r
'"file" : "?(.+?)",', webpage
) 
  68         # Assume the links are ordered in quality 
  72         } for i
, l 
in enumerate(links
)] 
  73         self
._sort
_formats
(formats
)