fixing #508 in ezdl

master
Blatzar 2020-09-13 10:07:41 +02:00 committed by GitHub
parent 80ed758b89
commit 2f403d4b2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 10 deletions

View File

@ -6,7 +6,7 @@ import requests_cache
from anime_downloader import session, util
from anime_downloader.__version__ import __version__
from anime_downloader.sites import get_anime_class, ALL_ANIME_SITES
from anime_downloader.sites import get_anime_class, ALL_ANIME_SITES, exceptions
from anime_downloader import animeinfo
from anime_downloader.config import Config
@ -16,6 +16,8 @@ echo = click.echo
sitenames = [v[1] for v in ALL_ANIME_SITES]
# NOTE: Don't put defaults here. Add them to the dict in config
@click.command()
@click.argument('anime_url')
@click.option(
@ -33,16 +35,15 @@ sitenames = [v[1] for v in ALL_ANIME_SITES]
type=click.Choice(sitenames)
)
@click.option(
'--ratio', '-r',type=int,
'--ratio', '-r', type=int,
help='Ratio used for the auto select in search. 100 means it only auto selects on complete matches. 0 auto selects regardless of how similar the result is.',
default=50
)
@click.option(
'--url', '-u', type=bool, is_flag=True,
help="If flag is set, prints the stream url instead of downloading")
@click.option(
'--choice', '-c',type=int,
'--choice', '-c', type=int,
help='Choice to start downloading given anime number ',
default=None
)
@ -50,7 +51,6 @@ sitenames = [v[1] for v in ALL_ANIME_SITES]
'--download-metadata', '-dm', is_flag=True,
help='Download additional metadata')
@click.option("--skip-fillers", is_flag=True, help="Skip downloading of fillers.")
@click.pass_context
def command(ctx, anime_url, episode_range, player,
force_download, provider,
@ -79,7 +79,7 @@ def command(ctx, anime_url, episode_range, player,
fallback_providers.insert(0, provider)
# Eliminates duplicates while keeping order
providers = sorted(set(fallback_providers),key=fallback_providers.index)
providers = sorted(set(fallback_providers), key=fallback_providers.index)
info = animeinfo.search_anilist(query, choice)
@ -89,15 +89,18 @@ def command(ctx, anime_url, episode_range, player,
# 1:3 -> for _episode in range(1, 4):
episode_range = util.parse_episode_range(episode_count, episode_range)
episode_range_split = episode_range.split(':')
# Issue #508.
if episode_range_split[0] > episode_range_split[-1]:
raise exceptions.NotFoundError('No episodes found within index.')
# Stores the choices for each provider, to prevent re-prompting search.
# As the current setup runs episode wise without this a 12 episode series would give 12+ prompts.
choice_dict = {}
# Doesn't work on nyaa since it only returns one episode.
for episode_range in range(int(episode_range_split[0]), int(episode_range_split[-1])+1):
for episode_range in range(int(episode_range_split[0]), int(episode_range_split[-1]) + 1):
# Exits if all providers are skipped.
if [choice_dict[i] for i in choice_dict] == [0]*len(providers):
if [choice_dict[i] for i in choice_dict] == [0] * len(providers):
logger.info('All providers skipped, exiting')
exit()
@ -116,8 +119,8 @@ def command(ctx, anime_url, episode_range, player,
rep_dict = {
'animeinfo_anime_title': util.slugify(info.title),
'provider': util.slugify(real_provider),
'anime_title':'{anime_title}',
'ep_no':'{ep_no}'
'anime_title': '{anime_title}',
'ep_no': '{ep_no}'
}
fixed_file_format = file_format.format(**rep_dict)
# Keeping this as I don't know the impact of removing it.