feat: add new command test
parent
fb0edc73ee
commit
781258ad0f
|
@ -77,7 +77,6 @@ def command(ctx, anime_url, episode_range, url, player, skip_download, quality,
|
||||||
external_downloader, chunk_size, disable_ssl, fallback_qualities, choice):
|
external_downloader, chunk_size, disable_ssl, fallback_qualities, choice):
|
||||||
""" Download the anime using the url or search for it.
|
""" Download the anime using the url or search for it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
util.print_info(__version__)
|
util.print_info(__version__)
|
||||||
# TODO: Replace by factory
|
# TODO: Replace by factory
|
||||||
cls = get_anime_class(anime_url)
|
cls = get_anime_class(anime_url)
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
from anime_downloader.sites import get_anime_class, ALL_ANIME_SITES
|
||||||
|
from anime_downloader import util
|
||||||
|
from anime_downloader.__version__ import __version__
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
echo = click.echo
|
||||||
|
sitenames = [v[1] for v in ALL_ANIME_SITES]
|
||||||
|
|
||||||
|
|
||||||
|
class SiteThread(threading.Thread):
|
||||||
|
def __init__(self, site, *args, **kwargs):
|
||||||
|
self.site = site
|
||||||
|
self.exception = None
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
try:
|
||||||
|
ani = get_anime_class(self.site)
|
||||||
|
|
||||||
|
# this should be more dynamic
|
||||||
|
sr = ani.search('naruto')[0]
|
||||||
|
|
||||||
|
anime = ani(sr.url)
|
||||||
|
|
||||||
|
stream_url = anime[0].source().stream_url
|
||||||
|
except Exception as e:
|
||||||
|
self.exception = e
|
||||||
|
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
@click.argument('test_query', default='naruto')
|
||||||
|
def command(test_query):
|
||||||
|
"""Test all sites to see which ones are working and which ones aren't. Test naruto as a default."""
|
||||||
|
util.print_info(__version__)
|
||||||
|
logger = logging.getLogger("anime_downloader")
|
||||||
|
logger.setLevel(logging.WARNING)
|
||||||
|
|
||||||
|
threads = []
|
||||||
|
|
||||||
|
for site in sitenames:
|
||||||
|
t = SiteThread(site, daemon=True)
|
||||||
|
t.start()
|
||||||
|
threads.append(t)
|
||||||
|
|
||||||
|
for thread in threads:
|
||||||
|
thread.join(timeout=10)
|
||||||
|
if not thread.is_alive():
|
||||||
|
if not thread.exception:
|
||||||
|
# echo(click.style('Works ', fg='green') + site)
|
||||||
|
echo(click.style('✅ ', fg='green') + thread.site)
|
||||||
|
else:
|
||||||
|
logging.debug('Error occured during testing')
|
||||||
|
logging.debug(thread.exception)
|
||||||
|
echo(click.style("❌ ", fg='red') + thread.site)
|
||||||
|
else:
|
||||||
|
logging.debug('timeout during testing')
|
||||||
|
echo(click.style("❌ ", fg='red') + thread.site)
|
|
@ -52,6 +52,9 @@ def command(anime_name, new, update_all, _list, quality, remove,
|
||||||
download : Download episodes of selected anime
|
download : Download episodes of selected anime
|
||||||
"""
|
"""
|
||||||
util.print_info(__version__)
|
util.print_info(__version__)
|
||||||
|
echo('Watch is deprecated in favour of adl: https://github.com/RaitaroH/adl .')
|
||||||
|
echo('You can use dl command to stream anime if you do not want anime tracking.')
|
||||||
|
echo('watch command may come back in the future.')
|
||||||
|
|
||||||
watcher = _watch.Watcher()
|
watcher = _watch.Watcher()
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ NOTE: To download from sites marked `[cloudflare]`, anime-downloader has to be i
|
||||||
|
|
||||||
usage/installation
|
usage/installation
|
||||||
usage/dl
|
usage/dl
|
||||||
|
usage/test
|
||||||
usage/watch
|
usage/watch
|
||||||
usage/config
|
usage/config
|
||||||
usage/sites
|
usage/sites
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
``anime test``
|
||||||
|
==============
|
||||||
|
|
||||||
|
You can check which provider has your favorite anime and check which provider is currrently working.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
^^^^^
|
||||||
|
|
||||||
|
- To check the providers with code geass
|
||||||
|
|
||||||
|
.. code:: bash
|
||||||
|
anime test 'code geass'
|
Loading…
Reference in New Issue