layed out the complete fetching of album
This commit is contained in:
parent
96f2d7ef6e
commit
f39c3c11ad
File diff suppressed because one or more lines are too long
@ -60,6 +60,7 @@ X-Requested-With: XMLHttpRequest
|
|||||||
|
|
||||||
class MusifyTypes(Enum):
|
class MusifyTypes(Enum):
|
||||||
ARTIST = "artist"
|
ARTIST = "artist"
|
||||||
|
RELEASE = "release"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -85,6 +86,30 @@ class Musify(Page):
|
|||||||
|
|
||||||
SOURCE_TYPE = SourcePages.MUSIFY
|
SOURCE_TYPE = SourcePages.MUSIFY
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_url(cls, url: str) -> MusifyUrl:
|
||||||
|
parsed = urlparse(url)
|
||||||
|
|
||||||
|
path = parsed.path.split("/")
|
||||||
|
|
||||||
|
split_name = path[2].split("-")
|
||||||
|
url_id = split_name[-1]
|
||||||
|
name_for_url = "-".join(split_name[:-1])
|
||||||
|
|
||||||
|
try:
|
||||||
|
type_enum = MusifyTypes(path[1])
|
||||||
|
except ValueError as e:
|
||||||
|
print(f"{path[1]} is not yet implemented, add it to MusifyTypes")
|
||||||
|
raise e
|
||||||
|
|
||||||
|
return MusifyUrl(
|
||||||
|
source_type=type_enum,
|
||||||
|
name_without_id=name_for_url,
|
||||||
|
name_with_id=path[2],
|
||||||
|
musify_id=url_id,
|
||||||
|
url=url
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def search_by_query(cls, query: str) -> Options:
|
def search_by_query(cls, query: str) -> Options:
|
||||||
query_obj = cls.Query(query)
|
query_obj = cls.Query(query)
|
||||||
@ -358,24 +383,6 @@ class Musify(Page):
|
|||||||
|
|
||||||
return Options(search_results)
|
return Options(search_results)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def parse_url(cls, url: str) -> MusifyUrl:
|
|
||||||
parsed = urlparse(url)
|
|
||||||
|
|
||||||
path = parsed.path.split("/")
|
|
||||||
|
|
||||||
split_name = path[2].split("-")
|
|
||||||
url_id = split_name[-1]
|
|
||||||
name_for_url = "-".join(split_name[:-1])
|
|
||||||
|
|
||||||
return MusifyUrl(
|
|
||||||
source_type=MusifyTypes(path[1]),
|
|
||||||
name_without_id=name_for_url,
|
|
||||||
name_with_id=path[2],
|
|
||||||
musify_id=url_id,
|
|
||||||
url=url
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_album_card(cls, album_card: BeautifulSoup, artist_name: str = None) -> Album:
|
def parse_album_card(cls, album_card: BeautifulSoup, artist_name: str = None) -> Album:
|
||||||
"""
|
"""
|
||||||
@ -706,7 +713,7 @@ class Musify(Page):
|
|||||||
fetches artist from source
|
fetches artist from source
|
||||||
|
|
||||||
[x] discography
|
[x] discography
|
||||||
[x] attributes *(name and country... wooooow and I waste one request for this)*
|
[x] attributes
|
||||||
[] picture gallery
|
[] picture gallery
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -728,14 +735,27 @@ class Musify(Page):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fetch_album_from_source(cls, source: Source, flat: bool = False) -> Album:
|
def fetch_album_from_source(cls, source: Source, flat: bool = False) -> Album:
|
||||||
"""_summary_
|
|
||||||
|
|
||||||
Args:
|
|
||||||
source (Source): _description_
|
|
||||||
flat (bool, optional): _description_. Defaults to False.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Album: _description_
|
|
||||||
"""
|
"""
|
||||||
|
fetches album from source:
|
||||||
|
eg. 'https://musify.club/release/linkin-park-hybrid-theory-2000-188'
|
||||||
|
|
||||||
|
/html/musify/album_overview.html
|
||||||
|
[] tracklist
|
||||||
|
[] attributes *(name and country... wooooow and I waste one request for this)*
|
||||||
|
[] ratings
|
||||||
|
|
||||||
|
:param source:
|
||||||
|
:param flat:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
url = cls.parse_url(source.url)
|
||||||
|
|
||||||
|
endpoint = cls.HOST + "/release/" + url.name_with_id
|
||||||
|
r = cls.get_request(endpoint)
|
||||||
|
if r is None:
|
||||||
|
return Album()
|
||||||
|
|
||||||
|
soup = BeautifulSoup(r.content, "html.parser")
|
||||||
|
|
||||||
|
|
||||||
return Album(title="works")
|
return Album(title="works")
|
||||||
|
@ -15,9 +15,11 @@ def fetch_artist():
|
|||||||
artist = Musify.fetch_details(artist)
|
artist = Musify.fetch_details(artist)
|
||||||
print(artist.options)
|
print(artist.options)
|
||||||
|
|
||||||
|
|
||||||
def fetch_album():
|
def fetch_album():
|
||||||
album = objects.Album(
|
album = objects.Album(
|
||||||
source_list=[objects.Source(objects.SourcePages.MUSIFY, "https://musify.club/release/linkin-park-hybrid-theory-2000-188")]
|
source_list=[objects.Source(objects.SourcePages.MUSIFY,
|
||||||
|
"https://musify.club/release/linkin-park-hybrid-theory-2000-188")]
|
||||||
)
|
)
|
||||||
|
|
||||||
album = Musify.fetch_details(album)
|
album = Musify.fetch_details(album)
|
||||||
|
Loading…
Reference in New Issue
Block a user