diff --git a/ythdd_extractor.py b/ythdd_extractor.py index 2508a42..10184f9 100644 --- a/ythdd_extractor.py +++ b/ythdd_extractor.py @@ -543,7 +543,7 @@ def WEBextractPlaylist(plid: str = "", ctoken: str = ""): metadata = None if not ctoken: metadata = { - "header": safeTraverse(resp_json, ["header"]), + "microformat": safeTraverse(resp_json, ["microformat"]), "sidebar": safeTraverse(resp_json, ["sidebar"]) } diff --git a/ythdd_inv_tl.py b/ythdd_inv_tl.py index 6c10ccc..21e45ab 100644 --- a/ythdd_inv_tl.py +++ b/ythdd_inv_tl.py @@ -938,7 +938,14 @@ def playlists(data, req, only_json: bool = False): author = safeTraverse(secondary_sidebar, ["videoOwner", "videoOwnerRenderer", "title", "runs", 0, "text"], default="Unknown channel") author_ucid = safeTraverse(secondary_sidebar, ["videoOwner", "videoOwnerRenderer", "title", "runs", 0, "navigationEndpoint", "browseEndpoint", "browseId"], default="UNKNOWNCHANNELID") author_avatars = ythdd_extractor.generateChannelAvatarsFromUrl(safeTraverse(secondary_sidebar, ["videoOwner", "videoOwnerRenderer", "thumbnail", "thumbnails", 0, "url"], default=DEFAULT_AVATAR)) - description = safeTraverse(meta, ["header", "pageHeaderRenderer", "content", "pageHeaderViewModel", "description", "descriptionPreviewViewModel", "description", "content"], default="(ythdd: failed to retrieve description, perhaps it's empty?)") + description = safeTraverse(meta, ["microformat", "microformatDataRenderer", "description"], default="(ythdd: failed to retrieve description, perhaps it's empty?)") + if author_ucid == "UNKNOWNCHANNELID" and author == "Unknown channel": + # most likely a collaborative playlist + author = safeTraverse(secondary_sidebar, ["videoOwner", "videoOwnerRenderer", "title", "simpleText"], default="by Unknown user and others").removeprefix("by ") + author_orig = author[:author.rfind(" and ")] + description += f"\n(ythdd: This is a collaborative playlist by \"{author_orig}\" {author.removeprefix(author_orig + ' ')}. You can't view the authors' channels.)" + author = author_orig + description_html = html.escape(description).replace("\r\n", "
").replace("\n", "
") video_count = ythdd_struct_parser.parseViewsFromViewText(ythdd_struct_parser.extractTextFromSimpleOrRuns(safeTraverse(primary_sidebar, ["stats", 0]), default="No videos")) view_count = ythdd_struct_parser.parseViewsFromViewText(ythdd_struct_parser.extractTextFromSimpleOrRuns(safeTraverse(primary_sidebar, ["stats", 1]), default="No views"))