change tagging logic (>.8 acoustid trumps all; >.4 acoustid fallback)
This commit is contained in:
parent
2027b80fb6
commit
d782ce8c48
1 changed files with 24 additions and 21 deletions
45
delojza.py
45
delojza.py
|
@ -109,23 +109,18 @@ class DelojzaBot:
|
||||||
artist = None
|
artist = None
|
||||||
source = None
|
source = None
|
||||||
|
|
||||||
if 'track' in info:
|
best_acoustid_score = 0
|
||||||
title = info['track']
|
|
||||||
if 'artist' in info:
|
|
||||||
artist = info['artist']
|
|
||||||
|
|
||||||
if 'track' in info or 'artist' in info:
|
if self.acoustid_key:
|
||||||
source = "supplied metadata"
|
|
||||||
|
|
||||||
if title is None or artist is None and self.acoustid_key:
|
|
||||||
try:
|
try:
|
||||||
self.logger.debug("Requesting AcoustID for {}".format(filepath))
|
self.logger.debug("Requesting AcoustID for {}".format(filepath))
|
||||||
results = sorted(acoustid.match(self.acoustid_key, filepath), key=itemgetter(0), reverse=True)
|
results = sorted(acoustid.match(self.acoustid_key, filepath), key=itemgetter(0), reverse=True)
|
||||||
if len(results) > 0:
|
if len(results) > 0:
|
||||||
score, rid, aid_title, aid_artist = results[0]
|
score, rid, aid_title, aid_artist = results[0]
|
||||||
if score > .8:
|
if score > .4:
|
||||||
title = aid_title
|
title = aid_title
|
||||||
artist = aid_artist
|
artist = aid_artist
|
||||||
|
best_acoustid_score = score
|
||||||
source = "AcoustID ({}%)".format(round(score * 100))
|
source = "AcoustID ({}%)".format(round(score * 100))
|
||||||
except acoustid.NoBackendError:
|
except acoustid.NoBackendError:
|
||||||
self.logger.warning("chromaprint library/tool not found")
|
self.logger.warning("chromaprint library/tool not found")
|
||||||
|
@ -134,19 +129,28 @@ class DelojzaBot:
|
||||||
except acoustid.WebServiceError as exc:
|
except acoustid.WebServiceError as exc:
|
||||||
self.logger.warning("web service request failed: {}".format(exc.message))
|
self.logger.warning("web service request failed: {}".format(exc.message))
|
||||||
|
|
||||||
if title is None and artist is None and '-' in info.get("title", ""):
|
if best_acoustid_score < .8:
|
||||||
split = info['title'].split("-")
|
if 'track' in info:
|
||||||
artist = split[0]
|
title = info['track']
|
||||||
title = split[1]
|
if 'artist' in info:
|
||||||
source = "fallback (artist - title)"
|
artist = info['artist']
|
||||||
|
|
||||||
if title is None and 'title' in info:
|
if 'track' in info or 'artist' in info:
|
||||||
title = info['title']
|
source = "supplied metadata"
|
||||||
source = "full title fallback"
|
|
||||||
|
|
||||||
if 'soundcloud' in info.get("extractor", "") and artist is None:
|
if title is None and artist is None and '-' in info.get("title", ""):
|
||||||
artist = info['uploader']
|
split = info['title'].split("-")
|
||||||
source = "soundcloud \"fallback\""
|
artist = split[0]
|
||||||
|
title = split[1]
|
||||||
|
source = "fallback (artist - title)"
|
||||||
|
|
||||||
|
if title is None and 'title' in info:
|
||||||
|
title = info['title']
|
||||||
|
source = "full title fallback"
|
||||||
|
|
||||||
|
if 'soundcloud' in info.get("extractor", "") and artist is None:
|
||||||
|
artist = info['uploader']
|
||||||
|
source = "soundcloud \"fallback\""
|
||||||
|
|
||||||
artist = artist.strip() if artist else None
|
artist = artist.strip() if artist else None
|
||||||
title = title.strip() if title else None
|
title = title.strip() if title else None
|
||||||
|
@ -332,7 +336,6 @@ class DelojzaBot:
|
||||||
if len(file_urls) > 0:
|
if len(file_urls) > 0:
|
||||||
self.handle(file_urls, message, hashtags, self.download_raw)
|
self.handle(file_urls, message, hashtags, self.download_raw)
|
||||||
|
|
||||||
# noinspection PyBroadException
|
|
||||||
def tg_handle_rest(self, bot, update):
|
def tg_handle_rest(self, bot, update):
|
||||||
self.handle_tg_message(update.message, bot, self.get_hashtags(update.message))
|
self.handle_tg_message(update.message, bot, self.get_hashtags(update.message))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue