cleant up messages

This commit is contained in:
Hellow 2023-07-28 09:24:14 +02:00
parent 406dc3d1e2
commit eef2e74c1b
5 changed files with 11 additions and 16 deletions

View File

@ -214,11 +214,14 @@ class Downloader:
artist = None if not "a" in key_text else Artist(name=key_text["a"], dynamic=True) artist = None if not "a" in key_text else Artist(name=key_text["a"], dynamic=True)
if song is not None: if song is not None:
if album is not None:
song.album_collection.append(album) song.album_collection.append(album)
if artist is not None:
song.main_artist_collection.append(artist) song.main_artist_collection.append(artist)
return Query(raw_query=query, music_object=song) return Query(raw_query=query, music_object=song)
if album is not None: if album is not None:
if artist is not None:
album.artist_collection.append(artist) album.artist_collection.append(artist)
return Query(raw_query=query, music_object=album) return Query(raw_query=query, music_object=album)

View File

@ -76,7 +76,7 @@ class Connection:
def _hearthbeat_loop(self, interval: float): def _hearthbeat_loop(self, interval: float):
def hearthbeat_wrapper(): def hearthbeat_wrapper():
self.session_is_occupied = True self.session_is_occupied = True
self.LOGGER.info(f"I am living. (sending a hearthbeat)") self.LOGGER.debug(f"I am living. (sending a hearthbeat)")
self.hearthbeat() self.hearthbeat()
self.LOGGER.debug(f"finished the hearthbeat") self.LOGGER.debug(f"finished the hearthbeat")
self.session_is_occupied = False self.session_is_occupied = False

View File

@ -79,6 +79,8 @@ RENDERER_PARSERS = {
"musicResponsiveListItemRenderer": music_responsive_list_item_renderer, "musicResponsiveListItemRenderer": music_responsive_list_item_renderer,
"musicResponsiveListItemFlexColumnRenderer": music_responsive_list_item_flex_column_renderer, "musicResponsiveListItemFlexColumnRenderer": music_responsive_list_item_flex_column_renderer,
"musicShelfRenderer": music_card_shelf_renderer, "musicShelfRenderer": music_card_shelf_renderer,
"itemSectionRenderer": lambda _: [],
} }
def parse_renderer(renderer: dict) -> List[DatabaseObject]: def parse_renderer(renderer: dict) -> List[DatabaseObject]:

View File

@ -25,6 +25,7 @@ class PageType(Enum):
PLAYLIST = "MUSIC_PAGE_TYPE_PLAYLIST" PLAYLIST = "MUSIC_PAGE_TYPE_PLAYLIST"
SONG = "MUSIC_VIDEO_TYPE_ATV" SONG = "MUSIC_VIDEO_TYPE_ATV"
VIDEO = "MUSIC_VIDEO_TYPE_UGC" VIDEO = "MUSIC_VIDEO_TYPE_UGC"
OFFICIAL_MUSIC_VIDEO = "MUSIC_VIDEO_TYPE_OMV"
def parse_run_element(run_element: dict) -> Optional[DatabaseObject]: def parse_run_element(run_element: dict) -> Optional[DatabaseObject]:
@ -49,7 +50,7 @@ def parse_run_element(run_element: dict) -> Optional[DatabaseObject]:
LOGGER.warning("Couldn't find either the id or text of a Youtube music element.") LOGGER.warning("Couldn't find either the id or text of a Youtube music element.")
return return
if element_type == PageType.SONG or (element_type == PageType.VIDEO and not YOUTUBE_MUSIC_CLEAN_DATA): if element_type == PageType.SONG or (element_type == PageType.VIDEO and not YOUTUBE_MUSIC_CLEAN_DATA) or (element_type == PageType.OFFICIAL_MUSIC_VIDEO and not YOUTUBE_MUSIC_CLEAN_DATA):
source = Source(SOURCE_PAGE, f"https://music.youtube.com/watch?v={element_id}") source = Source(SOURCE_PAGE, f"https://music.youtube.com/watch?v={element_id}")
return Song(title=element_text, source_list=[source]) return Song(title=element_text, source_list=[source])

View File

@ -223,8 +223,6 @@ class YoutubeMusic(Page):
def general_search(self, search_query: str) -> List[DatabaseObject]: def general_search(self, search_query: str) -> List[DatabaseObject]:
search_query = search_query.strip() search_query = search_query.strip()
self.LOGGER.info(f"general search for {search_query}")
print(self.credentials)
urlescaped_query: str = quote(search_query.strip().replace(" ", "+")) urlescaped_query: str = quote(search_query.strip().replace(" ", "+"))
@ -259,7 +257,6 @@ class YoutubeMusic(Page):
) )
self.LOGGER.debug(str(r)) self.LOGGER.debug(str(r))
# dump_to_file(f"{search_query}.json", r.content, is_json=True)
renderer_list = r.json().get("contents", {}).get("tabbedSearchResultsRenderer", {}).get("tabs", [{}])[0].get("tabRenderer").get("content", {}).get("sectionListRenderer", {}).get("contents", []) renderer_list = r.json().get("contents", {}).get("tabbedSearchResultsRenderer", {}).get("tabs", [{}])[0].get("tabRenderer").get("content", {}).get("sectionListRenderer", {}).get("contents", [])
@ -270,7 +267,6 @@ class YoutubeMusic(Page):
results = [] results = []
""" """
TODO
cant use fixed indices, because if something has no entries, the list dissappears cant use fixed indices, because if something has no entries, the list dissappears
instead I have to try parse everything, and just reject community playlists and profiles. instead I have to try parse everything, and just reject community playlists and profiles.
""" """
@ -278,13 +274,6 @@ class YoutubeMusic(Page):
for renderer in renderer_list: for renderer in renderer_list:
results.extend(parse_renderer(renderer)) results.extend(parse_renderer(renderer))
"""
results.extend(parse_renderer(renderer_list[1]))
results.extend(parse_renderer(renderer_list[2]))
results.extend(parse_renderer(renderer_list[4]))
results.extend(parse_renderer(renderer_list[6]))
"""
return results return results
def label_search(self, label: Label) -> List[Label]: def label_search(self, label: Label) -> List[Label]: