diff --git a/JOYNAT/__init__.py b/JOYNAT/__init__.py index 62724c9..7486fbd 100644 --- a/JOYNAT/__init__.py +++ b/JOYNAT/__init__.py @@ -33,7 +33,7 @@ class JOYNAT(Service): @staticmethod @click.command(name="JOYN", short_help="https://joyn.at", help=__doc__) @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 def cli(ctx: click.Context, **kwargs: Any) -> JOYNAT: return JOYNAT(ctx, **kwargs) @@ -275,33 +275,42 @@ class JOYNAT(Service): for season in series_data['allSeasons']: self._validate_required_fields(season, ['id', 'number'], 'season') - season_response = self._execute_graphql_query( - 'Season', {'id': season['id']}, - 'ee2396bb1b7c9f800e5cefd0b341271b7213fceb4ebe18d5a30dab41d703009f', - ) + first = 20 + offset = 0 - season_data = season_response.get('season') - if not season_data: - continue + while True: + season_response = self._execute_graphql_query( + '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(episode, ['id', 'title', 'number'], 'episode') - self._validate_video_field(episode, 'episode') + self._validate_required_fields(season_data, ['episodes'], 'season_data') - if self._is_age_restricted(episode, episode['title']): - continue + if len(season_data['episodes']) == 0: + break # no more episodes in this season - episodes.append(Episode( - id_=episode['id'], - service=self.__class__, - title=series_data['title'], - season=season['number'], - number=episode['number'], - name=episode['title'], - data=episode, - )) + for episode in season_data['episodes']: + self._validate_required_fields(episode, ['id', 'title', 'number'], 'episode') + self._validate_video_field(episode, 'episode') + + if self._is_age_restricted(episode, episode['title']): + continue + + 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)