python-metallum icon indicating copy to clipboard operation
python-metallum copied to clipboard

Added similar artists property to bands

Open msanlop opened this issue 3 years ago • 0 comments

Sorry for resubmiting I just learned that github only allows 1 account and ppl got banned so I wanna play it safe.

  • Added similar artists property that fetches the Similar Artists tab on a band's page.

  • Also added an example in the README.

  • commented requests_cache.core, doesn't exist (?!)

Usage preview:

bands = metallum.band_search('metallica')
band = bands[0].get()

metallica_sa = band.similar_artists
# -> <SimilarArtists: Megadeth (490) | Testament (415) | Exodus (212) | Evile (206) | Anthrax (184) | Death Angel (149) | Diamond Head (119) | Xentrix (114) | Annihilator (110) | Newsted (108) | Heathen (106) | Metal Church (105) | Flotsam and Jetsam (103) | Slayer (71) | Trivium (70) | Overkill (66) | Artillery (58) | Mortal Sin (58) | Volbeat (55) | Sacred Reich (50)>

metallica_sa[0]
# -> <SimilarArtist: Megadeth | United States | Speed/Thrash Metal (early/later); Heavy Metal/Rock (mid) | 490 >

metallica_sa[0].id
# -> '138'

metallica_sa[0].score
# -> 490

metallica_sa[0].genres
# -> ['Speed/Thrash Metal (early/later)', 'Heavy Metal/Rock (mid)']

metallica_sa[0].get()
#-> <Band: Megadeth>

#btw it would make more sense to pass id and append to endpoing in Band's __init__() I think 
band_without_sa = metallum.Band('/bands/_/3540496252') 
# -> <SimilarArtists: None>

This only gets the first 'batch', I'll probably add the option to get the 'see more' bands when I get the time. Cheers

PS: I had to comment out 2 lines with requests_cache.core because it doesn't seem to work for me idk... I submitted an issue. And some of the tests are outdated with the data on the site.

msanlop avatar Jan 16 '22 14:01 msanlop