mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-14 15:22:35 +00:00
[ie/tenplay] Add support for seasons (#7939)
Closes #7744 Authored by: midnightveil
This commit is contained in:
parent
09f815ad52
commit
88a99c87b6
2 changed files with 60 additions and 3 deletions
|
@ -1992,7 +1992,10 @@ from .tencent import (
|
|||
WeTvSeriesIE,
|
||||
)
|
||||
from .tennistv import TennisTVIE
|
||||
from .tenplay import TenPlayIE
|
||||
from .tenplay import (
|
||||
TenPlayIE,
|
||||
TenPlaySeasonIE,
|
||||
)
|
||||
from .testurl import TestURLIE
|
||||
from .tf1 import TF1IE
|
||||
from .tfo import TFOIE
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from datetime import datetime
|
||||
import base64
|
||||
import functools
|
||||
import itertools
|
||||
from datetime import datetime
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..networking import HEADRequest
|
||||
from ..utils import int_or_none, urlencode_postdata
|
||||
from ..utils import int_or_none, traverse_obj, urlencode_postdata, urljoin
|
||||
|
||||
|
||||
class TenPlayIE(InfoExtractor):
|
||||
|
@ -113,3 +115,55 @@ class TenPlayIE(InfoExtractor):
|
|||
'uploader': 'Channel 10',
|
||||
'uploader_id': '2199827728001',
|
||||
}
|
||||
|
||||
|
||||
class TenPlaySeasonIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?10play\.com\.au/(?P<show>[^/?#]+)/episodes/(?P<season>[^/?#]+)/?(?:$|[?#])'
|
||||
_TESTS = [{
|
||||
'url': 'https://10play.com.au/masterchef/episodes/season-14',
|
||||
'info_dict': {
|
||||
'title': 'Season 14',
|
||||
'id': 'MjMyOTIy',
|
||||
},
|
||||
'playlist_mincount': 64,
|
||||
}, {
|
||||
'url': 'https://10play.com.au/the-bold-and-the-beautiful-fast-tracked/episodes/season-2022',
|
||||
'info_dict': {
|
||||
'title': 'Season 2022',
|
||||
'id': 'Mjc0OTIw',
|
||||
},
|
||||
'playlist_mincount': 256,
|
||||
}]
|
||||
|
||||
def _entries(self, load_more_url, display_id=None):
|
||||
skip_ids = []
|
||||
for page in itertools.count(1):
|
||||
episodes_carousel = self._download_json(
|
||||
load_more_url, display_id, query={'skipIds[]': skip_ids},
|
||||
note=f'Fetching episodes page {page}')
|
||||
|
||||
episodes_chunk = episodes_carousel['items']
|
||||
skip_ids.extend(ep['id'] for ep in episodes_chunk)
|
||||
|
||||
for ep in episodes_chunk:
|
||||
yield ep['cardLink']
|
||||
if not episodes_carousel['hasMore']:
|
||||
break
|
||||
|
||||
def _real_extract(self, url):
|
||||
show, season = self._match_valid_url(url).group('show', 'season')
|
||||
season_info = self._download_json(
|
||||
f'https://10play.com.au/api/shows/{show}/episodes/{season}', f'{show}/{season}')
|
||||
|
||||
episodes_carousel = traverse_obj(season_info, (
|
||||
'content', 0, 'components', (
|
||||
lambda _, v: v['title'].lower() == 'episodes',
|
||||
(..., {dict}),
|
||||
)), get_all=False) or {}
|
||||
|
||||
playlist_id = episodes_carousel['tpId']
|
||||
|
||||
return self.playlist_from_matches(
|
||||
self._entries(urljoin(url, episodes_carousel['loadMoreUrl']), playlist_id),
|
||||
playlist_id, traverse_obj(season_info, ('content', 0, 'title', {str})),
|
||||
getter=functools.partial(urljoin, url))
|
||||
|
|
Loading…
Reference in a new issue