mirror of
https://github.com/WorldObservationLog/AppleMusicDecrypt.git
synced 2026-01-15 14:22:54 -03:00
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# DO NOT EDIT IT
|
||||
version = "0.0.7"
|
||||
version = "0.0.8"
|
||||
|
||||
[instance]
|
||||
url = "127.0.0.1:8080"
|
||||
@@ -91,6 +91,8 @@ playlistDirPathFormat = "downloads/playlists/{playlistName}"
|
||||
playlistSongNameFormat = "{playlistSongIndex:02d}. {artist} - {title}"
|
||||
# Save lyrics as .lrc file
|
||||
saveLyrics = true
|
||||
# lrc or ttml
|
||||
lyricsFormat = "ttml"
|
||||
saveCover = true
|
||||
coverFormat = "jpg"
|
||||
coverSize = "5000x5000"
|
||||
|
||||
@@ -5,7 +5,7 @@ from creart import exists_module
|
||||
from creart.creator import AbstractCreator, CreateTargetInfo
|
||||
from pydantic import BaseModel
|
||||
|
||||
CONFIG_VERSION = "0.0.7"
|
||||
CONFIG_VERSION = "0.0.8"
|
||||
|
||||
|
||||
class Instance(BaseModel):
|
||||
@@ -43,6 +43,7 @@ class Download(BaseModel):
|
||||
playlistDirPathFormat: str = "downloads/playlists/{playlistName}"
|
||||
playlistSongNameFormat: str = "{playlistSongIndex:02d}. {artist} - {title}"
|
||||
saveLyrics: bool = True
|
||||
lyricsFormat: str = "lrc"
|
||||
saveCover: bool = True
|
||||
coverFormat: str = "jpg"
|
||||
coverSize: str = "5000x5000"
|
||||
|
||||
@@ -7,7 +7,7 @@ from pydantic import BaseModel
|
||||
from src.api import WebAPI
|
||||
from src.models import AlbumMeta
|
||||
from src.models.song_data import Datum
|
||||
from src.utils import ttml_convent_to_lrc, count_total_track_and_disc
|
||||
from src.utils import ttml_convent, count_total_track_and_disc
|
||||
|
||||
NOT_INCLUDED_FIELD = ["playlistIndex", "bit_depth", "sample_rate", "sample_rate_kHz",
|
||||
"track_total", "disk_total", "cover_url"]
|
||||
@@ -75,7 +75,7 @@ class SongMetadata(BaseModel):
|
||||
if key in NOT_INCLUDED_FIELD:
|
||||
continue
|
||||
if key == "lyrics":
|
||||
lrc = ttml_convent_to_lrc(value)
|
||||
lrc = ttml_convent(value)
|
||||
tags.append(f"{key}={lrc}")
|
||||
continue
|
||||
if key.lower() in ('upc', 'isrc'):
|
||||
@@ -97,7 +97,7 @@ class SongMetadata(BaseModel):
|
||||
if key in NOT_INCLUDED_FIELD:
|
||||
continue
|
||||
if key == "lyrics":
|
||||
lrc = ttml_convent_to_lrc(value)
|
||||
lrc = ttml_convent(value)
|
||||
tags.update({TAG_MAPPING[key]: lrc})
|
||||
continue
|
||||
if key == "tracknum":
|
||||
|
||||
@@ -6,7 +6,7 @@ from creart import it
|
||||
from src.config import Config
|
||||
from src.metadata import SongMetadata
|
||||
from src.models import PlaylistInfo
|
||||
from src.utils import ttml_convent_to_lrc, get_song_name_and_dir_path, get_suffix
|
||||
from src.utils import ttml_convent, get_song_name_and_dir_path, get_suffix
|
||||
|
||||
|
||||
def save(song: bytes, codec: str, metadata: SongMetadata, playlist: PlaylistInfo = None):
|
||||
@@ -21,7 +21,7 @@ def save(song: bytes, codec: str, metadata: SongMetadata, playlist: PlaylistInfo
|
||||
with open(cover_path.absolute(), "wb") as f:
|
||||
f.write(metadata.cover)
|
||||
if it(Config).download.saveLyrics and metadata.lyrics:
|
||||
lrc = ttml_convent_to_lrc(metadata.lyrics)
|
||||
lrc = ttml_convent(metadata.lyrics)
|
||||
if lrc:
|
||||
lrc_path = dir_path / Path(song_name + ".lrc")
|
||||
lrc_path.write_text(lrc, encoding="utf-8")
|
||||
|
||||
@@ -87,7 +87,10 @@ def get_digit_from_string(text: str) -> int:
|
||||
return int(''.join(filter(str.isdigit, text)))
|
||||
|
||||
|
||||
def ttml_convent_to_lrc(ttml: str) -> str:
|
||||
def ttml_convent(ttml: str) -> str:
|
||||
if it(Config).download.lyricsFormat == "ttml":
|
||||
return ttml
|
||||
|
||||
b = BeautifulSoup(ttml, features="xml")
|
||||
lrc_lines = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user