fixed the download directory

This commit is contained in:
Hellow2 2023-04-03 11:47:30 +02:00
parent c501461b1e
commit 45b5f0875a
2 changed files with 17 additions and 3 deletions

View File

@ -85,7 +85,7 @@ class Page:
LOGGER.warning("to many tries. Aborting.") LOGGER.warning("to many tries. Aborting.")
return None return None
return cls.get_request(url, accepted_response_codes, trie + 1) return cls.get_request(url=url, stream=stream, accepted_response_codes=accepted_response_codes, trie=trie + 1)
@classmethod @classmethod
def post_request(cls, url: str, json: dict, accepted_response_codes: set = set((200,)), trie: int = 0) -> Optional[ def post_request(cls, url: str, json: dict, accepted_response_codes: set = set((200,)), trie: int = 0) -> Optional[
@ -109,7 +109,7 @@ class Page:
LOGGER.warning("to many tries. Aborting.") LOGGER.warning("to many tries. Aborting.")
return None return None
return cls.post_request(url, json, accepted_response_codes, trie + 1) return cls.post_request(url=url, json=json, accepted_response_codes=accepted_response_codes, trie=trie + 1)
@classmethod @classmethod
def get_soup_from_response(cls, r: requests.Response) -> BeautifulSoup: def get_soup_from_response(cls, r: requests.Response) -> BeautifulSoup:
@ -351,6 +351,8 @@ class Page:
else: else:
default_target = copy(default_target) default_target = copy(default_target)
default_target.artist = artist.name default_target.artist = artist.name
if not artist.label_collection.empty:
default_target.label = artist.label_collection[0].name
cls.fetch_details(artist) cls.fetch_details(artist)
for album in artist.main_album_collection: for album in artist.main_album_collection:
@ -367,6 +369,10 @@ class Page:
else: else:
default_target = copy(default_target) default_target = copy(default_target)
default_target.album = album.title default_target.album = album.title
if not album.artist_collection.empty:
default_target.artist = album.artist_collection[0].name
if not album.label_collection.empty:
default_target.label = album.label_collection[0].name
cls.fetch_details(album) cls.fetch_details(album)
for song in album.song_collection: for song in album.song_collection:
@ -379,6 +385,14 @@ class Page:
else: else:
default_target = copy(default_target) default_target = copy(default_target)
default_target.song = song.title default_target.song = song.title
if not song.album_collection.empty:
default_target.album = song.album_collection[0].title
if not song.main_artist_collection.empty:
artist: Artist = song.main_artist_collection[0]
default_target.artist = artist.name
if not artist.label_collection.empty:
default_target.label = artist.label_collection[0].name
cls.fetch_details(song) cls.fetch_details(song)

View File

@ -101,7 +101,7 @@ class Search(Download):
db_object, page = self._current_option.choose_from_all_pages(index=index) db_object, page = self._current_option.choose_from_all_pages(index=index)
music_object = self.fetch_details(db_object) music_object = self.fetch_details(db_object)
mpo = self.next_options_from_music_obj(music_object, page) mpo = self.next_options(derive_from=music_object)
mpo[page] = music_object.options mpo[page] = music_object.options