python-metallum
python-metallum copied to clipboard
Queries resulting in more than just the basic band information
BandResult only has properties to extract the data from index 0 to 2 which is sufficient for the most basic query result:
>>> print(metallum.band_search('Iron Maiden'))
[<SearchResult: Iron Maiden | Heavy Metal, NWOBHM | United Kingdom>]
But if other criteria are added, there'll be more information included in other indices and it adds up:
>>> print(metallum.band_search('Iron Maiden', countries='GB')) # Country query results in the location at index 2 instead of the country
[<SearchResult: Iron Maiden | Heavy Metal, NWOBHM | London, England >]
>>> print(metallum.band_search('Iron Maiden', location='London'))
[<SearchResult: Iron Maiden | Heavy Metal, NWOBHM | United Kingdom | London, England >] # Location query adds the location
>>> print(metallum.band_search('Iron Maiden', themes='History')) # Lyrical themes query adds data
[<SearchResult: Iron Maiden | Heavy Metal, NWOBHM | United Kingdom | History, Literature, War, Mythology, Society, Religion>]
>>> print(metallum.band_search('Iron Maiden', label="Parlophone")) # Label query adds data
[<SearchResult: Iron Maiden | Heavy Metal, NWOBHM | United Kingdom | Parlophone>]
Year created from/to both result in extra data containing the year the band was formed in:
>>> print(metallum.band_search('Iron Maiden', year_created_from="1970"))
[<SearchResult: Iron Maiden | Heavy Metal, NWOBHM | United Kingdom | 1975>]
>>> print(metallum.band_search('Iron Maiden', year_created_to="1980"))
[<SearchResult: Iron Maiden | Heavy Metal, NWOBHM | United Kingdom | 1975>]
>>> print(metallum.band_search('Iron Maiden', year_created_from="1970", year_created_to="1980"))
[<SearchResult: Iron Maiden | Heavy Metal, NWOBHM | United Kingdom | 1975>]
Arbitrary combinations are possible:
>>> print(metallum.band_search('Iron Maiden', themes='History', location='London'))
[<SearchResult: Iron Maiden | Heavy Metal, NWOBHM | United Kingdom | London, England | History, Literature, War, Mythology, Society, Religion>]
>>> print(metallum.band_search('Iron Maiden', countries='GB', location='London', themes='History', year_created_from="1970", year_created_to="1980"))
[<SearchResult: Iron Maiden | Heavy Metal, NWOBHM | London, England | History, Literature, War, Mythology, Society, Religion | 1975>]
Other queries don't add/change the basic data:
>>> print(metallum.band_search('Iron Maiden', status="1"))
[<SearchResult: Iron Maiden | Heavy Metal, NWOBHM | United Kingdom>]
To access the data separately I added the following in my local version
@property
def other(self) -> str:
"""
>>> s[0].other
['Politics, Misanthropy, Gore']
"""
return self[3:]
but this is fairly ugly and means that the user has to know what kind of information will be included in there, also in case of a country (but not location) query, the country property will return the location.