converted to py file

This commit is contained in:
Josh Flatt 2025-12-10 00:03:33 -06:00
parent b1a51fa266
commit 7e2f426ddd

45
download_stats.py Normal file
View File

@ -0,0 +1,45 @@
import subprocess
from pathlib import Path
import pandas as pd
file_directory = Path("../downloads")
files_to_check = [
p for p in file_directory.iterdir()
if p.is_file() and p.suffix.lower() in [".jpg", ".mp4"]
]
file_df = pd.DataFrame(data=files_to_check, columns=["file"])
def get_metadata(row: pd.Series) -> pd.Series:
file_path = row["file"]
command = [
"exiftool",
"-T",
"-createdate",
"-gpslatitude",
"-gpslongitude",
# *tags_to_check,
str(file_path)
]
result = subprocess.run(
command,
capture_output=True,
text=True,
check=False,
timeout=30
)
metadata = result.stdout.strip().split('\n')[0].split('\t')
if len(metadata) < 3:
metadata = metadata + ['-'] * (3 - len(metadata))
row["createdate"] = metadata[0]
row["gpslatitude"] = metadata[1]
row["gpslongitude"] = metadata[2]
return row
df = file_df.apply(get_metadata, axis=1)
df.to_csv("../temp/filemetadata.csv", index=False, sep="#")