Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add yt_dlp_extra_options argument to VideoHash #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions videohash2/downloader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from shutil import which
from subprocess import PIPE, Popen
from typing import Optional

from .exceptions import DownloadFailed, DownloadOutPutDirDoesNotExist
from .utils import does_path_exists, get_list_of_all_files_in_dir
Expand All @@ -20,6 +21,7 @@ def __init__(
self,
url: str,
output_dir: str,
yt_dlp_extra_options: Optional[str] = None,
worst: bool = True,
) -> None:
"""
Expand All @@ -40,6 +42,7 @@ def __init__(
self.url = url
self.output_dir = output_dir
self.worst = worst
self.yt_dlp_extra_options= yt_dlp_extra_options

if not does_path_exists(self.output_dir):
raise DownloadOutPutDirDoesNotExist(
Expand Down Expand Up @@ -68,6 +71,7 @@ def download_video(self) -> None:
+ '"'
+ self.url
+ '"'
+ (f' {self.yt_dlp_extra_options} ' if self.yt_dlp_extra_options else '')
+ " -o "
+ '"'
+ self.output_dir
Expand Down
2 changes: 2 additions & 0 deletions videohash2/videocopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
def _copy_video_to_video_dir(
video_dir: str,
video_download_dir: str,
yt_dlp_extra_options: Optional[str],
do_not_copy: Optional[bool] = True,
download_worst: bool = False,
url: Optional[str] = None,
Expand Down Expand Up @@ -61,6 +62,7 @@ def _copy_video_to_video_dir(
url,
video_download_dir,
worst=download_worst,
yt_dlp_extra_options=yt_dlp_extra_options,
)

downloaded_file = get_list_of_all_files_in_dir(video_download_dir)[0]
Expand Down
6 changes: 4 additions & 2 deletions videohash2/videoduration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def video_duration(url: Optional[str] = None,
path: Optional[str] = None,
storage_path: Optional[str] = None,
do_not_copy: Optional[bool] = True,
ffmpeg_path: Optional[str] = None
ffmpeg_path: Optional[str] = None,
yt_dlp_extra_options: Optional[str] = None
) -> float:

"""
Expand Down Expand Up @@ -59,7 +60,8 @@ def video_duration(url: Optional[str] = None,
video_download_dir,
do_not_copy=do_not_copy,
download_worst=True,
url=url
url=url,
yt_dlp_extra_options=yt_dlp_extra_options
)

command = f'"{ffmpeg_path}" -i "{path}"'
Expand Down
5 changes: 4 additions & 1 deletion videohash2/videohash.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(
download_worst: bool = False,
frame_interval: Union[int, float] = 1,
do_not_copy: Optional[bool] = True,
yt_dlp_extra_options:Optional[str] = None
) -> None:
"""
:param path: Absolute path of the input video file.
Expand Down Expand Up @@ -76,6 +77,7 @@ def __init__(
self.download_worst = download_worst
self.do_not_copy = do_not_copy
self.frame_interval = frame_interval
self.yt_dlp_extra_options=yt_dlp_extra_options

self.task_uid = _get_task_uid()

Expand All @@ -98,7 +100,8 @@ def __init__(
do_not_copy=self.do_not_copy,
download_worst=self.download_worst,
url=self.url,
path=self.path
path=self.path,
yt_dlp_extra_options=self.yt_dlp_extra_options
)

self.video_duration = video_duration(path=self.video_path)
Expand Down