feat(download command): add headers functionality

This commit is contained in:
Benex254
2024-08-17 15:31:53 +03:00
parent 40f1c4fba5
commit 5bc0e52179
2 changed files with 5 additions and 0 deletions

View File

@@ -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,

View File

@@ -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)