diff --git a/applications/task/serialziers.py b/applications/task/serialziers.py index a67a8c4..17ec148 100644 --- a/applications/task/serialziers.py +++ b/applications/task/serialziers.py @@ -15,6 +15,7 @@ class MusicId3Serializer(serializers.Serializer): title = serializers.CharField(required=True, allow_null=True, allow_blank=True) artist = serializers.CharField(required=True, allow_null=True, allow_blank=True) album = serializers.CharField(required=True, allow_null=True, allow_blank=True) + album_type = serializers.CharField(required=False, allow_null=True, allow_blank=True) albumartist = serializers.CharField(required=True, allow_null=True, allow_blank=True) discnumber = serializers.CharField(required=True, allow_null=True, allow_blank=True) tracknumber = serializers.CharField(required=True, allow_null=True, allow_blank=True) diff --git a/applications/task/services/music_ids.py b/applications/task/services/music_ids.py index bafe804..f3ffd58 100644 --- a/applications/task/services/music_ids.py +++ b/applications/task/services/music_ids.py @@ -26,6 +26,16 @@ class MusicIDS: return album_name return self.file["album"].value + @property + def album_type(self): + try: + if self.file.tag_format in ["FLAC", "OGG"]: + return self.file.mfile.tags.get("RELEASETYPE")[0] + else: + return self.file.mfile.tags.get("MUSICBRAINZALBUMTYPE")[0] + except Exception: + return "" + @property def album_artist(self): return self.file["albumartist"].value @@ -137,6 +147,7 @@ class MusicIDS: "title": self.title or self.file_name.split(".")[0], "artist": self.artist, "album": self.album, + "album_type": self.album_type, "genre": self.genre, "filename": self.file_name, "albumartist": self.album_artist, diff --git a/applications/task/services/update_ids.py b/applications/task/services/update_ids.py index dcfc131..9343d01 100644 --- a/applications/task/services/update_ids.py +++ b/applications/task/services/update_ids.py @@ -95,6 +95,11 @@ def save_music(f, each, is_raw_thumbnail): f['artwork'] = f['artwork'].first.raw_thumbnail([2048, 2048]) except Exception: pass + if each.get("album_type", None): + if file_ext in ["flac", "ogg"]: + f.mfile.tags["RELEASETYPE"] = each["album_type"] + else: + f["MUSICBRAINZALBUMTYPE"] = each["album_type"] f.save() # 重命名文件名称 if each.get("filename", None): diff --git a/component/mz/run.py b/component/mz/run.py index 7bfe27e..87a1d0c 100644 --- a/component/mz/run.py +++ b/component/mz/run.py @@ -14,4 +14,7 @@ apikey = "cSpUJKpD" def get_acoustid(path): - return acoustid.match(apikey, path) + try: + return acoustid.match(apikey, path) + except Exception: + return "" diff --git a/static/dist/index.prod.html b/static/dist/index.prod.html index 56eff97..6cbd407 100644 --- a/static/dist/index.prod.html +++ b/static/dist/index.prod.html @@ -1,3 +1,3 @@