]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/primesharetv.py
   1 from __future__ 
import unicode_literals
 
   3 from .common 
import InfoExtractor
 
   8 from ..utils 
import ExtractorError
 
  11 class PrimeShareTVIE(InfoExtractor
): 
  12     _VALID_URL 
= r
'https?://(?:www\.)?primeshare\.tv/download/(?P<id>[\da-zA-Z]+)' 
  15         'url': 'http://primeshare.tv/download/238790B611', 
  16         'md5': 'b92d9bf5461137c36228009f31533fbc', 
  20             'title': 'Public Domain - 1960s Commercial - Crest Toothpaste-YKsuFona', 
  24     def _real_extract(self
, url
): 
  25         video_id 
= self
._match
_id
(url
) 
  27         webpage 
= self
._download
_webpage
(url
, video_id
) 
  29         if '>File not exist<' in webpage
: 
  30             raise ExtractorError('Video %s does not exist' % video_id
, expected
=True) 
  32         fields 
= self
._hidden
_inputs
(webpage
) 
  36             'Content-Type': 'application/x-www-form-urlencoded', 
  39         wait_time 
= int(self
._search
_regex
( 
  40             r
'var\s+cWaitTime\s*=\s*(\d+)', 
  41             webpage
, 'wait time', default
=7)) + 1 
  42         self
._sleep
(wait_time
, video_id
) 
  44         req 
= compat_urllib_request
.Request( 
  45             url
, compat_urllib_parse
.urlencode(fields
), headers
) 
  46         video_page 
= self
._download
_webpage
( 
  47             req
, video_id
, 'Downloading video page') 
  49         video_url 
= self
._search
_regex
( 
  50             r
"url\s*:\s*'([^']+\.primeshare\.tv(?::443)?/file/[^']+)'", 
  51             video_page
, 'video url') 
  53         title 
= self
._html
_search
_regex
( 
  54             r
'<h1>Watch\s*(?: )?\s*\((.+?)(?:\s*\[\.\.\.\])?\)\s*(?: )?\s*<strong>',