Merge pull request #578 from AbdullahM0hamed/episode

master
Arjix 2021-10-16 13:55:12 +03:00 committed by GitHub
commit a4f3eeee51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import os
import click
import requests_cache
import re
from anime_downloader import session, util
from anime_downloader.__version__ import __version__
@ -92,6 +93,13 @@ def command(ctx, anime_url, episode_range, url, player, skip_download, quality,
""" Download the anime using the url or search for it.
"""
if episode_range:
regexed_range = re.compile("^:?(\d+)?:?(\d+)?$").search(episode_range)
# Prevent such cases as: :5: and :1:1
if not regexed_range or (len(regexed_range.groups()) >= episode_range.count(":") and episode_range.count(":") != 1):
raise click.UsageError(
"Invalid value for '--episode' / '-e': {} is not a valid range".format(episode_range))
if sub and dub:
raise click.UsageError(
"--dub/-d and --sub/-s flags cannot be used together")