-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli):add quality and translation type selection
- Loading branch information
Benex254
committed
Jun 28, 2024
1 parent
84b8bd9
commit 1ffb122
Showing
36 changed files
with
674 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#! /usr/bin/bash | ||
cd $HOME/code/python/kivy_apps/FastAnime | ||
poetry install | ||
clear | ||
poetry run fastanime $* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[DEFAULT] | ||
server = | ||
continue_from_history = False | ||
quality = 0 | ||
auto_next = True | ||
sort_by = search match | ||
downloads_dir = /home/benxl-85/Videos/FastAnime | ||
translation_type = sub | ||
|
||
[stream] | ||
|
||
[general] | ||
|
||
[anilist] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
import shutil | ||
|
||
from pyshortcuts import make_shortcut | ||
|
||
from .. import ASSETS_DIR, PLATFORM | ||
|
||
|
||
def create_desktop_shortcut(): | ||
app = "_ -m fastanime --gui" | ||
|
||
logo = os.path.join(ASSETS_DIR, "logo.png") | ||
if PLATFORM == "Windows": | ||
logo = os.path.join(ASSETS_DIR, "logo.ico") | ||
if fastanime := shutil.which("fastanime"): | ||
app = f"{fastanime} --gui" | ||
make_shortcut( | ||
app, | ||
name="FastAnime", | ||
description="Download and watch anime", | ||
terminal=False, | ||
icon=logo, | ||
executable=fastanime, | ||
) | ||
else: | ||
make_shortcut( | ||
app, | ||
name="FastAnime", | ||
description="Download and watch anime", | ||
terminal=False, | ||
icon=logo, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,62 @@ | ||
import click | ||
from rich import print | ||
|
||
from .commands import anilist, download, search | ||
from .. import __version__ | ||
from ..libs.anime_provider.allanime.constants import SERVERS_AVAILABLE | ||
from ..Utility.data import anilist_sort_normalizer | ||
from .commands.anilist import anilist | ||
from .commands.config import configure | ||
from .commands.download import download | ||
from .commands.search import search | ||
from .config import Config | ||
|
||
commands = {"search": search, "download": download, "anilist": anilist} | ||
commands = { | ||
"search": search, | ||
"download": download, | ||
"anilist": anilist, | ||
"config": configure, | ||
} | ||
|
||
|
||
@click.group(commands=commands) | ||
def run_cli(): | ||
print("Yellow") | ||
@click.group(commands=commands, invoke_without_command=True) | ||
@click.version_option(__version__, "--version") | ||
@click.option( | ||
"-s", | ||
"--server", | ||
type=click.Choice(SERVERS_AVAILABLE, case_sensitive=False), | ||
) | ||
@click.option("-h", "--hist", type=bool) | ||
@click.option("-q", "--quality", type=int) | ||
@click.option("-t-t", "--translation_type") | ||
@click.option("-a-n", "--auto-next", type=bool) | ||
@click.option( | ||
"-s-b", | ||
"--sort-by", | ||
type=click.Choice(anilist_sort_normalizer.keys()), # pyright: ignore | ||
) | ||
@click.option("-d", "--downloads-dir", type=click.Path()) | ||
@click.pass_context | ||
def run_cli( | ||
ctx: click.Context, | ||
server, | ||
hist, | ||
translation_type, | ||
quality, | ||
auto_next, | ||
sort_by, | ||
downloads_dir, | ||
): | ||
ctx.obj = Config() | ||
if server: | ||
ctx.obj.server = server | ||
if hist: | ||
ctx.obj.continue_from_history = hist | ||
if quality: | ||
ctx.obj.quality = quality | ||
if auto_next: | ||
ctx.obj.auto_next = auto_next | ||
if sort_by: | ||
ctx.obj.sort_by = sort_by | ||
if downloads_dir: | ||
ctx.obj.downloads_dir = downloads_dir | ||
if translation_type: | ||
ctx.obj.translation_type = translation_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
import click | ||
|
||
from ....libs.anilist.anilist import AniList | ||
from ...interfaces.anime_interface import anime_interface | ||
from .utils import get_search_result | ||
|
||
|
||
@click.command() | ||
def trending(): | ||
success, trending = AniList.get_trending() | ||
if trending and success: | ||
result = get_search_result(trending) | ||
if result: | ||
anime_interface(result) | ||
get_search_result(trending) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import click | ||
|
||
|
||
@click.command() | ||
def configure(): | ||
pass | ||
|
||
# create_desktop_shortcut() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
import click | ||
|
||
from ..interfaces import anime_provider_ | ||
|
||
|
||
@click.command() | ||
def search(): | ||
print("Searching") | ||
@click.pass_obj | ||
def search( | ||
config, | ||
anime_title, | ||
): | ||
anime_provider_( | ||
config, | ||
anime_title, | ||
) |
Oops, something went wrong.