]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/tubitv.py
3 from .common
import InfoExtractor
14 class TubiTvIE(InfoExtractor
):
18 https?://(?:www\.)?tubitv\.com/(?:video|movies|tv-shows)/
21 _LOGIN_URL
= 'http://tubitv.com/login'
22 _NETRC_MACHINE
= 'tubitv'
23 _GEO_COUNTRIES
= ['US']
25 'url': 'http://tubitv.com/video/283829/the_comedian_at_the_friday',
26 'md5': '43ac06be9326f41912dc64ccf7a80320',
30 'title': 'The Comedian at The Friday',
31 '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.',
32 'uploader_id': 'bc168bee0d18dd1cb3b86c68706ab434',
35 'url': 'http://tubitv.com/tv-shows/321886/s01_e01_on_nom_stories',
36 'only_matching': True,
38 'url': 'http://tubitv.com/movies/383676/tracker',
39 'only_matching': True,
41 'url': 'https://tubitv.com/movies/560057/penitentiary?start=true',
45 'title': 'Penitentiary',
46 'description': 'md5:8d2fc793a93cc1575ff426fdcb8dd3f9',
47 'uploader_id': 'd8fed30d4f24fcb22ec294421b9defc2',
51 'skip_download': True,
55 def _perform_login(self
, username
, password
):
61 payload
= urlencode_postdata(form_data
)
62 request
= sanitized_Request(self
._LOGIN
_URL
, payload
)
63 request
.add_header('Content-Type', 'application/x-www-form-urlencoded')
64 login_page
= self
._download
_webpage
(
65 request
, None, False, 'Wrong login info')
66 if not re
.search(r
'id="tubi-logout"', login_page
):
68 'Login failed (invalid username/password)', expected
=True)
70 def _real_extract(self
, url
):
71 video_id
= self
._match
_id
(url
)
72 video_data
= self
._download
_json
(
73 'https://tubitv.com/oz/videos/%s/content?video_resources=dash&video_resources=hlsv3&video_resources=hlsv6' % video_id
, video_id
)
74 title
= video_data
['title']
78 for resource
in video_data
['video_resources']:
79 if resource
['type'] in ('dash', ):
80 formats
+= self
._extract
_mpd
_formats
(resource
['manifest']['url'], video_id
, mpd_id
=resource
['type'], fatal
=False)
81 elif resource
['type'] in ('hlsv3', 'hlsv6'):
82 formats
+= self
._extract
_m
3u8_formats
(resource
['manifest']['url'], video_id
, 'mp4', m3u8_id
=resource
['type'], fatal
=False)
84 self
._sort
_formats
(formats
)
87 for thumbnail_url
in video_data
.get('thumbnails', []):
91 'url': self
._proto
_relative
_url
(thumbnail_url
),
95 for sub
in video_data
.get('subtitles', []):
96 sub_url
= sub
.get('url')
99 subtitles
.setdefault(sub
.get('lang', 'English'), []).append({
100 'url': self
._proto
_relative
_url
(sub_url
),
103 season_number
, episode_number
, episode_title
= self
._search
_regex
(
104 r
'^S(\d+):E(\d+) - (.+)', title
, 'episode info', fatal
=False, group
=(1, 2, 3), default
=(None, None, None))
110 'subtitles': subtitles
,
111 'thumbnails': thumbnails
,
112 'description': video_data
.get('description'),
113 'duration': int_or_none(video_data
.get('duration')),
114 'uploader_id': video_data
.get('publisher_id'),
115 'release_year': int_or_none(video_data
.get('year')),
116 'season_number': int_or_none(season_number
),
117 'episode_number': int_or_none(episode_number
),
118 'episode_title': episode_title
122 class TubiTvShowIE(InfoExtractor
):
123 _VALID_URL
= r
'https?://(?:www\.)?tubitv\.com/series/[0-9]+/(?P<show_name>[^/?#]+)'
125 'url': 'https://tubitv.com/series/3936/the-joy-of-painting-with-bob-ross?start=true',
126 'playlist_mincount': 390,
128 'id': 'the-joy-of-painting-with-bob-ross',
132 def _entries(self
, show_url
, show_name
):
133 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']
139 for episode_id
in show_json
['fullContentById'].keys():
140 if traverse_obj(show_json
, ('byId', episode_id
, 'type')) == 's':
142 yield self
.url_result(
143 'tubitv:%s' % episode_id
,
144 ie
=TubiTvIE
.ie_key(), video_id
=episode_id
)
146 def _real_extract(self
, url
):
147 show_name
= self
._match
_valid
_url
(url
).group('show_name')
148 return self
.playlist_result(self
._entries
(url
, show_name
), playlist_id
=show_name
)