Make --list more powerful
parent
73ab5d691f
commit
88d56a93db
|
@ -17,6 +17,7 @@ Yeah. Me too! That's why this tool exists.
|
||||||
- Specify the quality you want to stream or download.
|
- Specify the quality you want to stream or download.
|
||||||
- Search and download. (Only 9anime)
|
- Search and download. (Only 9anime)
|
||||||
- Save yourselves from those malicious ads.
|
- Save yourselves from those malicious ads.
|
||||||
|
- Add any anime to your watch list using `anime watch` and let anime downloader take care of everything for you.
|
||||||
|
|
||||||
## Supported Sites
|
## Supported Sites
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ pip install -U git+https://github.com/vn-ki/anime-downloader.git#egg=anime-downl
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Anime downloader has two sub commands, `dl` and `watch`.
|
Anime downloader has two sub commands, `dl` and `watch`. You can find the documentation in [wiki](https://github.com/vn-ki/anime-downloader/wiki)
|
||||||
|
|
||||||
- [dl](https://github.com/vn-ki/anime-downloader/wiki/dl-command)
|
- [dl](https://github.com/vn-ki/anime-downloader/wiki/dl-command)
|
||||||
- [watch](https://github.com/vn-ki/anime-downloader/wiki/watch-command)
|
- [watch](https://github.com/vn-ki/anime-downloader/wiki/watch-command)
|
||||||
|
|
|
@ -140,7 +140,7 @@ def watch(anime_name, new, _list, quality, log_level, remove):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if _list:
|
if _list:
|
||||||
watcher.list()
|
list_animes(watcher)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if anime_name:
|
if anime_name:
|
||||||
|
@ -170,3 +170,48 @@ def watch(anime_name, new, _list, quality, log_level, remove):
|
||||||
anime.episodes_done += 1
|
anime.episodes_done += 1
|
||||||
watcher.update(anime)
|
watcher.update(anime)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
def list_animes(watcher):
|
||||||
|
watcher.list()
|
||||||
|
inp = click.prompt('Select an anime', default=1)
|
||||||
|
try:
|
||||||
|
anime = watcher.get(int(inp)-1)
|
||||||
|
except IndexError:
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
click.clear()
|
||||||
|
click.secho('Title: ' + click.style(anime.title, fg='green', bold=True))
|
||||||
|
click.echo('episodes_done: {}'.format(click.style(
|
||||||
|
str(anime.episodes_done), bold=True, fg='yellow')))
|
||||||
|
click.echo('Length: {}'.format(len(anime)))
|
||||||
|
|
||||||
|
meta = ''
|
||||||
|
for k, v in anime.meta.items():
|
||||||
|
meta += '{}: {}\n'.format(k, click.style(v, bold=True))
|
||||||
|
click.echo(meta)
|
||||||
|
|
||||||
|
click.echo('You can set title and episodes_done. '
|
||||||
|
'Ex: set episodes_done=3\n'
|
||||||
|
'You can remove by remove\n')
|
||||||
|
|
||||||
|
inp = click.prompt('Press q to exit', default='q').strip()
|
||||||
|
|
||||||
|
if inp == 'q':
|
||||||
|
break
|
||||||
|
elif inp == 'remove':
|
||||||
|
watcher.remove(anime.title)
|
||||||
|
break
|
||||||
|
elif 'set' in inp:
|
||||||
|
inp = inp.split('set ')[-1]
|
||||||
|
key, val = [v.strip() for v in inp.split('=')]
|
||||||
|
key = key.lower()
|
||||||
|
|
||||||
|
if key == 'title':
|
||||||
|
watcher.remove(anime)
|
||||||
|
setattr(anime, key, val)
|
||||||
|
watcher.add(anime)
|
||||||
|
elif key == 'episodes_done':
|
||||||
|
setattr(anime, key, int(val))
|
||||||
|
watcher.update(anime)
|
||||||
|
|
|
@ -6,7 +6,12 @@ import sys
|
||||||
import pickle
|
import pickle
|
||||||
import logging
|
import logging
|
||||||
import click
|
import click
|
||||||
from fuzzywuzzy import process
|
import warnings
|
||||||
|
|
||||||
|
# Don't warn if not using fuzzywuzzy[speedup]
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.simplefilter('ignore')
|
||||||
|
from fuzzywuzzy import process
|
||||||
|
|
||||||
|
|
||||||
class Watcher:
|
class Watcher:
|
||||||
|
@ -39,10 +44,17 @@ class Watcher:
|
||||||
|
|
||||||
def get(self, anime_name):
|
def get(self, anime_name):
|
||||||
animes = self._read_from_watch_file()
|
animes = self._read_from_watch_file()
|
||||||
|
|
||||||
|
if isinstance(anime_name, int):
|
||||||
|
return animes[anime_name]
|
||||||
|
|
||||||
match = process.extractOne(anime_name, animes, score_cutoff=40)
|
match = process.extractOne(anime_name, animes, score_cutoff=40)
|
||||||
if match:
|
if match:
|
||||||
return match[0]
|
return match[0]
|
||||||
|
|
||||||
|
def add(self, anime):
|
||||||
|
self._append_to_watch_file(anime)
|
||||||
|
|
||||||
def remove(self, anime_name):
|
def remove(self, anime_name):
|
||||||
animes = self._read_from_watch_file()
|
animes = self._read_from_watch_file()
|
||||||
animes = [anime for anime in animes if anime.title != anime_name]
|
animes = [anime for anime in animes if anime.title != anime_name]
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -20,7 +20,7 @@ setup(
|
||||||
'beautifulsoup4>=4.6.0',
|
'beautifulsoup4>=4.6.0',
|
||||||
'requests>=2.18.4',
|
'requests>=2.18.4',
|
||||||
'Click>=6.7',
|
'Click>=6.7',
|
||||||
'fuzzywuzzy[speedup]>=0.16.0',
|
'fuzzywuzzy>=0.16.0',
|
||||||
],
|
],
|
||||||
extras_require={
|
extras_require={
|
||||||
'cloudflare': ['cfscrape>=1.9.5']
|
'cloudflare': ['cfscrape>=1.9.5']
|
||||||
|
|
Loading…
Reference in New Issue