diff --git a/BAT-and-UTIL-files/add-art-to-flac.bat b/BAT-and-UTIL-files/add-art-to-flac.bat index e4f4958..0f59772 100644 --- a/BAT-and-UTIL-files/add-art-to-flac.bat +++ b/BAT-and-UTIL-files/add-art-to-flac.bat @@ -1,19 +1,21 @@ -@echo off +@Echo OFF +rem We had to move this functionality into a subordinate BAT file after discovering that WinAmp only displays +rem artwork added by Metaflac if you remove the existing artwork first. So adding requires removing first. - SET ART=%1 - SET MUSIC=%2 - call validate-environment-variables ART MUSIC - metaflac --import-picture-from="%@UNQUOTE[%ART]" %MUSIC% +rem Capture parameters and validate environment: + set PARAMS_ADDARTTOFLAC=%* + set PARAM_ADDARTTOFLAC_1=%1 + set PARAM_ADDARTTOFLAC_2=%2 + if %VALIDATED_ADDARTTOFLAC ne 1 ( + call validate-in-path remove-art-from-flac add-art-to-flac-helper + set VALIDATED_ADDARTTOFLAC=1 + ) +rem Remove old art, add new art: + call remove-art-from-flac %PARAM_ADDARTTOFLAC_2% + call add-art-to-flac-helper %PARAM_ADDARTTOFLAC_1% %PARAM_ADDARTTOFLAC_2% - call warning "this is untested on flac yet - ERRORLEVEL = %ERRORLEVEL% - let's see what happens?!" - pause - - - if ERRORLEVEL 1 (%COLOR_ERROR %+ ECHO %EMOJI_RED_EXCLAMATION_MARK%ERROR embedding art "%ART%" into song "%SONG%"!! %+ BEEP %+ pause %+ pause %+ pause %+ pause %+ pause %+ pause %+ pause %+ pause %+ pause) -REM if ERRORLEVEL 0 .and. %DONT_DELETE_ART_AFTER_EMBEDDING ne 1 (del %ART%) - if ERRORLEVEL 0 .and. %DONT_DELETE_ART_AFTER_EMBEDDING ne 1 (%COLOR_SUCCESS% %+ echo %EMOJI_CHECK_MARK%Success!!! %+ if %DONT_DELETE_ART_AFTER_EMBEDDING ne 1 (%COLOR_REMOVAL %+ del %ART%)) diff --git a/BAT-and-UTIL-files/zipped/personal-BAT-files-used--------filelist.txt b/BAT-and-UTIL-files/zipped/personal-BAT-files-used--------filelist.txt index 87df414..fb53ddb 100644 --- a/BAT-and-UTIL-files/zipped/personal-BAT-files-used--------filelist.txt +++ b/BAT-and-UTIL-files/zipped/personal-BAT-files-used--------filelist.txt @@ -1,3 +1,3 @@ -2023-07-16 21:34 772 50% add-art-to-flac.bat +2024-04-19 20:02 781 55% add-art-to-flac.bat 2023-07-18 09:19 3,817 70% add-art-to-mp3.bat 2023-05-05 02:24 459 47% add-art-to-song.bat diff --git a/BAT-and-UTIL-files/zipped/personal-BAT-files-used-in-this-project.zip b/BAT-and-UTIL-files/zipped/personal-BAT-files-used-in-this-project.zip index 4b455d1..946d057 100644 Binary files a/BAT-and-UTIL-files/zipped/personal-BAT-files-used-in-this-project.zip and b/BAT-and-UTIL-files/zipped/personal-BAT-files-used-in-this-project.zip differ diff --git a/cover_downloader.py b/cover_downloader.py index 78761dd..cb5a8e7 100644 --- a/cover_downloader.py +++ b/cover_downloader.py @@ -282,7 +282,7 @@ def delete_file_with_backup(filename): -def does_companion_exist(filename): +def does_companion_exist_OLD_tried_and_true_for_a_year(filename): base_filename = os.path.splitext(filename)[0] image_extensions = [".jpg", ".jpeg", ".png", ".webp"] possible_filenames = [f"{base_filename}{s}{image_extension}" @@ -296,6 +296,23 @@ def does_companion_exist(filename): +def does_companion_exist(filename): #new 2024/04/19 version of function to include truncated last character situation I've run into + base_filename_1 = os.path.splitext(filename)[0] #with last charcter + base_filename_2 = os.path.splitext(filename)[:-1] #without last charcter + image_extensions = [".jpg", ".jpeg", ".png", ".webp"] + possible_filenames = [ f"{filename_to_use}{fname_range_sfx}{image_extension}" + for filename_to_use in [base_filename_1, base_filename_2] + for fname_range_sfx in ["", "A", "B", "C"] + [f"B{i}" for i in range(1, 999)] + for image_extension in image_extensions] + #primt("[PF] possible_filenames: " + possible_filenames) + for possible_filename in possible_filenames: + #primt("[CA] Checking " + possible_filename) + if file_exists_and_nonzero_size(possible_filename): + return True + return False + + + @@ -993,9 +1010,9 @@ def clean_up_zero_byte_downloads(): file.write('\n:CleanUp_Zero_Byte_Images_Execute\n') if IS_WINDOWS and OUR_SHELL.lower() != "bash": file.write('set FMASK_IMAGE=*.jpg;*.jpeg;*.gif;*.png;*.bmp;*.webp;*.ico;*.tif;*.tiff;*.pcx;*.art;*.dcm;*.jfif;*.jpg_large;*.png_large\n') - if OUR_SHELL == "TCC": file.write('call delete-zero-byte-files\n\n') #i have my own script for this purpose so i call that one too just to be double-thorough - if OUR_SHELL == "TCC": file.write('for %A in (%FMASK_IMAGE%) do ( if %@FILESIZE["%A"] == 0 (*del "%A") )\n\n') - else: file.write('for %%A in ("%FMASK_IMAGE%") do (if %%~zA equ 0 ( del "%%~A") )\n\n') #untested + if OUR_SHELL == "TCC": file.write('call delete-zero-byte-files %FMASK_IMAGE%\n\n') #i have my own script for this purpose so i call that one too just to be double-thorough, however that script needs to be passed a list of extensions or it ends up deleting other 0-byte files that are unrelated to this task + if OUR_SHELL == "TCC": file.write('for %A in (%FMASK_IMAGE%) do ( if %@FILESIZE["%A"] == 0 (*del /p "%A") )\n\n') + else: file.write('for %%A in ("%FMASK_IMAGE%") do (if %%~zA equ 0 ( del /p "%%~A") )\n\n') #untested else: file.write('export FMASK_IMAGE="*.jpg;*.jpeg;*.gif;*.png;*.bmp;*.webp;*.ico;*.tif;*.tiff;*.pcx;*.art;*.dcm;*.jfif;*.jpg_large;*.png_large"\n') file.write('find . -name "$FMASK_IMAGE" -size 0 -delete\n\n') #untested diff --git a/cover_embedder.py b/cover_embedder.py index 4cd4bf9..ce77ce2 100644 --- a/cover_embedder.py +++ b/cover_embedder.py @@ -18,7 +18,9 @@ def find_jpg(base_filename): bat_file.write("@Echo OFF\n\n") for audio_file in audio_files: # Iterate over audio files base_filename = os.path.splitext(audio_file)[0] # Get the base filename without the extension - jpg_filename = find_jpg(base_filename) # Search for a similarly named JPG + jpg_filename = None + if jpg_filename is None: jpg_filename = find_jpg(base_filename ) # Search for a similarly named JPG + if jpg_filename is None: jpg_filename = find_jpg(base_filename[:-1]) # Search for a similarly named JPG without the last character of the original name [for some reason I saw this happen in the wild] if jpg_filename: # Generate the command using the template and the filenames print(f" - yes companion jpg: {audio_file}") command = command_template.format(jpgfilename=jpg_filename, audiofilename=audio_file)