]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/tubitv.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
16 class TubiTvIE(InfoExtractor
):
20 https?://(?:www\.)?tubitv\.com/(?:video|movies|tv-shows)/
23 _LOGIN_URL
= 'http://tubitv.com/login'
24 _NETRC_MACHINE
= 'tubitv'
25 _GEO_COUNTRIES
= ['US']
27 'url': 'http://tubitv.com/video/283829/the_comedian_at_the_friday',
28 'md5': '43ac06be9326f41912dc64ccf7a80320',
32 'title': 'The Comedian at The Friday',
33 '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.',
34 'uploader_id': 'bc168bee0d18dd1cb3b86c68706ab434',
37 'url': 'http://tubitv.com/tv-shows/321886/s01_e01_on_nom_stories',
38 'only_matching': True,
40 'url': 'http://tubitv.com/movies/383676/tracker',
41 'only_matching': True,
43 'url': 'https://tubitv.com/movies/560057/penitentiary?start=true',
47 'title': 'Penitentiary',
48 'description': 'md5:8d2fc793a93cc1575ff426fdcb8dd3f9',
49 'uploader_id': 'd8fed30d4f24fcb22ec294421b9defc2',
53 'skip_download': True,
58 username
, password
= self
._get
_login
_info
()
66 payload
= urlencode_postdata(form_data
)
67 request
= sanitized_Request(self
._LOGIN
_URL
, payload
)
68 request
.add_header('Content-Type', 'application/x-www-form-urlencoded')
69 login_page
= self
._download
_webpage
(
70 request
, None, False, 'Wrong login info')
71 if not re
.search(r
'id="tubi-logout"', login_page
):
73 'Login failed (invalid username/password)', expected
=True)
75 def _real_initialize(self
):
78 def _real_extract(self
, url
):
79 video_id
= self
._match
_id
(url
)
80 video_data
= self
._download
_json
(
81 'http://tubitv.com/oz/videos/%s/content' % video_id
, video_id
)
82 title
= video_data
['title']
85 url
= video_data
['url']
86 # URL can be sometimes empty. Does this only happen when there is DRM?
88 formats
= self
._extract
_m
3u8_formats
(
89 self
._proto
_relative
_url
(url
),
90 video_id
, 'mp4', 'm3u8_native')
91 self
._sort
_formats
(formats
)
94 for thumbnail_url
in video_data
.get('thumbnails', []):
98 'url': self
._proto
_relative
_url
(thumbnail_url
),
102 for sub
in video_data
.get('subtitles', []):
103 sub_url
= sub
.get('url')
106 subtitles
.setdefault(sub
.get('lang', 'English'), []).append({
107 'url': self
._proto
_relative
_url
(sub_url
),
114 'subtitles': subtitles
,
115 'thumbnails': thumbnails
,
116 'description': video_data
.get('description'),
117 'duration': int_or_none(video_data
.get('duration')),
118 'uploader_id': video_data
.get('publisher_id'),
119 'release_year': int_or_none(video_data
.get('year')),
123 class TubiTvShowIE(InfoExtractor
):
124 _VALID_URL
= r
'https?://(?:www\.)?tubitv\.com/series/[0-9]+/(?P<show_name>[^/?#]+)'
126 'url': 'https://tubitv.com/series/3936/the-joy-of-painting-with-bob-ross?start=true',
127 'playlist_mincount': 390,
129 'id': 'the-joy-of-painting-with-bob-ross',
133 def _entries(self
, show_url
, show_name
):
134 show_webpage
= self
._download
_webpage
(show_url
, show_name
)
135 show_json
= self
._parse
_json
(self
._search
_regex
(
136 r
"window\.__data\s*=\s*({.+?});\s*</script>",
137 show_webpage
, 'data',), show_name
, transform_source
=js_to_json
)['video']
138 for episode_id
in show_json
['fullContentById'].keys():
139 yield self
.url_result(
140 'tubitv:%s' % episode_id
,
141 ie
=TubiTvIE
.ie_key(), video_id
=episode_id
)
143 def _real_extract(self
, url
):
144 show_name
= re
.match(self
._VALID
_URL
, url
).group('show_name')
145 return self
.playlist_result(self
._entries
(url
, show_name
), playlist_id
=show_name
)