cleant up messages
This commit is contained in:
parent
406dc3d1e2
commit
eef2e74c1b
@ -214,12 +214,15 @@ class Downloader:
|
||||
artist = None if not "a" in key_text else Artist(name=key_text["a"], dynamic=True)
|
||||
|
||||
if song is not None:
|
||||
song.album_collection.append(album)
|
||||
song.main_artist_collection.append(artist)
|
||||
if album is not None:
|
||||
song.album_collection.append(album)
|
||||
if artist is not None:
|
||||
song.main_artist_collection.append(artist)
|
||||
return Query(raw_query=query, music_object=song)
|
||||
|
||||
if album is not None:
|
||||
album.artist_collection.append(artist)
|
||||
if artist is not None:
|
||||
album.artist_collection.append(artist)
|
||||
return Query(raw_query=query, music_object=album)
|
||||
|
||||
if artist is not None:
|
||||
|
@ -76,7 +76,7 @@ class Connection:
|
||||
def _hearthbeat_loop(self, interval: float):
|
||||
def hearthbeat_wrapper():
|
||||
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.LOGGER.debug(f"finished the hearthbeat")
|
||||
self.session_is_occupied = False
|
||||
|
@ -79,6 +79,8 @@ RENDERER_PARSERS = {
|
||||
"musicResponsiveListItemRenderer": music_responsive_list_item_renderer,
|
||||
"musicResponsiveListItemFlexColumnRenderer": music_responsive_list_item_flex_column_renderer,
|
||||
"musicShelfRenderer": music_card_shelf_renderer,
|
||||
|
||||
"itemSectionRenderer": lambda _: [],
|
||||
}
|
||||
|
||||
def parse_renderer(renderer: dict) -> List[DatabaseObject]:
|
||||
|
@ -25,6 +25,7 @@ class PageType(Enum):
|
||||
PLAYLIST = "MUSIC_PAGE_TYPE_PLAYLIST"
|
||||
SONG = "MUSIC_VIDEO_TYPE_ATV"
|
||||
VIDEO = "MUSIC_VIDEO_TYPE_UGC"
|
||||
OFFICIAL_MUSIC_VIDEO = "MUSIC_VIDEO_TYPE_OMV"
|
||||
|
||||
|
||||
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.")
|
||||
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}")
|
||||
return Song(title=element_text, source_list=[source])
|
||||
|
||||
|
@ -223,8 +223,6 @@ class YoutubeMusic(Page):
|
||||
|
||||
def general_search(self, search_query: str) -> List[DatabaseObject]:
|
||||
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(" ", "+"))
|
||||
|
||||
@ -259,7 +257,6 @@ class YoutubeMusic(Page):
|
||||
)
|
||||
|
||||
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", [])
|
||||
|
||||
@ -270,7 +267,6 @@ class YoutubeMusic(Page):
|
||||
results = []
|
||||
|
||||
"""
|
||||
TODO
|
||||
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.
|
||||
"""
|
||||
@ -278,13 +274,6 @@ class YoutubeMusic(Page):
|
||||
for renderer in renderer_list:
|
||||
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
|
||||
|
||||
def label_search(self, label: Label) -> List[Label]:
|
||||
|
Loading…
Reference in New Issue
Block a user