finished search of metal encyclopedia
This commit is contained in:
parent
081a57360f
commit
c7811e9ae5
@ -2,5 +2,7 @@ from music_kraken.pages import (
|
|||||||
EncyclopaediaMetallum
|
EncyclopaediaMetallum
|
||||||
)
|
)
|
||||||
|
|
||||||
# print(EncyclopaediaMetallum.search_by_query("Death"))
|
print(EncyclopaediaMetallum.search_by_query("Psychonaut"))
|
||||||
|
print(EncyclopaediaMetallum.search_by_query("#a Ghost Bath"))
|
||||||
|
print(EncyclopaediaMetallum.search_by_query("#a Ghost Bath #r Self Loather"))
|
||||||
print(EncyclopaediaMetallum.search_by_query("#a Ghost Bath #r Self Loather #t hide from the sun"))
|
print(EncyclopaediaMetallum.search_by_query("#a Ghost Bath #r Self Loather #t hide from the sun"))
|
||||||
|
@ -240,7 +240,8 @@ class Album(DatabaseObject, ID3Metadata):
|
|||||||
is_split: bool = False,
|
is_split: bool = False,
|
||||||
albumsort: int = None,
|
albumsort: int = None,
|
||||||
dynamic: bool = False,
|
dynamic: bool = False,
|
||||||
sources: List[Source] = None
|
sources: List[Source] = None,
|
||||||
|
artists: list = None
|
||||||
) -> None:
|
) -> None:
|
||||||
DatabaseObject.__init__(self, id_=id_, dynamic=dynamic)
|
DatabaseObject.__init__(self, id_=id_, dynamic=dynamic)
|
||||||
self.title: str = title
|
self.title: str = title
|
||||||
@ -259,11 +260,14 @@ class Album(DatabaseObject, ID3Metadata):
|
|||||||
self.albumsort: int | None = albumsort
|
self.albumsort: int | None = albumsort
|
||||||
|
|
||||||
self.tracklist: List[Song] = []
|
self.tracklist: List[Song] = []
|
||||||
self.artists: List[Artist] = []
|
|
||||||
|
|
||||||
self._sources = []
|
self._sources = []
|
||||||
self.sources = sources
|
self.sources = sources
|
||||||
|
|
||||||
|
self.artists = []
|
||||||
|
if artists is not None:
|
||||||
|
self.artists = artists
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"Album: \"{self.title}\""
|
return f"Album: \"{self.title}\""
|
||||||
|
|
||||||
|
@ -37,6 +37,10 @@ class EncyclopaediaMetallum(Page):
|
|||||||
def advanced_search(cls, query: Page.Query) -> List[MusicObject]:
|
def advanced_search(cls, query: Page.Query) -> List[MusicObject]:
|
||||||
if query.song is not None:
|
if query.song is not None:
|
||||||
return cls.search_for_song(query=query)
|
return cls.search_for_song(query=query)
|
||||||
|
if query.album is not None:
|
||||||
|
return cls.search_for_album(query=query)
|
||||||
|
if query.artist is not None:
|
||||||
|
return cls.search_for_artist(query=query)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -48,7 +52,6 @@ class EncyclopaediaMetallum(Page):
|
|||||||
LOGGER.warning(f"code {r.status_code} at {endpoint.format(song=query.song_str, artist=query.artist_str, album=query.album_str)}")
|
LOGGER.warning(f"code {r.status_code} at {endpoint.format(song=query.song_str, artist=query.artist_str, album=query.album_str)}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
print(r.json()['aaData'])
|
|
||||||
return [cls.get_song_from_json(
|
return [cls.get_song_from_json(
|
||||||
artist_html=raw_song[0],
|
artist_html=raw_song[0],
|
||||||
album_html=raw_song[1],
|
album_html=raw_song[1],
|
||||||
@ -56,6 +59,35 @@ class EncyclopaediaMetallum(Page):
|
|||||||
title=raw_song[3]
|
title=raw_song[3]
|
||||||
) for raw_song in r.json()['aaData']]
|
) for raw_song in r.json()['aaData']]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def search_for_album(cls, query: Page.Query) -> List[Album]:
|
||||||
|
endpoint = "https://www.metal-archives.com/search/ajax-advanced/searching/albums/?bandName={artist}&releaseTitle={album}&releaseYearFrom=&releaseMonthFrom=&releaseYearTo=&releaseMonthTo=&country=&location=&releaseLabelName=&releaseCatalogNumber=&releaseIdentifiers=&releaseRecordingInfo=&releaseDescription=&releaseNotes=&genre=&sEcho=1&iColumns=3&sColumns=&iDisplayStart=0&iDisplayLength=200&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&_=1674563943747"
|
||||||
|
|
||||||
|
r = cls.API_SESSION.get(endpoint.format(artist=query.artist_str, album=query.album_str))
|
||||||
|
if r.status_code != 200:
|
||||||
|
LOGGER.warning(f"code {r.status_code} at {endpoint.format(song=query.song_str, artist=query.artist_str, album=query.album_str)}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
return [cls.get_album_from_json(
|
||||||
|
artist_html=raw_album[0],
|
||||||
|
album_html=raw_album[1],
|
||||||
|
release_type=[2]
|
||||||
|
) for raw_album in r.json()['aaData']]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def search_for_artist(cls, query: Page.Query) -> List[Artist]:
|
||||||
|
endpoint = "https://www.metal-archives.com/search/ajax-advanced/searching/bands/?bandName={artist}&genre=&country=&yearCreationFrom=&yearCreationTo=&bandNotes=&status=&themes=&location=&bandLabelName=&sEcho=1&iColumns=3&sColumns=&iDisplayStart=0&iDisplayLength=200&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&_=1674565459976"
|
||||||
|
|
||||||
|
r = cls.API_SESSION.get(endpoint.format(artist=query.artist))
|
||||||
|
if r.status_code != 200:
|
||||||
|
LOGGER.warning(f"code {r.status_code} at {endpoint.format(artist=query.artist)}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
return [
|
||||||
|
cls.get_artist_from_json(html=raw_artist[0], genre=raw_artist[1], country=raw_artist[2])
|
||||||
|
for raw_artist in r.json()['aaData']
|
||||||
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def simple_search(cls, query: Page.Query) -> List[Artist]:
|
def simple_search(cls, query: Page.Query) -> List[Artist]:
|
||||||
"""
|
"""
|
||||||
@ -69,7 +101,6 @@ class EncyclopaediaMetallum(Page):
|
|||||||
LOGGER.warning(f"code {r.status_code} at {endpoint.format(query=query.query)}")
|
LOGGER.warning(f"code {r.status_code} at {endpoint.format(query=query.query)}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
print(r.json())
|
|
||||||
return [
|
return [
|
||||||
cls.get_artist_from_json(html=raw_artist[0], genre=raw_artist[1], country=raw_artist[2])
|
cls.get_artist_from_json(html=raw_artist[0], genre=raw_artist[1], country=raw_artist[2])
|
||||||
for raw_artist in r.json()['aaData']
|
for raw_artist in r.json()['aaData']
|
||||||
@ -108,7 +139,7 @@ class EncyclopaediaMetallum(Page):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_album_from_json(cls, album_html=None, release_type=None) -> Album:
|
def get_album_from_json(cls, album_html=None, release_type=None, artist_html=None) -> Album:
|
||||||
# parse the html
|
# parse the html
|
||||||
# <a href="https://www.metal-archives.com/albums/Ghost_Bath/Self_Loather/970834">Self Loather</a>'
|
# <a href="https://www.metal-archives.com/albums/Ghost_Bath/Self_Loather/970834">Self Loather</a>'
|
||||||
soup = BeautifulSoup(album_html, 'html.parser')
|
soup = BeautifulSoup(album_html, 'html.parser')
|
||||||
@ -136,5 +167,5 @@ class EncyclopaediaMetallum(Page):
|
|||||||
main_artist_list=[
|
main_artist_list=[
|
||||||
cls.get_artist_from_json(html=artist_html)
|
cls.get_artist_from_json(html=artist_html)
|
||||||
],
|
],
|
||||||
album=cls.get_album_from_json(album_html=album_html, release_type=release_type)
|
album=cls.get_album_from_json(album_html=album_html, release_type=release_type, artist_html=artist_html)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user