8000 Added option to not copy video file to save on time for creating hash by aryan6969 · Pull Request #97 · akamhy/videohash · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added option to not copy video file to save on time for creating hash #97

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

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
12 changes: 3 additions & 9 deletions videohash/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,16 @@ def does_path_exists(path: str) -> bool:
If a directory is supplied then check if it exists.
If a file is supplied then check if it exists.

Directory ends with "/" on posix or "\" in windows and files do not.

If directory/file exists returns True else returns False

:return: True if dir or file exists else False.

:rtype: bool
"""
if path.endswith("/") or path.endswith("\\"):
# it's directory
return os.path.isdir(path)

if os.path.isdir(path) or os.path.isfile(path):
return os.path.exists(path)
else:
# it's file
return os.path.isfile(path)

return False

def create_and_return_temporary_directory() -> str:
"""
Expand Down
12 changes: 10 additions & 2 deletions videohash/videohash.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(
storage_path: Optional[str] = None,
download_worst: bool = False,
frame_interval: Union[int, float] = 1,
do_not_copy: bool = True,
) -> None:
"""
:param path: Absolute path of the input video file.
Expand Down Expand Up @@ -75,6 +76,7 @@ def __init__(

self._storage_path = self.storage_path
self.download_worst = download_worst
self.do_not_copy = do_not_copy
self.frame_interval = frame_interval

self.task_uid = VideoHash._get_task_uid()
Expand Down Expand Up @@ -290,7 +292,10 @@ def _copy_video_to_video_dir(self) -> None:

self.video_path = os.path.join(self.video_dir, (f"video.{extension}"))

shutil.copyfile(self.path, self.video_path)
if self.do_not_copy:
os.symlink(self.path, self.video_path)
else:
shutil.copyfile(self.path, self.video_path)

if self.url:

Expand All @@ -310,7 +315,10 @@ def _copy_video_to_video_dir(self) -> None:

self.video_path = f"{self.video_dir}video.{extension}"

shutil.copyfile(downloaded_file, self.video_path)
if self.do_not_copy:
shutil.copyfile(downloaded_file, self.video_path)
else:
shutil.copyfile(self.path, self.video_path)

def _create_required_dirs_and_check_for_errors(self) -> None:
"""
Expand Down
0