rewritten general search for me
This commit is contained in:
parent
70c7d831c9
commit
70e0a16b20
@ -20,6 +20,7 @@ from ..objects import (
|
|||||||
FormattedText,
|
FormattedText,
|
||||||
Label,
|
Label,
|
||||||
Options,
|
Options,
|
||||||
|
DatabaseObject
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -202,22 +203,21 @@ class EncyclopaediaMetallum(Page):
|
|||||||
for raw_artist in r.json()['aaData']
|
for raw_artist in r.json()['aaData']
|
||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
def general_search(self, query: str) -> List[DatabaseObject]:
|
||||||
def _raw_search(cls, query: str) -> Options:
|
|
||||||
"""
|
"""
|
||||||
Searches the default endpoint from metal archives, which intern searches only
|
Searches the default endpoint from metal archives, which intern searches only
|
||||||
for bands, but it is the default, thus I am rolling with it
|
for bands, but it is the default, thus I am rolling with it
|
||||||
"""
|
"""
|
||||||
endpoint = "https://www.metal-archives.com/search/ajax-band-search/?field=name&query={query}&sEcho=1&iColumns=3&sColumns=&iDisplayStart=0&iDisplayLength=200&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2"
|
endpoint = "https://www.metal-archives.com/search/ajax-band-search/?field=name&query={query}&sEcho=1&iColumns=3&sColumns=&iDisplayStart=0&iDisplayLength=200&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2"
|
||||||
|
|
||||||
r = cls.CONNECTION.get(endpoint.format(query=query))
|
r = self.connection.get(endpoint.format(query=query))
|
||||||
if r is None:
|
if r is None:
|
||||||
return Options()
|
return []
|
||||||
|
|
||||||
return Options([
|
return [
|
||||||
cls.get_artist_from_json(artist_html=raw_artist[0], genre=raw_artist[1], country=raw_artist[2])
|
_artist_from_json(artist_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']
|
||||||
])
|
]
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user