mirror of
https://github.com/xhongc/music-tag-web.git
synced 2026-02-03 02:03:35 +08:00
feature:支持音乐指纹识别,即使没有元数据也可以识别音乐
This commit is contained in:
@@ -37,6 +37,7 @@ class BatchUpdateId3Serializer(serializers.Serializer):
|
||||
class FetchId3ByTitleSerializer(serializers.Serializer):
|
||||
title = serializers.CharField(required=True)
|
||||
resource = serializers.CharField(required=True)
|
||||
full_path = serializers.CharField(required=False, allow_null=True, allow_blank=True)
|
||||
|
||||
|
||||
class FetchLlyricSerializer(serializers.Serializer):
|
||||
|
||||
22
applications/task/services/acoust.py
Normal file
22
applications/task/services/acoust.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from component.mz.run import get_acoustid
|
||||
|
||||
|
||||
class AcoustidClient:
|
||||
def fetch_id3_by_title(self, title):
|
||||
songs = []
|
||||
res = get_acoustid(title)
|
||||
for each in res:
|
||||
songs.append({
|
||||
"id": each[1],
|
||||
"name": each[2],
|
||||
"artist": each[3],
|
||||
"artist_id": "",
|
||||
"album": each[4],
|
||||
"album_id": "",
|
||||
"album_img": "",
|
||||
"year": "",
|
||||
})
|
||||
return songs
|
||||
|
||||
def fetch_lyric(self, song_id):
|
||||
raise Exception("暂不支持该音乐平台")
|
||||
@@ -1,6 +1,7 @@
|
||||
import requests
|
||||
import base64
|
||||
|
||||
from applications.task.services.acoust import AcoustidClient
|
||||
from applications.task.services.kugou import KugouClient
|
||||
from applications.task.services.kuwo import KuwoClient
|
||||
from applications.task.services.qm import QQMusicApi
|
||||
@@ -23,6 +24,8 @@ class MusicResource:
|
||||
return KugouClient()
|
||||
elif info == "kuwo":
|
||||
return KuwoClient()
|
||||
elif info == "acoustid":
|
||||
return AcoustidClient()
|
||||
raise Exception("暂不支持该音乐平台")
|
||||
|
||||
def fetch_lyric(self, song_id):
|
||||
|
||||
@@ -211,8 +211,11 @@ class TaskViewSets(GenericViewSet):
|
||||
def fetch_id3_by_title(self, request, *args, **kwargs):
|
||||
validate_data = self.is_validated_data(request.data)
|
||||
resource = validate_data["resource"]
|
||||
|
||||
full_path = validate_data.get("full_path", "")
|
||||
title = validate_data["title"]
|
||||
|
||||
if resource == "acoustid":
|
||||
title = full_path
|
||||
songs = MusicResource(resource).fetch_id3_by_title(title)
|
||||
return self.success_response(data=songs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user