From f68efd6919077915984ae33c1e6887db3eb71038 Mon Sep 17 00:00:00 2001 From: bender Date: Sun, 3 Mar 2024 00:35:11 -0500 Subject: [PATCH] Updated progress bar to be more accurate and added .DS_Store ignores --- .gitignore | 4 +++- Chop_Tag_Audio/exportchapters.py | 1 + Chop_Tag_Audio/final_metadata_add.py | 8 ++++++-- Chop_Tag_Audio/progress_bar.py | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e52e650..8b5b7c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ config.json -__pycache__/ \ No newline at end of file +__pycache__/ +.venv +.DS_Store \ No newline at end of file diff --git a/Chop_Tag_Audio/exportchapters.py b/Chop_Tag_Audio/exportchapters.py index 8d9f34e..089a680 100644 --- a/Chop_Tag_Audio/exportchapters.py +++ b/Chop_Tag_Audio/exportchapters.py @@ -39,6 +39,7 @@ def split_mp3s(annex, circulation): combined = AudioSegment.empty() for mp3_file in mp3_files: combined += AudioSegment.from_file(os.path.join(folder_path, mp3_file)) + overall_progress_bar.update(1) combined = combined.set_channels(1) # Assuming you want mono audio labels_file = os.path.join(folder_path, "overdrive_chapters_ms_spans.txt") diff --git a/Chop_Tag_Audio/final_metadata_add.py b/Chop_Tag_Audio/final_metadata_add.py index b66392f..bf5fa76 100644 --- a/Chop_Tag_Audio/final_metadata_add.py +++ b/Chop_Tag_Audio/final_metadata_add.py @@ -10,8 +10,10 @@ def process_directories(directory): '''Iterate through all subfolders in each author's directory & create cleaned_metadata.json''' for author_name in os.listdir(directory): author_path = os.path.join(directory, author_name) - if os.path.isdir(author_path): - for book_title in os.listdir(author_path): + if os.path.isdir(author_path): + for book_title in os.listdir(author_path): + if book_title == '.DS_Store': # Skip .DS_Store files/folders at this level, update for your systems specs + continue book_path = os.path.join(author_path, book_title) metadata_file = os.path.join(book_path, "cleaned_metadata.json") if os.path.exists(metadata_file): @@ -104,6 +106,8 @@ def meta_to_mp3(directory, bookshelf): author_path = os.path.join(directory, author_name) if os.path.isdir(author_path): for book_title in os.listdir(author_path): + if book_title == '.DS_Store': # Skip .DS_Store files/folders at this level + continue book_path = os.path.join(author_path, book_title) destination_path = os.path.join(bookshelf, author_name, book_title) os.makedirs(os.path.dirname(destination_path), exist_ok=True) diff --git a/Chop_Tag_Audio/progress_bar.py b/Chop_Tag_Audio/progress_bar.py index 00370e7..13f5db3 100644 --- a/Chop_Tag_Audio/progress_bar.py +++ b/Chop_Tag_Audio/progress_bar.py @@ -22,6 +22,7 @@ def get_chapter_count(directory): file_path = os.path.join(root, filename) with open(file_path, 'r') as f: total_chapters += sum(1 for _ in f) + total_chapters += len(fnmatch.filter(files, '*.mp3')) return total_chapters def process_progress(total_chapters):