Add version 1.0.0 and 1.1.0 support for writer

This commit is contained in:
Vadim committed 2023-12-28 22:07:34 +01:00
1 parent 31fd4c5dc7
commit ae4dcd15b9
5 files changed
+136 -76

No files matched your search

@@ -27,6 +27,10 @@ def parse_ultrastar_txt(input_file: str) -> UltrastarTxtValue:
ultrastar_class.title = line.split(":")[1].replace("\n", "")
elif line.startswith(f"#{UltrastarTxtTag.MP3}"):
ultrastar_class.mp3 = line.split(":")[1].replace("\n", "")
elif line.startswith(f"#{UltrastarTxtTag.AUDIO}"):
ultrastar_class.audio = line.split(":")[1].replace("\n", "")
elif line.startswith(f"#{UltrastarTxtTag.VIDEO}"):
ultrastar_class.video = line.split(":")[1].replace("\n", "")
elif line.startswith(f"#{UltrastarTxtTag.GAP}"):
ultrastar_class.gap = line.split(":")[1].replace("\n", "")
elif line.startswith(f"#{UltrastarTxtTag.BPM}"):
+39 -27
View File
@@ -1,4 +1,5 @@
"""Ultrastar TXT"""
from enum import Enum
FILE_ENCODING = "utf-8"
@@ -7,54 +8,61 @@ FILE_ENCODING = "utf-8"
class UltrastarTxtTag(str, Enum):
"""Tags for Ultrastar TXT files."""
VERSION = 'VERSION' # Version of the file format: See https://usdx.eu/format/
# 0.2.0
VERSION = 'VERSION' # Version of the file format: See https://usdx.eu/format/
ARTIST = 'ARTIST'
TITLE = 'TITLE'
MP3 = 'MP3'
MP3 = 'MP3' # Removed in v2.0.0
GAP = 'GAP'
BPM = 'BPM'
LANGUAGE = 'LANGUAGE'
LANGUAGE = 'LANGUAGE' # Multi-language support since v1.1.0
GENRE = 'GENRE' # Multi-language support since v1.1.0
YEAR = 'YEAR' # Multi-language support since v1.1.0
COVER = 'COVER' # Path to cover. Should end with `*[CO].jpg`
CREATOR = 'CREATOR'
CREATOR = 'CREATOR' # Multi-language support since v1.1.0
COMMENT = 'COMMENT'
VIDEO = 'VIDEO'
FILE_END = 'E'
LINEBREAK = '-'
# Unused
# 1.1.0
AUDIO = 'AUDIO' # Its instead of MP3. Just renamed
VOCALS = 'VOCALS' # Vocals only audio
INSTRUMENTAL = 'INSTRUMENTAL' # Instrumental only audio
TAGS = 'TAGS' # Tags for the song. Can be used for filtering
# Unused 0.2.0
BACKGROUND = 'BACKGROUND' # Path to background. Is shown when there is no video. Should end with `*[BG].jpg`
VIDEOGAP = 'VIDEOGAP'
GENRE = 'GENRE'
EDITION = 'EDITION'
YEAR = 'YEAR'
EDITION = 'EDITION' # Multi-language support since v1.1.0
START = 'START'
END = 'END'
PREVIEWSTART = 'PREVIEWSTART'
MEDLEYSTARTBEAT = 'MEDLEYSTARTBEAT'
MEDLEYENDBEAT = 'MEDLEYENDBEAT'
MEDLEYSTARTBEAT = 'MEDLEYSTARTBEAT' # Removed in 2.0.0
MEDLEYENDBEAT = 'MEDLEYENDBEAT' # Removed in v2.0.0
CALCMEDLEY = 'CALCMEDLEY'
P1 = 'P1' # Only for UltraStar Deluxe
P2 = 'P2' # Only for UltraStar Deluxe
DUETSINGERP1 = 'DUETSINGERP1' # Removed in 1.0.0 (Used by UltraStar WorldParty)
DUETSINGERP2 = 'DUETSINGERP2' # Removed in 1.0.0 (Used by UltraStar WorldParty)
RESOLUTION = 'RESOLUTION' # Changes the grid resolution of the editor. Only for the editor and nothing for singing. # Removed in 1.0.0
NOTESGAP = 'NOTESGAP' # Removed in 1.0.0
RELATIVE = 'RELATIVE' # Removed in 1.0.0
ENCODING = 'ENCODING' # Removed in 1.0.0
FIXER = 'FIXER' # Only used in UltraStar World Party
# (Unused) 1.1.0
PROVIDEDBY = 'PROVIDEDBY' # Should the URL from hoster server
# (Unused) deprecated since 1.0.0
DUETSINGERP1 = 'DUETSINGERP1'
DUETSINGERP2 = 'DUETSINGERP2'
RESOLUTION = 'RESOLUTION' # Changes the grid resolution of the editor. Only for the editor and nothing for singing.
NOTESGAP = 'NOTESGAP'
RELATIVE = 'RELATIVE'
ENCODING = 'ENCODING'
# (Unused) New in (unreleased) 1.2.0
AUDIOURL = 'AUDIOURL' # URL to the audio file
COVERURL = 'COVERURL' # URL to the cover file
BACKGROUNDURL = 'BACKGROUNDURL' # URL to the background file
VIDEOURL = 'VIDEOURL' # URL to the video file
# (Unused) New in (unreleased) 2.0.0
MEDLEYSTART = 'MEDLEYSTART' # Rename of MEDLEYSTARTBEAT
MEDLEYEND = 'MEDLEYEND' # Renmame of MEDLEYENDBEAT
# (Unused) New in 1.1.0
AUDIO = 'AUDIO' # Its instead of MP3. Just renamed
VOCALS = 'VOCALS' # Vocals only audio
INSTRUMENTAL = 'INSTRUMENTAL' # Instrumental only audio
ONLINE = 'ONLINE' # URL of the song/video online
MUSICDB = 'MUSICDB' # ID or other of an online DB like musicbrainz
DIFFICULTY = 'DIFFICULTY' # Difficulty of the song
MEDLEYSTART = 'MEDLEYSTART' # Rename of MEDLEYSTARTBEAT
MEDLEYEND = 'MEDLEYEND' # Renmame of MEDLEYENDBEAT
class UltrastarTxtNoteTypeTag(str, Enum):
"""Note types for Ultrastar TXT files."""
@@ -74,11 +82,15 @@ class UltrastarTxtValue:
year = None
genre = ""
mp3 = ""
audio = ""
video = None
gap = ""
bpm = ""
language = None
cover = None
vocals = None
instrumental = None
tags = None
creator = "UltraSinger [GitHub]"
comment = "UltraSinger [GitHub]"
startBeat = []
+11 -3
View File
@@ -1,7 +1,7 @@
"""Ultrastar writer module"""
import re
from packaging import version
import langcodes
from modules.console_colors import ULTRASINGER_HEAD
@@ -47,7 +47,6 @@ def get_multiplier(real_bpm: float) -> int:
multiplier += 1
return multiplier - 2
def get_language_name(language: str) -> str:
"""Creates the language name from the language code"""
@@ -75,7 +74,8 @@ def create_ultrastar_txt_from_automation(
with open(ultrastar_file_output, "w", encoding=FILE_ENCODING) as file:
gap = transcribed_data[0].start
# file.write(f"#{UltrastarTxtTag.VERSION}:{ultrastar_class.version}\n"),
if version.parse(ultrastar_class.version) >= version.parse("1.0.0"):
file.write(f"#{UltrastarTxtTag.VERSION}:{ultrastar_class.version}\n"),
file.write(f"#{UltrastarTxtTag.ARTIST}:{ultrastar_class.artist}\n")
file.write(f"#{UltrastarTxtTag.TITLE}:{ultrastar_class.title}\n")
if ultrastar_class.year is not None:
@@ -87,6 +87,14 @@ def create_ultrastar_txt_from_automation(
if ultrastar_class.cover is not None:
file.write(f"#{UltrastarTxtTag.COVER}:{ultrastar_class.cover}\n")
file.write(f"#{UltrastarTxtTag.MP3}:{ultrastar_class.mp3}\n")
if version.parse(ultrastar_class.version) >= version.parse("1.1.0"):
file.write(f"#{UltrastarTxtTag.AUDIO}:{ultrastar_class.audio}\n")
if ultrastar_class.vocals is not None:
file.write(f"#{UltrastarTxtTag.VOCALS}:{ultrastar_class.vocals}\n")
if ultrastar_class.instrumental is not None:
file.write(f"#{UltrastarTxtTag.INSTRUMENTAL}:{ultrastar_class.instrumental}\n")
if ultrastar_class.tags is not None:
file.write(f"#{UltrastarTxtTag.TAGS}:{ultrastar_class.tags}\n")
file.write(f"#{UltrastarTxtTag.VIDEO}:{ultrastar_class.video}\n")
file.write(f"#{UltrastarTxtTag.BPM}:{round(ultrastar_bpm, 2)}\n") # not the real BPM!
file.write(f"#{UltrastarTxtTag.GAP}:{int(gap * 1000)}\n")