Add debug logging to zip creation to diagnose missing files
Browse files
app.py
CHANGED
|
@@ -770,39 +770,55 @@ def create_song_package(audio, yt_url, name, lyrics, user_email, progress=gr.Pro
|
|
| 770 |
|
| 771 |
try:
|
| 772 |
with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:
|
|
|
|
|
|
|
| 773 |
# Add original audio
|
| 774 |
zf.write(audio_path, f"{safe_name}/original/{Path(audio_path).name}")
|
|
|
|
| 775 |
|
| 776 |
# Add mastered audio
|
| 777 |
if mastered_path and Path(mastered_path).exists():
|
| 778 |
zf.write(mastered_path, f"{safe_name}/mastered/{Path(mastered_path).name}")
|
|
|
|
| 779 |
|
| 780 |
# Add Pass 1 stems
|
|
|
|
| 781 |
for stem_name, stem_path in stems_pass1.items():
|
| 782 |
if Path(stem_path).exists():
|
| 783 |
zf.write(stem_path, f"{safe_name}/stems_basic/{stem_name}.mp3")
|
|
|
|
|
|
|
|
|
|
| 784 |
|
| 785 |
# Add Pass 2 stems
|
|
|
|
| 786 |
for stem_name, stem_path in stems_pass2.items():
|
| 787 |
if Path(stem_path).exists():
|
| 788 |
zf.write(stem_path, f"{safe_name}/stems_detailed/{stem_name}.mp3")
|
|
|
|
|
|
|
|
|
|
| 789 |
|
| 790 |
# Add chord chart
|
| 791 |
-
if chords_file and chords_file.exists():
|
| 792 |
-
zf.write(chords_file, f"{safe_name}/{chords_file.name}")
|
|
|
|
| 793 |
|
| 794 |
# Add Reaper project
|
| 795 |
-
if reaper_file and reaper_file.exists():
|
| 796 |
-
zf.write(reaper_file, f"{safe_name}/{reaper_file.name}")
|
|
|
|
| 797 |
|
| 798 |
# Add lyrics if provided
|
| 799 |
if lyrics:
|
| 800 |
-
|
| 801 |
-
with open(
|
| 802 |
f.write(lyrics)
|
| 803 |
-
zf.write(
|
|
|
|
| 804 |
|
| 805 |
log.append(f"\nPackage created: {safe_name}.zip")
|
|
|
|
| 806 |
log.append(f"Size: {zip_path.stat().st_size / (1024*1024):.1f} MB")
|
| 807 |
|
| 808 |
except Exception as e:
|
|
|
|
| 770 |
|
| 771 |
try:
|
| 772 |
with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:
|
| 773 |
+
files_added = []
|
| 774 |
+
|
| 775 |
# Add original audio
|
| 776 |
zf.write(audio_path, f"{safe_name}/original/{Path(audio_path).name}")
|
| 777 |
+
files_added.append("original")
|
| 778 |
|
| 779 |
# Add mastered audio
|
| 780 |
if mastered_path and Path(mastered_path).exists():
|
| 781 |
zf.write(mastered_path, f"{safe_name}/mastered/{Path(mastered_path).name}")
|
| 782 |
+
files_added.append("mastered")
|
| 783 |
|
| 784 |
# Add Pass 1 stems
|
| 785 |
+
stems1_added = 0
|
| 786 |
for stem_name, stem_path in stems_pass1.items():
|
| 787 |
if Path(stem_path).exists():
|
| 788 |
zf.write(stem_path, f"{safe_name}/stems_basic/{stem_name}.mp3")
|
| 789 |
+
stems1_added += 1
|
| 790 |
+
if stems1_added > 0:
|
| 791 |
+
files_added.append(f"stems_basic ({stems1_added})")
|
| 792 |
|
| 793 |
# Add Pass 2 stems
|
| 794 |
+
stems2_added = 0
|
| 795 |
for stem_name, stem_path in stems_pass2.items():
|
| 796 |
if Path(stem_path).exists():
|
| 797 |
zf.write(stem_path, f"{safe_name}/stems_detailed/{stem_name}.mp3")
|
| 798 |
+
stems2_added += 1
|
| 799 |
+
if stems2_added > 0:
|
| 800 |
+
files_added.append(f"stems_detailed ({stems2_added})")
|
| 801 |
|
| 802 |
# Add chord chart
|
| 803 |
+
if chords_file and Path(chords_file).exists():
|
| 804 |
+
zf.write(str(chords_file), f"{safe_name}/{chords_file.name}")
|
| 805 |
+
files_added.append("chords")
|
| 806 |
|
| 807 |
# Add Reaper project
|
| 808 |
+
if reaper_file and Path(reaper_file).exists():
|
| 809 |
+
zf.write(str(reaper_file), f"{safe_name}/{reaper_file.name}")
|
| 810 |
+
files_added.append("reaper")
|
| 811 |
|
| 812 |
# Add lyrics if provided
|
| 813 |
if lyrics:
|
| 814 |
+
lyrics_path = package_dir / f"{safe_name}_lyrics.txt"
|
| 815 |
+
with open(lyrics_path, 'w') as f:
|
| 816 |
f.write(lyrics)
|
| 817 |
+
zf.write(str(lyrics_path), f"{safe_name}/{lyrics_path.name}")
|
| 818 |
+
files_added.append("lyrics")
|
| 819 |
|
| 820 |
log.append(f"\nPackage created: {safe_name}.zip")
|
| 821 |
+
log.append(f"Contents: {', '.join(files_added)}")
|
| 822 |
log.append(f"Size: {zip_path.stat().st_size / (1024*1024):.1f} MB")
|
| 823 |
|
| 824 |
except Exception as e:
|