diff --git a/beetsplug/VGMCollection.py b/beetsplug/VGMCollection.py index 016384b..9c0bad6 100644 --- a/beetsplug/VGMCollection.py +++ b/beetsplug/VGMCollection.py @@ -90,9 +90,7 @@ def _create_collection(self, collection_name): self.session.post(self.add_url, forms, cookies=self.session.cookies) def _get_collections(self): - collection_request = self.session.get( - self.collection_view, cookies=self.session.cookies - ) + collection_request = self.session.get(self.collection_view, cookies=self.session.cookies) soup = BeautifulSoup(collection_request.text, "lxml") mycollection = soup.find("ul", {"class": "treeview"}) listofCollection = [] @@ -110,18 +108,14 @@ def format_album(self, album_soup): return title, vgmdb_id, catalog_number, album_soup["ref"] def _get_albums_in_collection(self): - collection_request = self.session.get( - self.collection_view, cookies=self.session.cookies - ) + collection_request = self.session.get(self.collection_view, cookies=self.session.cookies) soup = BeautifulSoup(collection_request.text, "lxml") mycollection = soup.find("ul", {"class": "treeview"}) myalbums = [] for collection_name, collection_id in self._collections_cache: collection_soup = mycollection.find("li", {"ref": collection_id}) for album_soup in collection_soup.find_all("li"): - title, vgmdb_id, catalog_number, collection_ref = self.format_album( - album_soup - ) + title, vgmdb_id, catalog_number, collection_ref = self.format_album(album_soup) myalbums.append( { "title": title, @@ -133,12 +127,8 @@ def _get_albums_in_collection(self): ) # root album if mycollection is not None: - for album_soup in mycollection.findChildren( - "li", {"class": None}, recursive=False - ): - title, vgmdb_id, catalog_number, collection_ref = self.format_album( - album_soup - ) + for album_soup in mycollection.findChildren("li", {"class": None}, recursive=False): + title, vgmdb_id, catalog_number, collection_ref = self.format_album(album_soup) myalbums.append( { "title": title, diff --git a/beetsplug/VGMplug.py b/beetsplug/VGMplug.py index 70fdd50..9c65fff 100644 --- a/beetsplug/VGMplug.py +++ b/beetsplug/VGMplug.py @@ -20,19 +20,15 @@ class VGMdbPlugin(BeetsPlugin): def __init__(self): super(VGMdbPlugin, self).__init__() - self._log.setLevel('ERROR') + self._log.setLevel("ERROR") self.config.add({"lang-priority": "en,ja-latn,ja", "source_weight": 0.0}) self.config.add({"artist-priority": "composers,performers,arrangers"}) - self.artist_priority = ( - self.config["artist-priority"].get().replace(" ", "").split(",") - ) + self.artist_priority = self.config["artist-priority"].get().replace(" ", "").split(",") self.source_weight = self.config["source_weight"].as_number() self.lang = self.config["lang-priority"].get().replace(" ", "").split(",") self.track_pref = [TRACK_NAME_CONVENTION[lang] for lang in self.lang] - self.register_listener( - "before_choose_candidate", self.before_choose_candidate_event - ) + self.register_listener("before_choose_candidate", self.before_choose_candidate_event) def before_choose_candidate_event(self, session, task): if task.is_album: @@ -117,9 +113,7 @@ def track_distance(self, item, info: TrackInfo) -> Distance: dist.add("source", self.source_weight) return dist - def album_distance( - self, items: List, album_info: AlbumInfo, mapping: Dict - ) -> Distance: + def album_distance(self, items: List, album_info: AlbumInfo, mapping: Dict) -> Distance: """ :param items: @@ -182,9 +176,7 @@ def _format_track_info(self, albuminfo, url): track_title = track["names"][lang] break for lang in track["names"].keys(): - optional_args.update( - {f"vgmdb_track_name_{lang}": track["names"][lang]} - ) + optional_args.update({f"vgmdb_track_name_{lang}": track["names"][lang]}) tracks.append( TrackInfo( @@ -193,9 +185,7 @@ def _format_track_info(self, albuminfo, url): release_track_id=None, artist=None, artist_id=None, - length=float(track_length) - if track_length is not None - else None, + length=float(track_length) if track_length is not None else None, index=track_album_index, medium=disc_index + 1, medium_index=track_index + 1, @@ -236,9 +226,7 @@ def format_list_of_person(self, listofVGMPerson: List, typeofPerson: str): ) return out - def format_album_vgmdbinfo( - self, albuminfo: Dict, url: Optional[str] = None - ) -> AlbumInfo: + def format_album_vgmdbinfo(self, albuminfo: Dict, url: Optional[str] = None) -> AlbumInfo: """ :param albuminfo: @@ -371,11 +359,7 @@ def _format_query(self, artist, album, va_likely) -> Iterable: :param va_likely: :return: """ - return [ - self.sanitize(text) - for text in album.split(" -") - if len(self.sanitize(text)) > 0 - ] + return [self.sanitize(text) for text in album.split(" -") if len(self.sanitize(text)) > 0] def album_for_id(self, album_id: int) -> Optional[AlbumInfo]: """