From dc80191313cf1f5bfd4fc2ef6c6a157f3e4688f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz?= Date: Tue, 25 Oct 2022 19:08:32 +0200 Subject: [PATCH 1/2] search_band with country fix --- src/enmet/entities.py | 4 ++-- src/enmet/pages.py | 2 +- src/enmet/search.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/enmet/entities.py b/src/enmet/entities.py index b6c94ce..8b160fc 100644 --- a/src/enmet/entities.py +++ b/src/enmet/entities.py @@ -81,13 +81,13 @@ def __str__(self): class Band(EnmetEntity): """Band or artist performing as a band.""" - def __init__(self, id_: str, *, name: str = None, country: str = None, genres: str = None): + def __init__(self, id_: str, *, name: str = None, country: Countries = None, genres: str = None): if not hasattr(self, "id"): super().__init__(id_) if name is not None: setattr(self, "name", name) if country is not None: - setattr(self, "country", Countries[country_to_enum_name(country)]) + setattr(self, "country", country) if genres is not None: setattr(self, "genres", genres) self._band_page = BandPage(self.id) diff --git a/src/enmet/pages.py b/src/enmet/pages.py index cbb6b72..2c60e8a 100644 --- a/src/enmet/pages.py +++ b/src/enmet/pages.py @@ -322,7 +322,7 @@ def reviews(self) -> Tuple[Optional[str], str]: return None, elem.text @cached_property - def tracks(self): + def tracks(self) -> List[List[Union[str, Optional[bool]]]]: result = [[]] for elem in self.enmet.select_one("#album_tabs_tracklist").select("tr.even,tr.odd,.discRow"): if "discRow" in elem["class"]: diff --git a/src/enmet/search.py b/src/enmet/search.py index 3a1d1d7..3f7a675 100644 --- a/src/enmet/search.py +++ b/src/enmet/search.py @@ -1,6 +1,6 @@ from typing import List -from enmet import Countries +from enmet import Countries, country_to_enum_name from enmet.common import ReleaseTypes, url_to_id, datestr_to_date from enmet.entities import Band, Album from enmet.pages import BandSearchPage, AlbumSearchPage, RandomBandPage @@ -30,7 +30,7 @@ def search_bands(*, name: str = None, strict: bool = None, genre: str = None, co params[_BAND_SEARCH_FIELDS_MAPPING["countries"]] = [c.value for c in countries or []] return [Band(url_to_id(b[0]), name=b[1], - country=countries[0] if countries and len(countries) == 1 else b[3]) + country=countries[0] if countries and len(countries) == 1 else Countries[country_to_enum_name(b[3])]) for b in BandSearchPage(params).bands] From 029b30e15ed4641563664586a00974bace723f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz?= Date: Tue, 25 Oct 2022 22:37:19 +0200 Subject: [PATCH 2/2] Version update --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4851f40..71f43cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "enmet" -version = "0.4.0" +version = "0.4.1" description = "Python API for Encyclopaedia Metallum (The Metal Archives) website." readme = {text = """ Enmet is a programmatic API to Encyclopaedia Metallum - The Metal Archives site. It allows convenient access to Metal Archives data from python code.