Compare commits
No commits in common. "98dd8ade8b676bd3ab85fb52ddb6b93beead9f18" and "a404dcf09b2cc8db465dfa5d2fb5b08d75742a93" have entirely different histories.
98dd8ade8b
...
a404dcf09b
1 changed files with 3 additions and 3 deletions
|
@ -85,7 +85,7 @@ def generate_video_thumbnail(
|
||||||
video_path = pstfile.file.path
|
video_path = pstfile.file.path
|
||||||
|
|
||||||
# Create output directory if it doesn't exist
|
# Create output directory if it doesn't exist
|
||||||
output_dir = "/tmp/thumbgen/"
|
output_dir = os.path.join("/tmp/thumbgen/", str(file_id))
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
|
||||||
thumbnail_filename = f"thumbnail_{pstfile.hash_blake3}.png"
|
thumbnail_filename = f"thumbnail_{pstfile.hash_blake3}.png"
|
||||||
|
@ -114,6 +114,8 @@ def generate_video_thumbnail(
|
||||||
|
|
||||||
thumbnail_hash_blake3 = compute_file_hash_blake3(thumbnail_file_path)
|
thumbnail_hash_blake3 = compute_file_hash_blake3(thumbnail_file_path)
|
||||||
|
|
||||||
|
if pstfile.thumbnail_hash_blake3 == thumbnail_hash_blake3:
|
||||||
|
return "Thumbnail already exists for this video file."
|
||||||
|
|
||||||
# Update the PostFileModel's thumbnail field with the new file
|
# Update the PostFileModel's thumbnail field with the new file
|
||||||
with open(thumbnail_file_path, "rb") as file:
|
with open(thumbnail_file_path, "rb") as file:
|
||||||
|
@ -125,8 +127,6 @@ def generate_video_thumbnail(
|
||||||
|
|
||||||
pstfile.save()
|
pstfile.save()
|
||||||
|
|
||||||
os.remove(thumbnail_file_path)
|
|
||||||
|
|
||||||
return f"Thumbnail generated and saved to {thumbnail_file_path}"
|
return f"Thumbnail generated and saved to {thumbnail_file_path}"
|
||||||
|
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
|
|
Loading…
Add table
Reference in a new issue