mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-01-29 01:27:52 +00:00
[ie/abematv] Support season extraction (#11771)
Closes #10602 Authored by: middlingphys
This commit is contained in:
parent
4850ce91d1
commit
c709cc41cb
@ -421,14 +421,15 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
|
|
||||||
class AbemaTVTitleIE(AbemaTVBaseIE):
|
class AbemaTVTitleIE(AbemaTVBaseIE):
|
||||||
_VALID_URL = r'https?://abema\.tv/video/title/(?P<id>[^?/]+)'
|
_VALID_URL = r'https?://abema\.tv/video/title/(?P<id>[^?/#]+)/?(?:\?(?:[^#]+&)?s=(?P<season>[^&#]+))?'
|
||||||
_PAGE_SIZE = 25
|
_PAGE_SIZE = 25
|
||||||
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://abema.tv/video/title/90-1597',
|
'url': 'https://abema.tv/video/title/90-1887',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '90-1597',
|
'id': '90-1887',
|
||||||
'title': 'シャッフルアイランド',
|
'title': 'シャッフルアイランド',
|
||||||
|
'description': 'md5:61b2425308f41a5282a926edda66f178',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 2,
|
'playlist_mincount': 2,
|
||||||
}, {
|
}, {
|
||||||
@ -436,41 +437,54 @@ class AbemaTVTitleIE(AbemaTVBaseIE):
|
|||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '193-132',
|
'id': '193-132',
|
||||||
'title': '真心が届く~僕とスターのオフィス・ラブ!?~',
|
'title': '真心が届く~僕とスターのオフィス・ラブ!?~',
|
||||||
|
'description': 'md5:9b59493d1f3a792bafbc7319258e7af8',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 16,
|
'playlist_mincount': 16,
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://abema.tv/video/title/25-102',
|
'url': 'https://abema.tv/video/title/25-1nzan-whrxe',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '25-102',
|
'id': '25-1nzan-whrxe',
|
||||||
'title': 'ソードアート・オンライン アリシゼーション',
|
'title': 'ソードアート・オンライン',
|
||||||
|
'description': 'md5:c094904052322e6978495532bdbf06e6',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 24,
|
'playlist_mincount': 25,
|
||||||
|
}, {
|
||||||
|
'url': 'https://abema.tv/video/title/26-2mzbynr-cph?s=26-2mzbynr-cph_s40',
|
||||||
|
'info_dict': {
|
||||||
|
'title': '〈物語〉シリーズ',
|
||||||
|
'id': '26-2mzbynr-cph',
|
||||||
|
'description': 'md5:e67873de1c88f360af1f0a4b84847a52',
|
||||||
|
},
|
||||||
|
'playlist_count': 59,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _fetch_page(self, playlist_id, series_version, page):
|
def _fetch_page(self, playlist_id, series_version, season_id, page):
|
||||||
|
query = {
|
||||||
|
'seriesVersion': series_version,
|
||||||
|
'offset': str(page * self._PAGE_SIZE),
|
||||||
|
'order': 'seq',
|
||||||
|
'limit': str(self._PAGE_SIZE),
|
||||||
|
}
|
||||||
|
if season_id:
|
||||||
|
query['seasonId'] = season_id
|
||||||
programs = self._call_api(
|
programs = self._call_api(
|
||||||
f'v1/video/series/{playlist_id}/programs', playlist_id,
|
f'v1/video/series/{playlist_id}/programs', playlist_id,
|
||||||
note=f'Downloading page {page + 1}',
|
note=f'Downloading page {page + 1}',
|
||||||
query={
|
query=query)
|
||||||
'seriesVersion': series_version,
|
|
||||||
'offset': str(page * self._PAGE_SIZE),
|
|
||||||
'order': 'seq',
|
|
||||||
'limit': str(self._PAGE_SIZE),
|
|
||||||
})
|
|
||||||
yield from (
|
yield from (
|
||||||
self.url_result(f'https://abema.tv/video/episode/{x}')
|
self.url_result(f'https://abema.tv/video/episode/{x}')
|
||||||
for x in traverse_obj(programs, ('programs', ..., 'id')))
|
for x in traverse_obj(programs, ('programs', ..., 'id')))
|
||||||
|
|
||||||
def _entries(self, playlist_id, series_version):
|
def _entries(self, playlist_id, series_version, season_id):
|
||||||
return OnDemandPagedList(
|
return OnDemandPagedList(
|
||||||
functools.partial(self._fetch_page, playlist_id, series_version),
|
functools.partial(self._fetch_page, playlist_id, series_version, season_id),
|
||||||
self._PAGE_SIZE)
|
self._PAGE_SIZE)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
playlist_id = self._match_id(url)
|
playlist_id, season_id = self._match_valid_url(url).group('id', 'season')
|
||||||
series_info = self._call_api(f'v1/video/series/{playlist_id}', playlist_id)
|
series_info = self._call_api(f'v1/video/series/{playlist_id}', playlist_id)
|
||||||
|
|
||||||
return self.playlist_result(
|
return self.playlist_result(
|
||||||
self._entries(playlist_id, series_info['version']), playlist_id=playlist_id,
|
self._entries(playlist_id, series_info['version'], season_id), playlist_id=playlist_id,
|
||||||
playlist_title=series_info.get('title'),
|
playlist_title=series_info.get('title'),
|
||||||
playlist_description=series_info.get('content'))
|
playlist_description=series_info.get('content'))
|
||||||
|
Loading…
Reference in New Issue
Block a user