Skip to content

Commit

Permalink
aply black
Browse files Browse the repository at this point in the history
  • Loading branch information
HOZHENWAI committed Mar 5, 2023
1 parent 1154a48 commit 679faa6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 39 deletions.
20 changes: 5 additions & 15 deletions beetsplug/VGMCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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,
Expand All @@ -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,
Expand Down
32 changes: 8 additions & 24 deletions beetsplug/VGMplug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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]:
"""
Expand Down

0 comments on commit 679faa6

Please sign in to comment.