diff --git a/JOYNAT/__init__.py b/JOYNAT/__init__.py index a6f9df7..fe39590 100644 --- a/JOYNAT/__init__.py +++ b/JOYNAT/__init__.py @@ -34,12 +34,14 @@ 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.pass_context def cli(ctx: click.Context, **kwargs: Any) -> JOYNAT: return JOYNAT(ctx, **kwargs) - def __init__(self, ctx: click.Context, title: str): + def __init__(self, ctx: click.Context, title: str, age_bypass: bool = False): self.title = title + self.age_bypass = age_bypass super().__init__(ctx) @@ -209,6 +211,11 @@ class JOYNAT(Service): self.log.error("Invalid movie_data data received.") raise ValueError("Invalid movie_data data received from Joyn service.") + min_age = movie_data.get('ageRating', {}).get('minAge', 0) if movie_data.get('ageRating') else 0 + if min_age >= 16 and not self.age_bypass: + self.log.warning(f"Skipping '{movie_data.get('title')}' due to age rating ({min_age}+). Use --age-bypass to download.") + return Movies([]) + return Movies( [ Movie( @@ -258,6 +265,11 @@ class JOYNAT(Service): self.log.error("Invalid episode data received.") raise ValueError("Invalid episode data received from Joyn service.") + min_age = episode.get('ageRating', {}).get('minAge', 0) if episode.get('ageRating') else 0 + if min_age >= 16 and not self.age_bypass: + self.log.warning(f"Skipping episode '{episode.get('title')}' due to age rating ({min_age}+). Use --age-bypass to download.") + continue + episodes.append( Episode( id_=episode['id'], @@ -294,6 +306,11 @@ class JOYNAT(Service): self.log.error("Invalid episode_data data received.") raise ValueError("Invalid episode_data data received from Joyn service.") + min_age = episode_data.get('ageRating', {}).get('minAge', 0) if episode_data.get('ageRating') else 0 + if min_age >= 16 and not self.age_bypass: + self.log.warning(f"Skipping episode '{episode_data['title']}' due to age rating ({min_age}+). Use --age-bypass to download.") + return Series([]) + return Series( [ Episode(