From 4a33dc6fc222d229c2d10a9d2c3fee6abfa08ae7 Mon Sep 17 00:00:00 2001 From: charlesxie <408737515@qq.com> Date: Tue, 8 Aug 2023 16:47:25 +0800 Subject: [PATCH] =?UTF-8?q?feature=EF=BC=9A=E6=96=B0=E5=A2=9E=20=E4=B8=93?= =?UTF-8?q?=E8=BE=91=E7=B1=BB=E5=9E=8B=E5=92=8C=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=AD=97=E6=AE=B5=E7=9A=84=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/task/serialziers.py | 1 + applications/task/services/music_ids.py | 11 + applications/task/services/update_ids.py | 5 + component/mz/run.py | 5 +- static/dist/index.prod.html | 2 +- web/src/views/home/home.vue | 524 ++++++++++++++--------- 6 files changed, 332 insertions(+), 216 deletions(-) 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 @@ 音乐标签Web版|Music Tag Web|
\ No newline at end of file + window.CSRF_COOKIE_NAME = 'django_vue_cli_csrftoken'
\ No newline at end of file diff --git a/web/src/views/home/home.vue b/web/src/views/home/home.vue index 71216d8..2252a1a 100644 --- a/web/src/views/home/home.vue +++ b/web/src/views/home/home.vue @@ -13,10 +13,11 @@
-
+