]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tubitv.py
   2 from __future__ 
import unicode_literals
 
   7 from .common 
import InfoExtractor
 
  18 class TubiTvIE(InfoExtractor
): 
  19     _VALID_URL 
= r
'https?://(?:www\.)?tubitv\.com/video\?id=(?P<id>[0-9]+)' 
  20     _LOGIN_URL 
= 'http://tubitv.com/login' 
  21     _NETRC_MACHINE 
= 'tubitv' 
  23         'url': 'http://tubitv.com/video?id=54411&title=The_Kitchen_Musical_-_EP01', 
  27             'title': 'The Kitchen Musical - EP01', 
  28             'thumbnail': 're:^https?://.*\.png$', 
  29             'description': 'md5:37532716166069b353e8866e71fefae7', 
  33             'skip_download': 'HLS download', 
  38         (username
, password
) = self
._get
_login
_info
() 
  46         payload 
= compat_urllib_parse
.urlencode(form_data
).encode('utf-8') 
  47         request 
= compat_urllib_request
.Request(self
._LOGIN
_URL
, payload
) 
  48         request
.add_header('Content-Type', 'application/x-www-form-urlencoded') 
  49         login_page 
= self
._download
_webpage
( 
  50             request
, None, False, 'Wrong login info') 
  51         if not re
.search(r
'id="tubi-logout"', login_page
): 
  53                 'Login failed (invalid username/password)', expected
=True) 
  55     def _real_initialize(self
): 
  58     def _real_extract(self
, url
): 
  59         video_id 
= self
._match
_id
(url
) 
  61         webpage 
= self
._download
_webpage
(url
, video_id
) 
  62         if re
.search(r
"<(?:DIV|div) class='login-required-screen'>", webpage
): 
  64                 'This video requires login, use --username and --password ' 
  65                 'options to provide account credentials.', expected
=True) 
  67         title 
= self
._og
_search
_title
(webpage
) 
  68         description 
= self
._og
_search
_description
(webpage
) 
  69         thumbnail 
= self
._og
_search
_thumbnail
(webpage
) 
  70         duration 
= int_or_none(self
._html
_search
_meta
( 
  71             'video:duration', webpage
, 'duration')) 
  73         apu 
= self
._search
_regex
(r
"apu='([^']+)'", webpage
, 'apu') 
  74         m3u8_url 
= codecs
.decode(apu
, 'rot_13')[::-1] 
  75         formats 
= self
._extract
_m
3u8_formats
(m3u8_url
, video_id
, ext
='mp4') 
  81             'thumbnail': thumbnail
, 
  82             'description': description
,