Fixed odm loop error
This commit is contained in:
@@ -80,5 +80,5 @@ for folder in sorted(os.listdir(main_directory)):
|
|||||||
print(f"Error processing {folder}: {e}")
|
print(f"Error processing {folder}: {e}")
|
||||||
|
|
||||||
#Archive everything except chapters_list.py
|
#Archive everything except chapters_list.py
|
||||||
if folder_path != "chapters_list.py":
|
if os.path.isdir(folder_path) and folder != 'chapters_list.py':
|
||||||
shutil.move(folder_path, archive/ + folder)
|
shutil.move(folder_path, archive + '/' + folder)
|
||||||
@@ -2,16 +2,7 @@
|
|||||||
# I like having multiple folders so as to visualize each step happening
|
# I like having multiple folders so as to visualize each step happening
|
||||||
# but you could easily adjust the setup to fit your preferences
|
# but you could easily adjust the setup to fit your preferences
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
# Where you will be downloading your .odm's to, we're writing this one
|
|
||||||
# as an environment for the bash to reference
|
|
||||||
os.environ["queue"] = "/Users/jonas/Documents/SERVER/QUEUE"
|
|
||||||
|
|
||||||
# Where the unpackaged odm mp3s will get moved
|
# Where the unpackaged odm mp3s will get moved
|
||||||
# First for the bash
|
|
||||||
os.environ["annex"] = "/Users/jonas/Documents/SERVER/BOOKS/01_ANNEX"
|
|
||||||
# Then for python
|
|
||||||
annex="/Users/jonas/Documents/SERVER/BOOKS/01_ANNEX"
|
annex="/Users/jonas/Documents/SERVER/BOOKS/01_ANNEX"
|
||||||
|
|
||||||
# Where chapterized and labeled mp3s will be stored
|
# Where chapterized and labeled mp3s will be stored
|
||||||
|
|||||||
+7
-7
@@ -6,22 +6,22 @@
|
|||||||
python3.10 config.py
|
python3.10 config.py
|
||||||
|
|
||||||
# unpack odm's
|
# unpack odm's
|
||||||
bash overdrivedelete.sh
|
#bash overdrivedelete.sh
|
||||||
|
|
||||||
# extract chapters, specify folder holding the unpackaged overdrive mp3's
|
# extract chapters, specify folder holding the unpackaged overdrive mp3's
|
||||||
source config.env
|
##source config.env
|
||||||
python3 extract_overdrive_chapters.py $annex
|
#python3 extract_overdrive_chapters.py $annex
|
||||||
|
|
||||||
# clean metadata
|
# clean metadata
|
||||||
python3 metadatatoxml.py
|
#python3 metadatatoxml.py
|
||||||
|
|
||||||
python3 xmlparse.py
|
##python3 xmlparse.py
|
||||||
|
|
||||||
# turn chapters into ms
|
# turn chapters into ms
|
||||||
python3 chapter_ms.py
|
#python3 chapter_ms.py
|
||||||
|
|
||||||
# format durations
|
# format durations
|
||||||
python3 durations.py
|
#python3 durations.py
|
||||||
|
|
||||||
# export labeled audio and archive original folder
|
# export labeled audio and archive original folder
|
||||||
# FIX: MAKE SURE IT CAN ADD TO EXISTING AUTHOR FOLDER
|
# FIX: MAKE SURE IT CAN ADD TO EXISTING AUTHOR FOLDER
|
||||||
|
|||||||
+13
-23
@@ -1,24 +1,16 @@
|
|||||||
#This officially works for the full ODM extraction as of 1/21/23 at 9:54pm
|
#This officially works for the full ODM extraction as of 1/21/23 at 9:54pm
|
||||||
|
|
||||||
# Define the directories
|
|
||||||
source config.env
|
source config.env
|
||||||
input_folder=$queue
|
folder=$queue
|
||||||
output_folder=$annex
|
annex=$annex
|
||||||
|
|
||||||
shopt -s nullglob
|
for file in $folder/*.odm
|
||||||
if [ -z "$(find $input_folder -type f -name '*.odm')" ]; then
|
|
||||||
echo "No .odm files found in $input_folder, exiting."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Open ODM's in temporary directory and export contents
|
|
||||||
for file in $input_folder/*.odm
|
|
||||||
do
|
do
|
||||||
# Make temp dir in loop so that it clears even if there's any errors
|
# Make temp dir in loop so that it clears even if there's any errors
|
||||||
temp_dir=$(mktemp -d)
|
temp_dir=$(mktemp -d)
|
||||||
cd "$temp_dir"
|
cd "$temp_dir"
|
||||||
|
|
||||||
echo "folder path: $input_folder"
|
echo "folder path: $folder"
|
||||||
echo "temp_dir path: $temp_dir"
|
echo "temp_dir path: $temp_dir"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
@@ -33,17 +25,15 @@ do
|
|||||||
echo "downloaded_folder: $downloaded_folder"
|
echo "downloaded_folder: $downloaded_folder"
|
||||||
|
|
||||||
# Move the downloaded folder to the destination
|
# Move the downloaded folder to the destination
|
||||||
mv "$downloaded_folder" "$output_folder"
|
mv "$downloaded_folder" "$annex"
|
||||||
|
|
||||||
# Move the .odm.metadata to the downloaded folder
|
#Move the .odm.metadata to the downloaded folder
|
||||||
metadata_file=$(find "$input_folder" -name "*.odm.metadata")
|
metadata_file=$(find "$folder" -name "*.odm.metadata")
|
||||||
mv "$metadata_file" "$output_folder/$(basename "$downloaded_folder")"
|
mv "$metadata_file" "$annex/$(basename "$downloaded_folder")"
|
||||||
|
|
||||||
# Delete leftover .odm and .odm.license files
|
|
||||||
odm=$(find "$input_folder" -name "*.odm")
|
|
||||||
license=$(find "$input_folder" -name "*.odm.license")
|
|
||||||
rm $odm
|
|
||||||
rm $license
|
|
||||||
|
|
||||||
rm -rf "$temp_dir"
|
rm -rf "$temp_dir"
|
||||||
done
|
|
||||||
|
done
|
||||||
|
|
||||||
|
rm $queue/*.odm
|
||||||
|
rm $queue/*.odm.license
|
||||||
Reference in New Issue
Block a user