album artist

This commit is contained in:
quackerd 2024-02-29 03:11:45 +08:00
parent d258b93347
commit 0b1c8806a2
3 changed files with 24 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

View File

@ -1,4 +1,4 @@
from mutagen.id3 import ID3, APIC, TIT2, TPE1, TALB, Encoding, PictureType
from mutagen.id3 import ID3, APIC, TIT2, TPE1, TPE2, TALB, Encoding, PictureType
from mutagen.flac import FLAC, Picture
from pathlib import Path
import io
@ -21,6 +21,9 @@ class MObject:
def get_album(self) -> list[str]:
raise Exception("unimplemented")
def get_album_artist(self) -> list[str]:
raise Exception("unimplemented")
def get_artist(self) -> list[str]:
raise Exception("unimplemented")
@ -30,6 +33,9 @@ class MObject:
def set_artist(self, val : list[str]) -> None:
raise Exception("unimplemented")
def set_album_artist(self, val : list[str]) -> None:
raise Exception("unimplemented")
def set_album(self, val : list[str]) -> None:
raise Exception("unimplemented")
@ -77,6 +83,16 @@ class MMP3Object(MObject):
self._file_io.seek(0)
self._id3.save(self._file_io)
def get_album_artist(self) -> list[str]:
return self._id3.get("TPE2")
def set_album_artist(self, val : list[str]) -> None:
self._id3.delall("TPE2")
self._id3.add(TPE2(text = val))
self._file_io.seek(0)
self._id3.save(self._file_io)
def get_cover(self) -> bytes:
cover = self._id3.getall("APIC")
@ -118,6 +134,12 @@ class MFLACObject(MObject):
self._file_io.seek(0)
self._flac.save(self._file_io)
def get_album_artist(self) -> list[str]:
return self.get_artist()
def set_album_artist(self, val : list[str]) -> None:
return self.set_artist(val)
def get_artist(self) -> list[str]:
return self._flac.get("ARTIST")

View File

@ -151,6 +151,7 @@ def process_file(f: str, odir: str):
f" Title: \"{mobj.get_title()}\" -> \"{title}\"")
mobj.set_artist(artist)
mobj.set_album_artist(artist)
mobj.set_album(album)
mobj.set_title(title)