fixed DISGUSTING bug
This commit is contained in:
parent
1ae01ed1fd
commit
dc6a176c24
@ -14,7 +14,8 @@ from ..objects import (
|
||||
Lyrics,
|
||||
Target,
|
||||
MusicObject,
|
||||
Options
|
||||
Options,
|
||||
SourcePages
|
||||
)
|
||||
|
||||
|
||||
@ -29,6 +30,8 @@ class Page:
|
||||
TIMEOUT = 5
|
||||
TRIES = 5
|
||||
|
||||
SOURCE_TYPE: SourcePages
|
||||
|
||||
@classmethod
|
||||
def get_request(cls, url: str, accepted_response_codes: set = set((200,)), trie: int = 0) -> Optional[
|
||||
requests.Request]:
|
||||
@ -166,6 +169,10 @@ class Page:
|
||||
|
||||
raise NotImplementedError(f"MusicObject {type(music_object)} has not been implemented yet")
|
||||
|
||||
@classmethod
|
||||
def fetch_song_from_source(cls, source: Source, flat: bool = False) -> Song:
|
||||
return Song()
|
||||
|
||||
@classmethod
|
||||
def fetch_song_details(cls, song: Song, flat: bool = False) -> Song:
|
||||
"""
|
||||
@ -182,8 +189,17 @@ class Page:
|
||||
:return detailed_song: it modifies the input song
|
||||
"""
|
||||
|
||||
source: Source
|
||||
for source in song.source_collection.get_sources_from_page(cls.SOURCE_TYPE):
|
||||
new_song = cls.fetch_song_from_source(source, flat)
|
||||
song.merge(new_song)
|
||||
|
||||
return song
|
||||
|
||||
@classmethod
|
||||
def fetch_album_from_source(cls, source: Source, flat: bool = False) -> Album:
|
||||
return Album()
|
||||
|
||||
@classmethod
|
||||
def fetch_album_details(cls, album: Album, flat: bool = False) -> Album:
|
||||
"""
|
||||
@ -201,8 +217,17 @@ class Page:
|
||||
:return detailed_artist: it modifies the input artist
|
||||
"""
|
||||
|
||||
source: Source
|
||||
for source in album.source_collection.get_sources_from_page(cls.SOURCE_TYPE):
|
||||
new_album: Album = cls.fetch_album_from_source(source, flat)
|
||||
album.merge(new_album)
|
||||
|
||||
return album
|
||||
|
||||
@classmethod
|
||||
def fetch_artist_from_source(cls, source: Source, flat: bool = False) -> Artist:
|
||||
return Artist()
|
||||
|
||||
@classmethod
|
||||
def fetch_artist_details(cls, artist: Artist, flat: bool = False) -> Artist:
|
||||
"""
|
||||
@ -218,4 +243,9 @@ class Page:
|
||||
:return detailed_artist: it modifies the input artist
|
||||
"""
|
||||
|
||||
source: Source
|
||||
for source in artist.source_collection.get_sources_from_page(cls.SOURCE_TYPE):
|
||||
new_artist: Artist = cls.fetch_artist_from_source(source, flat)
|
||||
artist.merge(new_artist)
|
||||
|
||||
return artist
|
||||
|
@ -516,7 +516,7 @@ class Musify(Page):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_discography(cls, url: MusifyUrl) -> List[Album]:
|
||||
def get_discography(cls, url: MusifyUrl, flat=False) -> List[Album]:
|
||||
"""
|
||||
POST https://musify.club/artist/filteralbums
|
||||
ArtistID: 280348
|
||||
@ -539,7 +539,13 @@ class Musify(Page):
|
||||
|
||||
discography: List[Album] = []
|
||||
for card_soup in soup.find_all("div", {"class": "card"}):
|
||||
discography.append(cls.parse_album_card(card_soup))
|
||||
new_album: Album = cls.parse_album_card(card_soup)
|
||||
album_source: Source
|
||||
if not flat:
|
||||
for album_source in new_album.source_collection.get_sources_from_page(cls.SOURCE_TYPE):
|
||||
new_album.merge(cls.get_album_from_source(album_source))
|
||||
|
||||
discography.append(new_album)
|
||||
|
||||
return discography
|
||||
|
||||
@ -556,7 +562,7 @@ class Musify(Page):
|
||||
|
||||
r = cls.get_request(f"https://musify.club/{url.source_type.value}/{url.name_with_id}?_pjax=#bodyContent")
|
||||
if r is None:
|
||||
return Artist(_id=url.musify_id, name="")
|
||||
return Artist(_id=url.musify_id)
|
||||
|
||||
soup = BeautifulSoup(r.content, "html.parser")
|
||||
|
||||
@ -592,11 +598,11 @@ class Musify(Page):
|
||||
name = None
|
||||
source_list: List[Source] = []
|
||||
country = None
|
||||
notes: FormattedText = None
|
||||
notes: FormattedText = FormattedText()
|
||||
|
||||
breadcrumbs: BeautifulSoup = soup.find("ol", {"class": "breadcrumb"})
|
||||
if breadcrumbs is not None:
|
||||
breadcrumb_list: List[BeautifulSoup] = breadcrumbs.find_all("li", {"class": "breadcrumb"}, recursive=False)
|
||||
breadcrumb_list: List[BeautifulSoup] = breadcrumbs.find_all("li", {"class": "breadcrumb-item"}, recursive=False)
|
||||
if len(breadcrumb_list) == 3:
|
||||
name = breadcrumb_list[-1].get_text(strip=True)
|
||||
else:
|
||||
@ -624,7 +630,7 @@ class Musify(Page):
|
||||
|
||||
content_title: BeautifulSoup = soup.find("header", {"class": "content__title"})
|
||||
if content_title is not None:
|
||||
h1_name: BeautifulSoup = soup.find("h1", recursive=False)
|
||||
h1_name: BeautifulSoup = content_title.find("h1", recursive=False)
|
||||
if h1_name is not None:
|
||||
name = h1_name.get_text(strip=True)
|
||||
|
||||
@ -663,7 +669,7 @@ class Musify(Page):
|
||||
|
||||
note_soup: BeautifulSoup = soup.find(id="text-main")
|
||||
if note_soup is not None:
|
||||
notes = FormattedText(html=note_soup.decode_contents())
|
||||
notes.html = note_soup.decode_contents()
|
||||
|
||||
return Artist(
|
||||
_id=url.musify_id,
|
||||
@ -674,7 +680,7 @@ class Musify(Page):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_artist_from_source(cls, source: Source, flat: bool = False) -> Artist:
|
||||
def fetch_artist_from_source(cls, source: Source, flat: bool = False) -> Artist:
|
||||
"""
|
||||
fetches artist from source
|
||||
|
||||
@ -700,30 +706,5 @@ class Musify(Page):
|
||||
return artist
|
||||
|
||||
@classmethod
|
||||
def fetch_artist_details(cls, artist: Artist, flat: bool = False) -> Artist:
|
||||
source_list = artist.source_collection.get_sources_from_page(cls.SOURCE_TYPE)
|
||||
if len(source_list) == 0:
|
||||
return artist
|
||||
|
||||
for source in source_list:
|
||||
artist.merge(cls.get_artist_from_source(source, flat=flat))
|
||||
|
||||
return artist
|
||||
|
||||
@classmethod
|
||||
def fetch_album_details(cls, album: Album, flat: bool = False) -> Album:
|
||||
|
||||
return album
|
||||
|
||||
@classmethod
|
||||
def fetch_song_details(cls, song: Song, flat: bool = False) -> Song:
|
||||
source_list = song.source_collection.get_sources_from_page(cls.SOURCE_TYPE)
|
||||
if len(source_list) == 0:
|
||||
return song
|
||||
|
||||
"""
|
||||
TODO
|
||||
lyrics
|
||||
"""
|
||||
|
||||
return song
|
||||
def get_album_from_source(cls, source: Source, flat: bool = False) -> Album:
|
||||
return Album()
|
||||
|
Loading…
Reference in New Issue
Block a user