Progress bar
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import sys
|
||||
import random
|
||||
import os
|
||||
import shutil
|
||||
from pydub import AudioSegment
|
||||
from XML_JSON.json_scripts import load_config
|
||||
from Chop_Tag_Audio.progress_bar import process_progress, get_chapter_count
|
||||
|
||||
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
config_path = os.path.join(parent_dir, 'config.json')
|
||||
@@ -28,20 +27,8 @@ def export_audio_file(combined, start_ms, end_ms, name, circulation, author_name
|
||||
return export_folder # Return the folder path where the file was exported
|
||||
|
||||
def split_mp3s(annex, circulation):
|
||||
update_messages = [
|
||||
"Getting close...",
|
||||
"Hang in there...",
|
||||
"Still running...",
|
||||
"Almost done...",
|
||||
"It'll all be over soon...",
|
||||
"Bear with me..."
|
||||
]
|
||||
|
||||
# Shuffle the list of messages
|
||||
random.shuffle(update_messages)
|
||||
|
||||
# An iterator over the shuffled list of messages
|
||||
message_cycle = iter(update_messages)
|
||||
total_chapters = get_chapter_count(annex)
|
||||
overall_progress_bar = process_progress(total_chapters)
|
||||
|
||||
for folder in sorted(os.listdir(annex)):
|
||||
folder_path = os.path.join(annex, folder)
|
||||
@@ -69,16 +56,9 @@ def split_mp3s(annex, circulation):
|
||||
export_folder = export_audio_file(combined, start_ms, end_ms, formatted_name, circulation, author_name.strip(), folder_name.strip())
|
||||
artwork_and_metadata(export_folder, folder_path)
|
||||
|
||||
overall_progress_bar.update(1)
|
||||
|
||||
file_count += 1 # Increment file_count after each file is exported
|
||||
|
||||
message = next(message_cycle, None)
|
||||
|
||||
if message is None: # If the end of the list is reached, shuffle and restart
|
||||
random.shuffle(update_messages)
|
||||
message_cycle = iter(update_messages)
|
||||
message = next(message_cycle)
|
||||
|
||||
print(message)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error processing {folder}: {e}")
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import sys
|
||||
import os
|
||||
import fnmatch
|
||||
from tqdm import tqdm
|
||||
|
||||
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, parent_dir)
|
||||
|
||||
from XML_JSON.json_scripts import load_config
|
||||
|
||||
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
config_path = os.path.join(parent_dir, 'config.json')
|
||||
|
||||
config = load_config(config_path)
|
||||
|
||||
directory = config['circulation']
|
||||
|
||||
def get_chapter_count(directory):
|
||||
total_chapters = 0
|
||||
for root, _, files in os.walk(directory):
|
||||
for filename in fnmatch.filter(files, 'overdrive_chapters_ms_spans.txt'):
|
||||
file_path = os.path.join(root, filename)
|
||||
with open(file_path, 'r') as f:
|
||||
total_chapters += sum(1 for _ in f)
|
||||
return total_chapters
|
||||
|
||||
def process_progress(total_chapters):
|
||||
return tqdm(total=total_chapters, ncols=75, desc="Splitting mp3's...")
|
||||
Reference in New Issue
Block a user