mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-12 17:36:46 +02:00
[ie/tubitv:series] Fix extractor (#10116)
Closes #8563 Authored by: bashonly
This commit is contained in:
parent
46c1b7cfec
commit
d7d861811c
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
class TubiTvIE(InfoExtractor):
|
class TubiTvIE(InfoExtractor):
|
||||||
|
IE_NAME = 'tubitv'
|
||||||
_VALID_URL = r'https?://(?:www\.)?tubitv\.com/(?P<type>video|movies|tv-shows)/(?P<id>\d+)'
|
_VALID_URL = r'https?://(?:www\.)?tubitv\.com/(?P<type>video|movies|tv-shows)/(?P<id>\d+)'
|
||||||
_LOGIN_URL = 'http://tubitv.com/login'
|
_LOGIN_URL = 'http://tubitv.com/login'
|
||||||
_NETRC_MACHINE = 'tubitv'
|
_NETRC_MACHINE = 'tubitv'
|
||||||
@ -148,30 +149,54 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
|
|
||||||
class TubiTvShowIE(InfoExtractor):
|
class TubiTvShowIE(InfoExtractor):
|
||||||
_WORKING = False
|
IE_NAME = 'tubitv:series'
|
||||||
_VALID_URL = r'https?://(?:www\.)?tubitv\.com/series/[0-9]+/(?P<show_name>[^/?#]+)'
|
_VALID_URL = r'https?://(?:www\.)?tubitv\.com/series/\d+/(?P<show_name>[^/?#]+)(?:/season-(?P<season>\d+))?'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://tubitv.com/series/3936/the-joy-of-painting-with-bob-ross?start=true',
|
'url': 'https://tubitv.com/series/3936/the-joy-of-painting-with-bob-ross?start=true',
|
||||||
'playlist_mincount': 390,
|
'playlist_mincount': 389,
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'the-joy-of-painting-with-bob-ross',
|
'id': 'the-joy-of-painting-with-bob-ross',
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://tubitv.com/series/2311/the-saddle-club/season-1',
|
||||||
|
'playlist_count': 26,
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'the-saddle-club-season-1',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://tubitv.com/series/2311/the-saddle-club/season-3',
|
||||||
|
'playlist_count': 19,
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'the-saddle-club-season-3',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'https://tubitv.com/series/2311/the-saddle-club/',
|
||||||
|
'playlist_mincount': 71,
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'the-saddle-club',
|
||||||
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _entries(self, show_url, show_name):
|
def _entries(self, show_url, playlist_id, selected_season):
|
||||||
show_webpage = self._download_webpage(show_url, show_name)
|
webpage = self._download_webpage(show_url, playlist_id)
|
||||||
|
|
||||||
show_json = self._parse_json(self._search_regex(
|
data = self._search_json(
|
||||||
r'window\.__data\s*=\s*({[^<]+});\s*</script>',
|
r'window\.__data\s*=', webpage, 'data', playlist_id,
|
||||||
show_webpage, 'data'), show_name, transform_source=js_to_json)['video']
|
transform_source=js_to_json)['video']
|
||||||
|
|
||||||
for episode_id in show_json['fullContentById']:
|
# v['number'] is already a decimal string, but stringify to protect against API changes
|
||||||
if traverse_obj(show_json, ('byId', episode_id, 'type')) == 's':
|
path = [lambda _, v: str(v['number']) == selected_season] if selected_season else [..., {dict}]
|
||||||
continue
|
|
||||||
yield self.url_result(
|
for season in traverse_obj(data, ('byId', lambda _, v: v['type'] == 's', 'seasons', *path)):
|
||||||
f'https://tubitv.com/tv-shows/{episode_id}/',
|
season_number = int_or_none(season.get('number'))
|
||||||
ie=TubiTvIE.ie_key(), video_id=episode_id)
|
for episode in traverse_obj(season, ('episodes', lambda _, v: v['id'])):
|
||||||
|
episode_id = episode['id']
|
||||||
|
yield self.url_result(
|
||||||
|
f'https://tubitv.com/tv-shows/{episode_id}/', TubiTvIE, episode_id,
|
||||||
|
season_number=season_number, episode_number=int_or_none(episode.get('num')))
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
show_name = self._match_valid_url(url).group('show_name')
|
playlist_id, selected_season = self._match_valid_url(url).group('show_name', 'season')
|
||||||
return self.playlist_result(self._entries(url, show_name), playlist_id=show_name)
|
if selected_season:
|
||||||
|
playlist_id = f'{playlist_id}-season-{selected_season}'
|
||||||
|
return self.playlist_result(self._entries(url, playlist_id, selected_season), playlist_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user