From 9f163d5eca43712ef9795c00683b4362179f1bd5 Mon Sep 17 00:00:00 2001 From: Minmo Date: Thu, 16 Jul 2020 12:43:55 +0200 Subject: [PATCH 1/7] Fix album link The url to access albums seems to have changed in the meantime from "albums" to "AL" --- vocadb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vocadb.py b/vocadb.py index 481a717..f874cc0 100644 --- a/vocadb.py +++ b/vocadb.py @@ -243,7 +243,7 @@ def get_album_info(self, item): catalognum=catalognum, script='utf-8', # VocaDB's JSON responses are encoded in UTF-8 language=language, country=None, artist_credit=artist_credit, data_source='VocaDB', - data_url=(self.base_url + '/albums/%d' % album_id)) + data_url=(self.base_url + '/AL/%d' % album_id)) def add_genre_to_item(self, item, is_album): lang = self.lang[0] or 'Default' From 68f3bbc167a06e07d7ec64476a2e5e8578ee1a71 Mon Sep 17 00:00:00 2001 From: Minmo Date: Thu, 16 Jul 2020 12:46:44 +0200 Subject: [PATCH 2/7] Fix album artist issues Features (feat.) don't get included in album arists anymore (Hatsune Miku is not an album artist). Multiple album artists are separated with a semicolon now, which most software prefers. Various artists -> Various Artists, to conform with the musicbrainz standard --- vocadb.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vocadb.py b/vocadb.py index f874cc0..3e942b4 100644 --- a/vocadb.py +++ b/vocadb.py @@ -237,6 +237,19 @@ def get_album_info(self, item): and disctitles[track.medium]: track.disctitle = disctitles[track.medium] + + self._log.debug(f"old artist: {artist}") + try: + artist = re.search(r'(^.*)(\s+feat\.)', artist).group(1) + self._log.debug(f"new artist: {artist}") + artist = artist.replace(",", ";") + except: + pass + + if artist == "Various artists": + artist = "Various Artists" + self._log.debug(f"various artist?: {artist}") + return AlbumInfo(album_name, album_id, artist, artist_id, tracks, albumtype=albumtype, va=va, year=year, month=month, day=day, label=label, mediums=mediums, artist_sort=None, From cf23ecf2fb02aca8ec6036ac8f2dad482257bb6e Mon Sep 17 00:00:00 2001 From: Minmo Date: Thu, 16 Jul 2020 12:50:21 +0200 Subject: [PATCH 3/7] Fix issue with songs that have almost no info In some albums like https://vocadb.net/Al/18564 there are songs which do not contain enough information to get processed by this plugin. This resulted in no results being returned. Now instead it returns a dummy_title, so the plugin doesn't fail at least --- vocadb.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vocadb.py b/vocadb.py index 3e942b4..c2c33ed 100644 --- a/vocadb.py +++ b/vocadb.py @@ -124,8 +124,15 @@ def get_preferred_name(self, item): return (item_name, language) def get_track_info(self, item): - """"Convert JSON data into a format beets can read.""" - song = item['song'] + # This try-except is necessary because of albums like https://vocadb.net/Al/18564, that have songs with very little info + # You can probably improve this a lot by still providing the track title, but I spent way too much time debuggint this as it is + try: + """"Convert JSON data into a format beets can read.""" + song = item['song'] + self._log.debug(f"after song") + except: + return TrackInfo("dummy_title", 0, medium_index=0, medium_total=None, data_source='VocaDB',) + title, _ = self.get_preferred_name(item['song']) track_id = song['id'] artist = song['artistString'] From d8347095df7146a5614a7e016b07b5bee5b99d52 Mon Sep 17 00:00:00 2001 From: Minmo Date: Thu, 16 Jul 2020 12:53:17 +0200 Subject: [PATCH 4/7] Log album url --- vocadb.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vocadb.py b/vocadb.py index c2c33ed..8d35742 100644 --- a/vocadb.py +++ b/vocadb.py @@ -93,7 +93,9 @@ def album_for_id(self, album_id): def tracks_for_album_id(self, album_id): lang = self.lang[0] or 'Default' - r = requests.get(self.base_url + '/api/albums/%d/tracks?fields=Names,Artists&lang=%s' % (album_id, lang), + url = self.base_url + '/api/albums/%d/tracks?fields=Names,Artists&lang=%s' % (album_id, lang) + self._log.debug(f"Url to access album: {url}") + r = requests.get(url, headers={'Accept': 'application/json'}) try: tracks = r.json() From 2eee6b65239a19a232543328d7b7c9bbb2703b7f Mon Sep 17 00:00:00 2001 From: Minmo Date: Thu, 16 Jul 2020 12:53:39 +0200 Subject: [PATCH 5/7] Add same source_weight as musicbrainz Also make english the default language to be used for titles --- vocadb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vocadb.py b/vocadb.py index 8d35742..f49730d 100644 --- a/vocadb.py +++ b/vocadb.py @@ -14,14 +14,14 @@ def __init__(self): self.base_url = 'http://vocadb.net' self.lg = lastgenre.LastGenrePlugin() self.config.add({ - 'source_weight': 0.5, + 'source_weight': 0.0, 'canonical_artists': True, 'separator': ', ', 'whitelist': True, 'artist_priority': ['producers', 'circles'], 'circles_exclude': [], 'genres': True, - 'lang-priority': '' # 'Japanese, Romaji, English' + 'lang-priority': 'English' # 'Japanese, Romaji, English' }) self._log.debug('Querying VocaDB') self.lang = self.config['lang-priority'].get().split(',') From ad08efb4a7aa226a0f6e01b5a005f6ebd70e6bc3 Mon Sep 17 00:00:00 2001 From: Minmo Date: Thu, 16 Jul 2020 12:55:11 +0200 Subject: [PATCH 6/7] Remove whitespace --- vocadb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vocadb.py b/vocadb.py index f49730d..297177f 100644 --- a/vocadb.py +++ b/vocadb.py @@ -180,7 +180,7 @@ def get_album_info(self, item): artist_id = None artist_credit = None va = (artist == 'Various artists' or item['discType'] == 'Compilation') # if compilation - + # More detailed artist information if 'artists' in item and not self.config['canonical_artists'].get(): orig_artist = artist # the original artist before we start trying to find better ones @@ -195,7 +195,7 @@ def get_album_info(self, item): if (_artist['artist']['name'] in self.config['circles_exclude'].as_str_seq()\ and not len(producers) > 1): # Use a circle, even if it's excluded, when there are multiple primary producers break - + if ('Default' in _artist['roles'].split(', ') or orig_artist == 'Various artists'): artist_credit = orig_artist artist = _artist['artist']['name'] From 9560b8a5c2b71136edd7de4ea7132ba17b9f32c4 Mon Sep 17 00:00:00 2001 From: Minmo Date: Thu, 16 Jul 2020 12:58:10 +0200 Subject: [PATCH 7/7] Update readme with install instructions --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 9193b72..4d6e88b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,11 @@ #beets-vocadb +## How to install: + +* Clone this repository +* Modify beets config to point to this repository and enable the plugin: +``` +pluginpath: + - /path/beets-vocadb/ +plugins: vocadb +```