commit
a1742d457f
|
@ -7,7 +7,7 @@ from anime_downloader import session, util
|
|||
from anime_downloader.__version__ import __version__
|
||||
from anime_downloader.sites import get_anime_class, ALL_ANIME_SITES
|
||||
|
||||
logger = logging.Logger(__name__)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
echo = click.echo
|
||||
sitenames = [v[1] for v in ALL_ANIME_SITES]
|
||||
|
@ -67,14 +67,18 @@ sitenames = [v[1] for v in ALL_ANIME_SITES]
|
|||
is_flag=True,
|
||||
help='Disable verifying the SSL certificate, if flag is set'
|
||||
)
|
||||
@click.option(
|
||||
'--choice', '-c',type=int,
|
||||
help='Choice to start downloading given anime number '
|
||||
)
|
||||
@click.pass_context
|
||||
def command(ctx, anime_url, episode_range, url, player, skip_download, quality,
|
||||
force_download, download_dir, file_format, provider,
|
||||
external_downloader, chunk_size, disable_ssl, fallback_qualities):
|
||||
external_downloader, chunk_size, disable_ssl, fallback_qualities, choice):
|
||||
""" Download the anime using the url or search for it.
|
||||
"""
|
||||
|
||||
util.print_info(__version__)
|
||||
|
||||
# TODO: Replace by factory
|
||||
cls = get_anime_class(anime_url)
|
||||
|
||||
|
@ -82,7 +86,7 @@ def command(ctx, anime_url, episode_range, url, player, skip_download, quality,
|
|||
session.get_session().verify = not disable_ssl
|
||||
|
||||
if not cls:
|
||||
anime_url = util.search(anime_url, provider)
|
||||
anime_url = util.search(anime_url, provider, choice)
|
||||
cls = get_anime_class(anime_url)
|
||||
|
||||
anime = cls(anime_url, quality=quality,
|
||||
|
|
|
@ -72,7 +72,7 @@ def format_search_results(search_results):
|
|||
return table
|
||||
|
||||
|
||||
def search(query, provider):
|
||||
def search(query, provider, choice=None):
|
||||
# Since this function outputs to stdout this should ideally be in
|
||||
# cli. But it is used in watch too. :(
|
||||
cls = get_anime_class(provider)
|
||||
|
@ -82,8 +82,11 @@ def search(query, provider):
|
|||
if not search_results:
|
||||
logger.error('No such Anime found. Please ensure correct spelling.')
|
||||
sys.exit(1)
|
||||
|
||||
val = click.prompt('Enter the anime no: ', type=int, default=1)
|
||||
|
||||
if choice:
|
||||
val = choice
|
||||
else:
|
||||
val = click.prompt('Enter the anime no: ', type=int, default=1)
|
||||
|
||||
try:
|
||||
url = search_results[val-1].url
|
||||
|
|
Loading…
Reference in New Issue