diff --git a/applications/task/services/smart_tag_resource.py b/applications/task/services/smart_tag_resource.py index 078b842..c2c3e55 100644 --- a/applications/task/services/smart_tag_resource.py +++ b/applications/task/services/smart_tag_resource.py @@ -1,5 +1,4 @@ - -from applications.task.utils import match_score +from applications.task.utils import match_score, match_artist from concurrent.futures import ThreadPoolExecutor from component import music_tag @@ -32,8 +31,14 @@ class SmartTagClient: for songs in results: for song in songs: title_score = match_score(title, song["name"]) - artist_score = match_score(artist if artist else title, song["artist"]) + artist_score = match_artist(artist if artist else title, song["artist"]) album_score = match_score(album if album else title, song["album"]) + if artist and artist_score == 0: + artist_score = -2 + # 标题包含艺术家信息 + if not artist and artist_score >= 1: + if title_score >= 1: + title_score = 2 song["score"] = title_score + artist_score + album_score max_score = max(max_score, song["score"]) if title_score == 0: diff --git a/applications/task/utils.py b/applications/task/utils.py index b71ec9f..658409e 100644 --- a/applications/task/utils.py +++ b/applications/task/utils.py @@ -50,6 +50,14 @@ def match_score(my_value, u_value): return 0 +def match_artist(my_value, u_value): + if "," in u_value: + return match_score(my_value, u_value.split(",")[0].replace(" ", "")) \ + + match_score(my_value, u_value.split(",")[1].replace(" ", "")) + else: + return match_score(my_value, u_value) + + def match_song(resource, song_path, select_mode): from applications.task.services.music_resource import MusicResource @@ -71,8 +79,14 @@ def match_song(resource, song_path, select_mode): } for song in songs: match_score_map["title"] = match_score(title, song["name"]) - match_score_map["artist"] = match_score(artist if artist else title, song["artist"]) + match_score_map["artist"] = match_artist(artist if artist else title, song["artist"]) match_score_map["album"] = match_score(album if album else title, song["album"]) + if artist and match_score_map["artist"] == 0: + match_score_map["artist"] = -2 + # 标题包含艺术家信息 + if not artist and match_score_map["artist"] >= 1: + if match_score_map["title"] >= 1: + match_score_map["title"] = 2 if sum(match_score_map.values()) >= 3: is_match = True song_select = song @@ -120,3 +134,7 @@ def detect_language(lyrics): return '泰文' else: return '未知' + + +def parse_discnumber(discnumber): + pass diff --git a/static/dist/index.prod.html b/static/dist/index.prod.html index c300006..233f836 100644 --- a/static/dist/index.prod.html +++ b/static/dist/index.prod.html @@ -1,3 +1,3 @@