]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tubitv.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
16 class TubiTvIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?tubitv\.com/video/(?P<id>[0-9]+)'
18 _LOGIN_URL
= 'http://tubitv.com/login'
19 _NETRC_MACHINE
= 'tubitv'
21 'url': 'http://tubitv.com/video/283829/the_comedian_at_the_friday',
25 'title': 'The Comedian at The Friday',
26 'description': 'A stand up comedian is forced to look at the decisions in his life while on a one week trip to the west coast.',
27 'uploader': 'Indie Rights Films',
28 'upload_date': '20160111',
29 'timestamp': 1452555979,
32 'skip_download': 'HLS download',
37 (username
, password
) = self
._get
_login
_info
()
45 payload
= urlencode_postdata(form_data
)
46 request
= sanitized_Request(self
._LOGIN
_URL
, payload
)
47 request
.add_header('Content-Type', 'application/x-www-form-urlencoded')
48 login_page
= self
._download
_webpage
(
49 request
, None, False, 'Wrong login info')
50 if not re
.search(r
'id="tubi-logout"', login_page
):
52 'Login failed (invalid username/password)', expected
=True)
54 def _real_initialize(self
):
57 def _real_extract(self
, url
):
58 video_id
= self
._match
_id
(url
)
59 video_data
= self
._download
_json
(
60 'http://tubitv.com/oz/videos/%s/content' % video_id
, video_id
)
61 title
= video_data
['n']
63 formats
= self
._extract
_m
3u8_formats
(
64 video_data
['mh'], video_id
, 'mp4', 'm3u8_native')
65 self
._sort
_formats
(formats
)
68 for sub
in video_data
.get('sb', []):
69 sub_url
= sub
.get('u')
72 subtitles
.setdefault(sub
.get('l', 'en'), []).append({
80 'subtitles': subtitles
,
81 'thumbnail': video_data
.get('ph'),
82 'description': video_data
.get('d'),
83 'duration': int_or_none(video_data
.get('s')),
84 'timestamp': parse_iso8601(video_data
.get('u')),
85 'uploader': video_data
.get('on'),