mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-15 09:00:51 -08:00
feat(cli): add downloads subcommand
This commit is contained in:
@@ -8,6 +8,7 @@ from ..Utility.data import anilist_sort_normalizer
|
||||
from .commands.anilist import anilist
|
||||
from .commands.config import configure
|
||||
from .commands.download import download
|
||||
from .commands.downloads import downloads
|
||||
from .commands.search import search
|
||||
from .config import Config
|
||||
|
||||
@@ -16,6 +17,7 @@ commands = {
|
||||
"download": download,
|
||||
"anilist": anilist,
|
||||
"config": configure,
|
||||
"downloads": downloads,
|
||||
}
|
||||
|
||||
|
||||
|
||||
32
fastanime/cli/commands/downloads.py
Normal file
32
fastanime/cli/commands/downloads.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import click
|
||||
|
||||
from ... import USER_VIDEOS_DIR
|
||||
from ...libs.fzf import fzf
|
||||
from ..utils.tools import exit_app
|
||||
|
||||
|
||||
@click.command(
|
||||
help="View and watch your downloads using mpv", short_help="Watch downloads"
|
||||
)
|
||||
def downloads():
|
||||
MPV = shutil.which("mpv")
|
||||
if not MPV:
|
||||
print("mpv not found")
|
||||
exit_app()
|
||||
return
|
||||
playlists = os.listdir(USER_VIDEOS_DIR)
|
||||
playlists.append("Exit")
|
||||
|
||||
def stream():
|
||||
playlist_name = fzf.run(playlists, "Enter Playlist Name", "Downloads")
|
||||
if playlist_name == "Exit":
|
||||
exit_app()
|
||||
playlist = os.path.join(USER_VIDEOS_DIR, playlist_name)
|
||||
subprocess.run([MPV, playlist])
|
||||
stream()
|
||||
|
||||
stream()
|
||||
Reference in New Issue
Block a user