From a321458f596b60d0cf248de1fd19e613313609eb Mon Sep 17 00:00:00 2001 From: Josh Flatt Date: Wed, 10 Dec 2025 00:33:24 -0600 Subject: [PATCH] cleaned up more --- notebooks/make_df.ipynb | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/notebooks/make_df.ipynb b/notebooks/make_df.ipynb index 4b579a4..09b50e3 100644 --- a/notebooks/make_df.ipynb +++ b/notebooks/make_df.ipynb @@ -1031,13 +1031,27 @@ "metadata": {}, "outputs": [], "source": [ - "def change_filetype(row: pd.Series) -> pd.Series:\n", + "def fix_filetype(row: pd.Series) -> pd.Series:\n", " try:\n", - " if row['path'] != '-':\n", - " if row['correct_media_type'] == 'Image':\n", - " os.rename(src=f\"../downloads/{row['filename'][:-4]}.mp4\", dst=f\"../downloads/{row['filename'][:-4]}.jpg\")\n", - " elif row['correct_media_type'] == 'Video':\n", - " os.rename(src=f\"../downloads/{row['filename'][:-4]}.jpg\", dst=f\"../downloads/{row['filename'][:-4]}.mp4\")\n", + " mp4_file_path = f\"../downloads/{row['filename'][:-4]}.mp4\"\n", + " jpg_file_path = f\"../downloads/{row['filename'][:-4]}.jpg\"\n", + " \n", + " if row['correct_media_type'] == row['actual_media_type']:\n", + " return row\n", + " \n", + " if row['path'] == '-':\n", + " return row\n", + " \n", + " if row['correct_media_type'] == 'Image':\n", + " os.rename(src=mp4_file_path, dst=jpg_file_path)\n", + " if os.path.exists(jpg_file_path):\n", + " row['filename'] = f\"{row['filename'][:-4]}.jpg\"\n", + " row['actual_media_type'] = 'Image'\n", + " elif row['correct_media_type'] == 'Video':\n", + " os.rename(src=jpg_file_path, dst=mp4_file_path)\n", + " if os.path.exists(mp4_file_path):\n", + " row['filename'] = f\"{row['filename'][:-4]}.mp4\"\n", + " row['actual_media_type'] = 'Video'\n", " except FileNotFoundError:\n", " print(f\"File not found: {row['filename']}\")\n", " return row" @@ -1050,7 +1064,7 @@ "metadata": {}, "outputs": [], "source": [ - "wrong_filetype.apply(change_filetype, axis=1)" + "wrong_filetype.apply(fix_filetype, axis=1)" ] }, { @@ -1104,7 +1118,7 @@ "metadata": {}, "outputs": [], "source": [ - "def update_exif_with_exiftool(row):\n", + "def update_exif_with_exiftool(row: pd.Series) -> None:\n", " image_path = row['path']\n", " create_date = row['correct_date_utc']\n", " latitude = row['correct_latitude']\n",