From 7e2f426ddd5f360cc646a15a65ba755ff03c179e Mon Sep 17 00:00:00 2001 From: Josh Flatt Date: Wed, 10 Dec 2025 00:03:33 -0600 Subject: [PATCH] converted to py file --- download_stats.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 download_stats.py diff --git a/download_stats.py b/download_stats.py new file mode 100644 index 0000000..d1d24a4 --- /dev/null +++ b/download_stats.py @@ -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="#")