From 0868c1de3037563492330c1d1468003a9c959b3e Mon Sep 17 00:00:00 2001 From: itouakirai <85016486+itouakirai@users.noreply.github.com> Date: Sun, 31 Aug 2025 19:37:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20status=E8=AF=B7=E6=B1=82=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=89=A7=E8=A1=8Cstatus=E5=89=8Dlogin?= =?UTF-8?q?=E3=80=81logout=E5=90=8E=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cmd.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cmd.py b/src/cmd.py index f0b2ef5..c87a74d 100644 --- a/src/cmd.py +++ b/src/cmd.py @@ -55,6 +55,7 @@ class InteractiveShell: subparser.add_parser("exit") async def show_status(self): + it(WrapperManager).status.cache_invalidate() st_resp = await it(WrapperManager).status() it(GlobalLogger).logger.info(f"Regions available on wrapper-manager instance: {', '.join(st_resp.regions)}") @@ -165,6 +166,7 @@ class InteractiveShell: it(GlobalLogger).logger.error("Login Failed!") return it(GlobalLogger).logger.info("Login Success!") + it(WrapperManager).status.cache_invalidate() async def logout_flow(self): await it(WrapperManager).init(it(Config).instance.url, it(Config).instance.secure) @@ -176,6 +178,7 @@ class InteractiveShell: it(GlobalLogger).logger.error("Logout Failed!") return it(GlobalLogger).logger.info("Logout Success!") + it(WrapperManager).status.cache_invalidate() async def start(self): From 775f61d937edacf7d07833489eb55cdec7410dfb Mon Sep 17 00:00:00 2001 From: Lowmst Date: Wed, 3 Sep 2025 20:13:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0artist=5Fid?= =?UTF-8?q?=E3=80=81song=5Fid=E3=80=81album=5Fid=E5=88=B0=E5=85=83?= =?UTF-8?q?=E6=95=B0=E6=8D=AE;=20=E4=BD=BFrtng=E5=80=BC=E4=B8=BA0=E6=97=B6?= =?UTF-8?q?=E4=BB=8D=E7=84=B6=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.example.toml | 4 ++-- src/metadata.py | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/config.example.toml b/config.example.toml index 1f86005..b0d5f19 100644 --- a/config.example.toml +++ b/config.example.toml @@ -93,7 +93,7 @@ afterDownloaded = "" # title, artist, album, album_artist, composer, # genre, created, track, tracknum, disk, # record_company, upc, isrc, copyright, -# lyrics, cover, ratings(rtng) +# lyrics, cover, ratings(rtng), song_id, album_id, artist_id embedMetadata = ["title", "artist", "album", "album_artist", "composer", "album_created", "genre", "created", "track", "tracknum", "disk", "lyrics", "cover", "copyright", - "record_company", "upc", "isrc", "rtng"] \ No newline at end of file + "record_company", "upc", "isrc", "rtng", "song_id", "album_id", "artist_id"] \ No newline at end of file diff --git a/src/metadata.py b/src/metadata.py index b52ca90..aec48f2 100644 --- a/src/metadata.py +++ b/src/metadata.py @@ -10,7 +10,7 @@ from src.models.song_data import Datum from src.utils import ttml_convent_to_lrc, count_total_track_and_disc NOT_INCLUDED_FIELD = ["playlistIndex", "bit_depth", "sample_rate", "sample_rate_kHz", - "song_id", "album_id", "track_total", "disk_total"] + "track_total", "disk_total", "cover_url"] TAG_MAPPING = { "song_id": "cnID", # iTunes Catalog ID "title": "©nam", # MP4 title @@ -32,6 +32,7 @@ TAG_MAPPING = { "upc": "----:com.apple.iTunes:BARCODE", # MP4 barcode (UPC) "isrc": "----:com.apple.iTunes:ISRC", # MP4 ISRC "rtng": "rtng", # MP4 advisory rating + "artist_id": "atID" # iTunes Artist ID } @@ -63,6 +64,7 @@ class SongMetadata(BaseModel): bit_depth: Optional[int] = None sample_rate: Optional[int] = None sample_rate_kHz: Optional[str] = None + artist_id: Optional[str] = None def to_itags_params(self, embed_metadata: list[str]): tags = [] @@ -89,9 +91,9 @@ class SongMetadata(BaseModel): def to_mutagen_tags(self, embed_metadata: list[str]): tags = {} for key, value in self.model_dump().items(): - if not value: + if not value and key != "rtng": continue - if key in embed_metadata and value: + if key in embed_metadata: if key in NOT_INCLUDED_FIELD: continue if key == "lyrics": @@ -119,6 +121,15 @@ class SongMetadata(BaseModel): if key == "rtng": tags.update({TAG_MAPPING[key]: (value,)}) continue + if key == "song_id": + tags.update({TAG_MAPPING[key]: (int(value),)}) + continue + if key == "album_id": + tags.update({TAG_MAPPING[key]: (int(value),)}) + continue + if key == "artist_id": + tags.update({TAG_MAPPING[key]: (int(value),)}) + continue tags.update({TAG_MAPPING[key]: str(value)}) return tags @@ -136,7 +147,8 @@ class SongMetadata(BaseModel): isrc=song_data.attributes.isrc, album_created=song_data.relationships.albums.data[0].attributes.releaseDate, rtng=cls._rating(song_data.attributes.contentRating), - song_id=song_data.id, album_id=song_data.relationships.albums.data[0].id + song_id=song_data.id, album_id=song_data.relationships.albums.data[0].id, + artist_id=song_data.relationships.artists.data[0].id ) def parse_from_album_data(self, album_data: AlbumMeta):