From 9f54fa4998bd71fdc6263a4739fc7acea0f97e91 Mon Sep 17 00:00:00 2001 From: Benex254 Date: Tue, 24 Sep 2024 15:55:24 +0300 Subject: [PATCH] feat: handle abscence of webtorrent-cli --- fastanime/Utility/downloader/downloader.py | 6 ++++++ fastanime/cli/utils/mpv.py | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/fastanime/Utility/downloader/downloader.py b/fastanime/Utility/downloader/downloader.py index f3613f5..3eb134a 100644 --- a/fastanime/Utility/downloader/downloader.py +++ b/fastanime/Utility/downloader/downloader.py @@ -62,6 +62,12 @@ class YtDLPDownloader: if url.endswith(".torrent"): WEBTORRENT_CLI = shutil.which("webtorrent") if not WEBTORRENT_CLI: + import time + + print( + "webtorrent cli is not installed which is required for downloading and streaming from nyaa\nplease install it or use another provider" + ) + time.sleep(120) return cmd = [ WEBTORRENT_CLI, diff --git a/fastanime/cli/utils/mpv.py b/fastanime/cli/utils/mpv.py index cec02e6..7a872cc 100644 --- a/fastanime/cli/utils/mpv.py +++ b/fastanime/cli/utils/mpv.py @@ -64,7 +64,16 @@ def run_mpv( youtube_regex = r"(https?://)?(www\.)?(youtube|youtu|youtube-nocookie)\.(com|be)/.+" if link.endswith(".torrent"): - cmd = ["webtorrent", link, f"--{player}"] + WEBTORRENT_CLI = shutil.which("webtorrent") + if not WEBTORRENT_CLI: + import time + + print( + "webtorrent cli is not installed which is required for downloading and streaming from nyaa\nplease install it or use another provider" + ) + time.sleep(120) + return "0", "0" + cmd = [WEBTORRENT_CLI, link, f"--{player}"] subprocess.run(cmd) return "0", "0" if player == "vlc":