From e5d70ddcbb2b263c1a2dd6bf075b1628fb0c7d18 Mon Sep 17 00:00:00 2001 From: djdembeck Date: Sat, 2 Oct 2021 23:03:53 -0500 Subject: [PATCH] feat(author-search): :sparkles: search/upgrade multi-author entries to single author entries for example: `Jason Anspach, Nick Cole, Doc Spears` -> `Jason Anspach` --- .vscode/settings.json | 3 ++- Contents/Code/__init__.py | 4 ++-- Contents/Code/search_tools.py | 11 ++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9df972f..9cfd3c4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,7 @@ { "conventionalCommits.scopes": [ "search", - "update" + "update", + "author-search" ] } \ No newline at end of file diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index b496325..020745e 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -72,13 +72,13 @@ def search(self, results, media, lang, manual): if not result: log.warn( 'No results found for query "%s"', - media.artist + search_helper.media.artist ) return log.debug( 'Found %s result(s) for query "%s"', len(result), - media.artist + search_helper.media.artist ) info = self.process_results(search_helper, result) diff --git a/Contents/Code/search_tools.py b/Contents/Code/search_tools.py index 3a14481..44fcec5 100644 --- a/Contents/Code/search_tools.py +++ b/Contents/Code/search_tools.py @@ -213,10 +213,19 @@ def parse_api_response(self, api_response): def validate_author_name(self): """ - Checks a list of known bad author names. + Checks for combined authors and a list of known bad author names. If matched, author name is set to None to prevent it being used in search query. """ + if ',' in self.media.artist: + split_authors = self.media.artist.split(',') + log.info( + 'Merging multi-author "' + + self.media.artist + + '" into top-level author "' + + split_authors[0] + '"' + ) + self.media.artist = split_authors[0] strings_to_check = [ "[Unknown Artist]" ]