forked from lcharlick/python-metallum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new functionality including song search and additional sear…
…ch parameters - Added functionality for the song search feature (song_search and SongResult and a change in the link parsing to extract the song ID) - Added additional search parameters for band_search and album_search such as release formats (there's a pull request for this by @pabe-github), additional notes etc. - Integrated the "similar artists" feature from @msanlop's fork and pull request, including the README example - Fixed the requests_cache.core import issue - "Lyrical themes" has since been renamed to just "Themes" - Added an other property to band_search results to allow access to additional search result parameters (issue by me Queries resulting in more than just the basic band information lcharlick#7) Original pull request: lcharlick#17
- Loading branch information
1 parent
901212b
commit 6b7c164
Showing
7 changed files
with
310 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from pyquery import PyQuery | ||
|
||
from metallum.models.Metallum import Metallum | ||
|
||
|
||
class SimilarArtists(Metallum, list): | ||
"""Entries in the similar artists tab""" | ||
|
||
def __init__(self, url, result_handler): | ||
super().__init__(url) | ||
data = self._content | ||
|
||
links_list = PyQuery(data)("a") | ||
values_list = PyQuery(data)("tr") | ||
|
||
# assert(len(links_list) == len(values_list) - 1) | ||
for i in range(0, len(links_list) - 1): | ||
details = [links_list[i].attrib.get("href")] | ||
details.extend(values_list[i + 1].text_content().split("\n")[1:-1]) | ||
self.append(result_handler(details)) | ||
self.result_count = i | ||
|
||
def __repr__(self): | ||
|
||
def similar_artist_str(SimilarArtistsResult): | ||
return f"{SimilarArtistsResult.name} ({SimilarArtistsResult.score})" | ||
|
||
if not self: | ||
return "<SimilarArtists: None>" | ||
names = list(map(similar_artist_str, self)) | ||
s = " | ".join(names) | ||
return "<SimilarArtists: {0}>".format(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.