]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/mooshare.py
   1 from __future__ 
import unicode_literals
 
   5 from .common 
import InfoExtractor
 
  15 class MooshareIE(InfoExtractor
): 
  17     IE_DESC 
= 'Mooshare.biz' 
  18     _VALID_URL 
= r
'http://(?:www\.)?mooshare\.biz/(?P<id>[\da-z]{12})' 
  22             'url': 'http://mooshare.biz/8dqtk4bjbp8g', 
  23             'md5': '4e14f9562928aecd2e42c6f341c8feba', 
  27                 'title': 'Comedy Football 2011 - (part 1-2)', 
  32             'url': 'http://mooshare.biz/aipjtoc4g95j', 
  36                 'title': 'Orange Caramel  Dashing Through the Snow', 
  41                 'skip_download': True, 
  46     def _real_extract(self
, url
): 
  47         video_id 
= self
._match
_id
(url
) 
  48         page 
= self
._download
_webpage
(url
, video_id
, 'Downloading page') 
  50         if re
.search(r
'>Video Not Found or Deleted<', page
) is not None: 
  51             raise ExtractorError('Video %s does not exist' % video_id
, expected
=True) 
  53         hash_key 
= self
._html
_search
_regex
(r
'<input type="hidden" name="hash" value="([^"]+)">', page
, 'hash') 
  54         title 
= self
._html
_search
_regex
(r
'(?m)<div class="blockTitle">\s*<h2>Watch ([^<]+)</h2>', page
, 'title') 
  62         request 
= compat_urllib_request
.Request( 
  63             'http://mooshare.biz/%s' % video_id
, compat_urllib_parse
.urlencode(download_form
)) 
  64         request
.add_header('Content-Type', 'application/x-www-form-urlencoded') 
  66         self
._sleep
(5, video_id
) 
  68         video_page 
= self
._download
_webpage
(request
, video_id
, 'Downloading video page') 
  70         thumbnail 
= self
._html
_search
_regex
(r
'image:\s*"([^"]+)",', video_page
, 'thumbnail', fatal
=False) 
  71         duration_str 
= self
._html
_search
_regex
(r
'duration:\s*"(\d+)",', video_page
, 'duration', fatal
=False) 
  72         duration 
= int(duration_str
) if duration_str 
is not None else None 
  77         mobj 
= re
.search(r
'(?m)file:\s*"(?P<url>[^"]+)",\s*provider:', video_page
) 
  80                 'url': mobj
.group('url'), 
  86         mobj 
= re
.search(r
'\'hd
-2\': { file: \'(?P
<url
>[^
\']+)\' },', video_page) 
  89                 'url
': mobj.group('url
'), 
  95         mobj = re.search(r'(?m
)file: "(?P<playpath>[^"]+)",\s*streamer: "(?P
<rtmpurl
>rtmp
://[^
"]+)",', video_page) 
  98                 'url
': mobj.group('rtmpurl
'), 
  99                 'play_path
': mobj.group('playpath
'), 
 109             'thumbnail
': thumbnail, 
 110             'duration
': duration,