mirror of
https://github.com/rakuri255/UltraSinger.git
synced 2026-11-20 13:07:52 +09:00
Merge branch 'main' into format_separated_string
# Conflicts: # ReleaseNotes.md # pytest/test_UltraSinger.py
This commit is contained in:
commit
fd975dfb73
3 files changed
+20
-1
No files matched your search
@@ -2,6 +2,7 @@ Version: 0.0.5
|
||||
Date: 2023.12.23
|
||||
Changes:
|
||||
- Format GENRE string
|
||||
- Extract year from date
|
||||
|
||||
Version: 0.0.4
|
||||
Date: 2023.12.16
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import unittest
|
||||
from src.UltraSinger import format_separated_string
|
||||
from src.UltraSinger import extract_year
|
||||
|
||||
class TestUltraSinger(unittest.TestCase):
|
||||
def test_format_separated_string(self):
|
||||
|
||||
@@ -10,3 +12,13 @@ class TestUltraSinger(unittest.TestCase):
|
||||
self.assertEqual(format_separated_string('rock/pop/rock-pop,'), 'Rock, Pop, Rock-Pop')
|
||||
self.assertEqual(format_separated_string('rock,pop/rock-pop;80s,'), 'Rock, Pop, Rock-Pop, 80s')
|
||||
self.assertEqual(format_separated_string('rock, pop, rock-pop, '), 'Rock, Pop, Rock-Pop')
|
||||
|
||||
def test_extract_year(self):
|
||||
years = {extract_year("2023-12-31"), extract_year("2023-12-31 23:59:59"), extract_year("2023/12/31"),
|
||||
extract_year("2023\\12\\31"), extract_year("2023.12.31"), extract_year("2023 12 31"),
|
||||
extract_year("12-31-2023"), extract_year("12/31/2023"), extract_year("12\\31\\2023"),
|
||||
extract_year("12.31.2023"), extract_year("12 31 2023"), extract_year("12-2023"),
|
||||
extract_year("12/2023"), extract_year("2023")}
|
||||
|
||||
for year in years:
|
||||
self.assertEqual(year, "2023")
|
||||
+7
-1
@@ -585,7 +585,7 @@ def create_ultrastar_txt_from_automation(
|
||||
if artist is not None:
|
||||
ultrastar_header.artist = artist
|
||||
if year is not None:
|
||||
ultrastar_header.year = year
|
||||
ultrastar_header.year = extract_year(year)
|
||||
if genre is not None:
|
||||
ultrastar_header.genre = format_separated_string(genre)
|
||||
|
||||
@@ -618,6 +618,12 @@ def create_ultrastar_txt_from_automation(
|
||||
)
|
||||
return real_bpm, ultrastar_file_output
|
||||
|
||||
def extract_year(date: str) -> str:
|
||||
match = re.search(r'\b\d{4}\b', date)
|
||||
if match:
|
||||
return match.group(0)
|
||||
else:
|
||||
return date
|
||||
|
||||
def format_separated_string(data: str) -> str:
|
||||
temp = re.sub(r'[;/]', ',', data)
|
||||
|
||||
Reference in new issue
Block a user