From 5bc0e521791dfa3d23d53458041c1312089c9733 Mon Sep 17 00:00:00 2001 From: Benex254 Date: Sat, 17 Aug 2024 15:31:53 +0300 Subject: [PATCH] feat(download command): add headers functionality --- fastanime/Utility/downloader/downloader.py | 2 ++ fastanime/cli/commands/download.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/fastanime/Utility/downloader/downloader.py b/fastanime/Utility/downloader/downloader.py index 909e668..1dda018 100644 --- a/fastanime/Utility/downloader/downloader.py +++ b/fastanime/Utility/downloader/downloader.py @@ -37,6 +37,7 @@ class YtDLPDownloader: vid_format: str = "best", force_unknown_ext=False, verbose=False, + headers={}, ): """Helper function that downloads anime given url and path details @@ -52,6 +53,7 @@ class YtDLPDownloader: episode_title = sanitize_filename(episode_title) ydl_opts = { # Specify the output path and template + "http_headers": headers, "outtmpl": f"{download_dir}/{anime_title}/{episode_title}.%(ext)s", "silent": silent, "verbose": verbose, diff --git a/fastanime/cli/commands/download.py b/fastanime/cli/commands/download.py index d77c7d5..7f2851a 100644 --- a/fastanime/cli/commands/download.py +++ b/fastanime/cli/commands/download.py @@ -174,6 +174,7 @@ def download( input("Enter to continue") continue link = stream_link["link"] + provider_headers = server["headers"] episode_title = server["episode_title"] else: with Progress() as progress: @@ -198,6 +199,7 @@ def download( print("Quality not found") continue link = stream_link["link"] + provider_headers = servers[server]["headers"] episode_title = servers[server]["episode_title"] print(f"[purple]Now Downloading:[/] {search_result} Episode {episode}") @@ -211,6 +213,7 @@ def download( config.format, force_unknown_ext, verbose, + headers=provider_headers, ) except Exception as e: print(e)