fix: Fixed paging in JOYNAT service
This commit is contained in:
+32
-23
@@ -33,7 +33,7 @@ class JOYNAT(Service):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@click.command(name="JOYN", short_help="https://joyn.at", help=__doc__)
|
@click.command(name="JOYN", short_help="https://joyn.at", help=__doc__)
|
||||||
@click.argument("title", type=str)
|
@click.argument("title", type=str)
|
||||||
@click.option("--age-bypass", is_flag=True, default=False, help="Download age gated videos with a rating of 16 years old or above.")
|
@click.option("--age-bypass", is_flag=True, default=False, help="Download age-restricted videos rated for ages 16 and up.")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(ctx: click.Context, **kwargs: Any) -> JOYNAT:
|
def cli(ctx: click.Context, **kwargs: Any) -> JOYNAT:
|
||||||
return JOYNAT(ctx, **kwargs)
|
return JOYNAT(ctx, **kwargs)
|
||||||
@@ -275,33 +275,42 @@ class JOYNAT(Service):
|
|||||||
for season in series_data['allSeasons']:
|
for season in series_data['allSeasons']:
|
||||||
self._validate_required_fields(season, ['id', 'number'], 'season')
|
self._validate_required_fields(season, ['id', 'number'], 'season')
|
||||||
|
|
||||||
season_response = self._execute_graphql_query(
|
first = 20
|
||||||
'Season', {'id': season['id']},
|
offset = 0
|
||||||
'ee2396bb1b7c9f800e5cefd0b341271b7213fceb4ebe18d5a30dab41d703009f',
|
|
||||||
)
|
|
||||||
|
|
||||||
season_data = season_response.get('season')
|
while True:
|
||||||
if not season_data:
|
season_response = self._execute_graphql_query(
|
||||||
continue
|
'Season', {'id': season['id'], 'first': first, 'offset': offset},
|
||||||
|
'ee2396bb1b7c9f800e5cefd0b341271b7213fceb4ebe18d5a30dab41d703009f',
|
||||||
|
)
|
||||||
|
|
||||||
self._validate_required_fields(season_data, ['episodes'], 'season_data')
|
season_data = season_response.get('season')
|
||||||
|
if not season_data:
|
||||||
|
break # no more seasons/episodes
|
||||||
|
|
||||||
for episode in season_data['episodes']:
|
self._validate_required_fields(season_data, ['episodes'], 'season_data')
|
||||||
self._validate_required_fields(episode, ['id', 'title', 'number'], 'episode')
|
|
||||||
self._validate_video_field(episode, 'episode')
|
|
||||||
|
|
||||||
if self._is_age_restricted(episode, episode['title']):
|
if len(season_data['episodes']) == 0:
|
||||||
continue
|
break # no more episodes in this season
|
||||||
|
|
||||||
episodes.append(Episode(
|
for episode in season_data['episodes']:
|
||||||
id_=episode['id'],
|
self._validate_required_fields(episode, ['id', 'title', 'number'], 'episode')
|
||||||
service=self.__class__,
|
self._validate_video_field(episode, 'episode')
|
||||||
title=series_data['title'],
|
|
||||||
season=season['number'],
|
if self._is_age_restricted(episode, episode['title']):
|
||||||
number=episode['number'],
|
continue
|
||||||
name=episode['title'],
|
|
||||||
data=episode,
|
episodes.append(Episode(
|
||||||
))
|
id_=episode['id'],
|
||||||
|
service=self.__class__,
|
||||||
|
title=series_data['title'],
|
||||||
|
season=season['number'],
|
||||||
|
number=episode['number'],
|
||||||
|
name=episode['title'],
|
||||||
|
data=episode,
|
||||||
|
))
|
||||||
|
|
||||||
|
offset += first
|
||||||
|
|
||||||
return Series(episodes)
|
return Series(episodes)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user