Merge pull request #90 from itouakirai/v2
Some checks failed
/ Build Windows (push) Has been cancelled

replacement类型的翻译直接替换原歌词行
This commit is contained in:
世界观察日志
2025-12-30 19:55:06 +08:00
committed by GitHub
2 changed files with 4 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ apt update && apt install pipx git -y && pipx install poetry && pipx ensurepath
git clone https://github.com/WorldObservationLog/AppleMusicDecrypt git clone https://github.com/WorldObservationLog/AppleMusicDecrypt
cd AppleMusicDecrypt cd AppleMusicDecrypt
bash ./tools/install-deps.sh bash ./tools/install-deps.sh
poetry install poetry env use /usr/bin/python3 && poetry install
cp config.example.toml config.toml cp config.example.toml config.toml
nano config.toml nano config.toml
``` ```

View File

@@ -124,8 +124,11 @@ def ttml_convent(ttml: str) -> str:
lrc_lines.append( lrc_lines.append(
f"[{str(m + h * 60).rjust(2, '0')}:{str(s).rjust(2, '0')}.{str(int(ms / 10)).rjust(2, '0')}]{lyric.text}") f"[{str(m + h * 60).rjust(2, '0')}:{str(s).rjust(2, '0')}.{str(int(ms / 10)).rjust(2, '0')}]{lyric.text}")
if "translation" in it(Config).download.lyricsExtra and b.tt.head.metadata.iTunesMetadata.translation: if "translation" in it(Config).download.lyricsExtra and b.tt.head.metadata.iTunesMetadata.translation:
trans_type = b.tt.head.metadata.iTunesMetadata.translation.get("type")
for translation in b.tt.head.metadata.iTunesMetadata.translation.children: for translation in b.tt.head.metadata.iTunesMetadata.translation.children:
if lyric.get("itunes:key") == translation.get("for"): if lyric.get("itunes:key") == translation.get("for"):
if trans_type == "replacement":
del lrc_lines[-1]
lrc_lines.append( lrc_lines.append(
f"[{str(m + h * 60).rjust(2, '0')}:{str(s).rjust(2, '0')}.{str(int(ms / 10)).rjust(2, '0')}]{translation.text}") f"[{str(m + h * 60).rjust(2, '0')}:{str(s).rjust(2, '0')}.{str(int(ms / 10)).rjust(2, '0')}]{translation.text}")
if "pronunciation" in it(Config).download.lyricsExtra and b.tt.head.metadata.iTunesMetadata.transliteration: if "pronunciation" in it(Config).download.lyricsExtra and b.tt.head.metadata.iTunesMetadata.transliteration: