]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/played.py
   2 from __future__ 
import unicode_literals
 
   7 from .common 
import InfoExtractor
 
  10     compat_urllib_request
, 
  17 class PlayedIE(InfoExtractor
): 
  19     _VALID_URL 
= r
'https?://(?:www\.)?played\.to/(?P<id>[a-zA-Z0-9_-]+)' 
  22         'url': 'http://played.to/j2f2sfiiukgt', 
  23         'md5': 'c2bd75a368e82980e7257bf500c00637', 
  27             'title': 'youtube-dl_test_video.mp4', 
  29         'skip': 'Removed for copyright infringement.',  # oh wow 
  32     def _real_extract(self
, url
): 
  33         video_id 
= self
._match
_id
(url
) 
  34         orig_webpage 
= self
._download
_webpage
(url
, video_id
) 
  37             r
'(?s)Reason for deletion:.*?<b class="err"[^>]*>(?P<msg>[^<]+)</b>', orig_webpage
) 
  39             raise ExtractorError(m_error
.group('msg'), expected
=True) 
  42             r
'type="hidden" name="([^"]+)"\s+value="([^"]+)">', orig_webpage
) 
  45         self
._sleep
(2, video_id
) 
  47         post 
= compat_urllib_parse
.urlencode(data
) 
  49             b
'Content-Type': b
'application/x-www-form-urlencoded', 
  51         req 
= compat_urllib_request
.Request(url
, post
, headers
) 
  52         webpage 
= self
._download
_webpage
( 
  53             req
, video_id
, note
='Downloading video page ...') 
  55         title 
= os
.path
.splitext(data
['fname'])[0] 
  57         video_url 
= self
._search
_regex
( 
  58             r
'file: "?(.+?)",', webpage
, 'video URL')