From cd83cf5890232c545639ba77b4a5caac674608f4 Mon Sep 17 00:00:00 2001 From: anderbggo Date: Sun, 9 Oct 2022 13:46:16 +0200 Subject: [PATCH] (v 1.1) Added custom edited suffix --- README.md | 10 ++++++---- files/auxFunctions.py | 4 ++-- files/main.py | 6 ++++-- files/window.py | 14 ++++++++++++-- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6598086..4e5d1a6 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,15 @@ This algorithm is able to match this information in the image/video from the dow 1. Download your _Google Photos_ media from [Takeout](https://takeout.google.com/) -2. Download and execute [GPMatcher.exe](GPMatcher.exe) +2. Download and execute GPMatcher.exe -3. Select the folder in which images/videos along with its JSONs were downloaded ('Photos from 2022' for example) +3. [Optional] Type custom suffix used for edited photos (explained in the program) -4. Click on _Match_ button +4. Select the folder in which images/videos along with its JSONs were downloaded ('Photos from 2022' for example) -5. Matched images/videos will be on directory _Matched_ inside the same path +5. Click on _Match_ button + +6. Matched images/videos will be on directory _Matched_ inside the same path ## FAQs diff --git a/files/auxFunctions.py b/files/auxFunctions.py index f8b7452..1429328 100644 --- a/files/auxFunctions.py +++ b/files/auxFunctions.py @@ -7,9 +7,9 @@ # Function to search media associated to the JSON -def searchMedia(path, title, mediaMoved, nonEdited): +def searchMedia(path, title, mediaMoved, nonEdited, editedWord): title = fixTitle(title) - realTitle = str(title.rsplit('.', 1)[0] + "-editado." + title.rsplit('.', 1)[1]) + realTitle = str(title.rsplit('.', 1)[0] + "-" + editedWord + "." + title.rsplit('.', 1)[1]) filepath = path + "\\" + realTitle # First we check if exists an edited version of the image if not os.path.exists(filepath): realTitle = str(title.rsplit('.', 1)[0] + "(1)." + title.rsplit('.', 1)[1]) diff --git a/files/main.py b/files/main.py index 42bb9e0..9949588 100644 --- a/files/main.py +++ b/files/main.py @@ -3,7 +3,7 @@ from PIL import Image import PySimpleGUI as sg -def mainProcess(browserPath, window): +def mainProcess(browserPath, window, editedW): piexifCodecs = [k.casefold() for k in ['TIF', 'TIFF', 'JPEG', 'JPG']] mediaMoved = [] # array with names of all the media already matched @@ -12,6 +12,8 @@ def mainProcess(browserPath, window): nonEditedMediaPath = path + "\EditedRaw" errorCounter = 0 successCounter = 0 + editedWord = editedW or "editado" + print(editedWord) try: obj = list(os.scandir(path)) #Convert iterator into a list to sort it @@ -35,7 +37,7 @@ def mainProcess(browserPath, window): titleOriginal = data['title'] # Store metadata into vars try: - title = searchMedia(path, titleOriginal, mediaMoved, nonEditedMediaPath) + title = searchMedia(path, titleOriginal, mediaMoved, nonEditedMediaPath, editedWord) except Exception as e: print("Error on searchMedia() with file " + titleOriginal) diff --git a/files/window.py b/files/window.py index 1019848..371e72a 100644 --- a/files/window.py +++ b/files/window.py @@ -2,7 +2,11 @@ sg.theme("DarkTeal2") layout = [[sg.T("")], - [sg.Text("Choose a folder: "), sg.Input(key="-IN2-", change_submits=True), sg.FolderBrowse(key="-IN-")], + [sg.Text('Enter suffix used for edited photos (optional):')], + [sg.InputText(key='-INPUT_TEXT-'), sg.ReadFormButton('Help')], + [sg.T("")], + [sg.Text("Choose a folder: ")], + [sg.Input(key="-IN2-", change_submits=True), sg.FolderBrowse(key="-IN-")], [sg.T("")], [sg.Button("Match")], [sg.T("")], @@ -17,4 +21,10 @@ if event == sg.WIN_CLOSED or event == "Exit": break elif event == "Match": - mainProcess(values["-IN2-"], window) + mainProcess(values["-IN2-"], window, values['-INPUT_TEXT-']) + elif event == "Help": + sg.Popup("", "Media edited with the integrated editor of google photos " + "will download both the original image 'Example.jpg' and the edited version 'Example-editado.jpg'.", "", + "The 'editado' suffix changes depending on the language (in the case of Spain it will be 'editado').","", + "If you leave this box blank default spanish suffix will be used to search for edited photos.", + "", title="Information", icon='photos.ico')