Added errorhandling to PDF sheet generation

This commit is contained in:
TheZet committed 2024-12-18 09:53:51 -05:00
1 parent e9eba046ea
commit 3ad2f18bae
2 files changed
+17 -9

No files matched your search

+5 -4
View File
@@ -123,15 +123,16 @@ _Not all options working now!_
--crepe_step_size unit is miliseconds >> ((default) is 10)
[extra]
--hyphenation True|False >> ((default) is True)
--disable_separation True|False >> ((default) is False)
--hyphenation Disable automatic hyphenation > True|False >> ((default) is True)
--disable_separation Disable track separation > True|False >> ((default) is False)
--disable_karaoke True|False >> ((default) is False)
--ignore_audio True|False >> ((default) is False)
--create_audio_chunks True|False >> ((default) is False)
--keep_cache True|False >> ((default) is False)
--plot True|False >> ((default) is False)
--keep_cache Keep cache folder after generation > True|False >> ((default) is False)
--plot Create a pitch plot > True|False >> ((default) is False)
--format_version 0.3.0|1.0.0|1.1.0 >> ((default) is 1.0.0)
--musescore_path path to MuseScore executable
--keep_numbers Transcribe numbers as digits and not words > True|False >> ((default) is False)
[yt-dlp]
--cookiefile File name where cookies should be read from
+12 -5
View File
@@ -41,11 +41,18 @@ def create_sheet(midi_segments: list[MidiSegment],
success = set_environment_variables(musescore_path)
if not success:
return
s = stream.Stream()
add_metadata_to_stream(s, media_info.artist, media_info.title, int(media_info.bpm))
add_midi_segments_to_stream(s, midi_segments)
export_stream_to_pdf(s, os.path.join(output_folder_path, f"{filename}.pdf"))
move(os.path.join(output_folder_path, f"{filename}.musicxml"), os.path.join(cache_folder_path, f"{filename}.musicxml"))
try:
s = stream.Stream()
add_metadata_to_stream(s, media_info.artist, media_info.title, int(media_info.bpm))
add_midi_segments_to_stream(s, midi_segments)
export_stream_to_pdf(s, os.path.join(output_folder_path, f"{filename}.pdf"))
move(os.path.join(output_folder_path, f"{filename}.musicxml"), os.path.join(cache_folder_path, f"{filename}.musicxml"))
except Exception as e:
song_error = (f"{media_info.artist} - {media_info.title}")
print(f"{ULTRASINGER_HEAD} {red_highlighted('Error: Could not create sheet for')} {blue_highlighted(song_error)}")
print(f"\t{red_highlighted(f'Error: ->{e}')}")
return
def round_to_nearest_quarter(number: float) -> float:
return round(number * 4) / 4