Package: youtube-community-tab
youtube_community_tabPython3 interface to YouTube community tab, it handles posts, comments and comment replies.Community Tabfromyoutube_community_tab.community_tabimportCommunityTabimportjsondefindent_print(text,level=1):indent=level*"\t"print(indent+("\n"+indent).join(text.split("\n")))# Cache expirationEXPIRATION_TIME=1*60*60ct=CommunityTab("vsauce1")# Load initial postsct.load_posts(expire_after=EXPIRATION_TIME)# Load more postswhile(ct.posts_continuation_tokenandlen(ct.posts)<40):ct.load_posts(expire_after=EXPIRATION_TIME)post=ct.posts[0]print(f"[Post{post.post_id}]")indent_print(post.get_text())print("\n[Thumbnails]")print(json.dumps(post.get_thumbnails()[0],indent=4))# Load initial commentspost.load_comments(expire_after=EXPIRATION_TIME)# Load more commentswhile(post.comments_continuation_tokenandlen(post.comments)<100):post.load_comments(expire_after=EXPIRATION_TIME)comment=post.comments[1]print(f"\n[Comment{comment.comment_id}]")indent_print(comment.get_text())# Load initial comment repliescomment.load_replies(expire_after=EXPIRATION_TIME)# Load more comment replieswhile(comment.replies_continuation_tokenandlen(comment.replies)<10):comment.load_replies(expire_after=EXPIRATION_TIME)reply=comment.replies[0]print(f"\n[Reply{reply.reply_id}]")indent_print(reply.get_text())Output:[Post UgkxzeM19x_He9LEoerdLOHwZJsqIwamUnTj]
        THANK YOU!

        WE RAISED $20,180 for the Alzheimer's Association!!!
        The winner of this beautiful cube of my beard hairs will be announced November 15th!!

        As you all know, we also donate a portion of all proceeds from the Curiosity Box to Alzheimer's research; and there's never been a better time to do a favor for your brain and everyone else's:

        RIGHT NOW: subscribe with code "BEST" and I'll send you our newest box *and* throw in our BEST-OF BOX completely FREE!!!


        https://www.curiositybox.com

[Thumbnails]
[
    {
        "url": "https://yt3.ggpht.com/DJhBHUy1SyM2XpjC1ObZyrt8llJ-qG6svLapmaZgU-wmo5rVnWR93kJMrtz85XI9EKSt395Cvziu-JE=s288-c-fcrop64=1,1e6d0000e38bffff-nd-v1",
        "width": 288,
        "height": 288
    },
    {
        "url": "https://yt3.ggpht.com/DJhBHUy1SyM2XpjC1ObZyrt8llJ-qG6svLapmaZgU-wmo5rVnWR93kJMrtz85XI9EKSt395Cvziu-JE=s400-c-fcrop64=1,1e6d0000e38bffff-nd-v1",
        "width": 400,
        "height": 400
    },
    {
        "url": "https://yt3.ggpht.com/DJhBHUy1SyM2XpjC1ObZyrt8llJ-qG6svLapmaZgU-wmo5rVnWR93kJMrtz85XI9EKSt395Cvziu-JE=s462-c-fcrop64=1,1e6d0000e38bffff-nd-v1",
        "width": 462,
        "height": 462
    }
]

[Comment UgyTIomDXMuKf3NTo294AaABAg]
        Thank you for doing this. Both my grandparents are affected by alzheimer's disease. It is difficult to watch a highly creative woman and an electrical engineer fade away.

[Reply UgyTIomDXMuKf3NTo294AaABAg.9TtQ3j7qvll9TtqSmVNrJu]
        Hey a heartPostfromyoutube_community_tab.postimportPostimportjsondefindent_print(text,level=1):indent=level*"\t"print(indent+("\n"+indent).join(text.split("\n")))# Cache expirationEXPIRATION_TIME=1*60*60post=Post.from_post_id("UgkxzeM19x_He9LEoerdLOHwZJsqIwamUnTj")print(f"[Post{post.post_id}]")indent_print(post.get_text())print("\n[Thumbnails]")print(json.dumps(post.get_thumbnails()[0],indent=4))# Load initial commentspost.load_comments(expire_after=EXPIRATION_TIME)# Load more commentswhile(post.comments_continuation_tokenandlen(post.comments)<100):post.load_comments(expire_after=EXPIRATION_TIME)comment=post.comments[1]print(f"\n[Comment{comment.comment_id}]")indent_print(comment.get_text())# Load initial comment repliescomment.load_replies(expire_after=EXPIRATION_TIME)# Load more comment replieswhile(comment.replies_continuation_tokenandlen(comment.replies)<10):comment.load_replies(expire_after=EXPIRATION_TIME)reply=comment.replies[0]print(f"\n[Reply{reply.reply_id}]")indent_print(reply.get_text())Output:[Post UgkxzeM19x_He9LEoerdLOHwZJsqIwamUnTj]
        THANK YOU!

        WE RAISED $20,180 for the Alzheimer's Association!!!
        The winner of this beautiful cube of my beard hairs will be announced November 15th!!

        As you all know, we also donate a portion of all proceeds from the Curiosity Box to Alzheimer's research; and there's never been a better time to do a favor for your brain and everyone else's:

        RIGHT NOW: subscribe with code "BEST" and I'll send you our newest box *and* throw in our BEST-OF BOX completely FREE!!!


        https://www.curiositybox.com

[Thumbnails]
[
    {
        "url": "https://yt3.ggpht.com/DJhBHUy1SyM2XpjC1ObZyrt8llJ-qG6svLapmaZgU-wmo5rVnWR93kJMrtz85XI9EKSt395Cvziu-JE=s288-c-fcrop64=1,1e6d0000e38bffff-nd-v1",
        "width": 288,
        "height": 288
    },
    {
        "url": "https://yt3.ggpht.com/DJhBHUy1SyM2XpjC1ObZyrt8llJ-qG6svLapmaZgU-wmo5rVnWR93kJMrtz85XI9EKSt395Cvziu-JE=s400-c-fcrop64=1,1e6d0000e38bffff-nd-v1",
        "width": 400,
        "height": 400
    },
    {
        "url": "https://yt3.ggpht.com/DJhBHUy1SyM2XpjC1ObZyrt8llJ-qG6svLapmaZgU-wmo5rVnWR93kJMrtz85XI9EKSt395Cvziu-JE=s462-c-fcrop64=1,1e6d0000e38bffff-nd-v1",
        "width": 462,
        "height": 462
    }
]

[Comment UgyTIomDXMuKf3NTo294AaABAg]
        Thank you for doing this. Both my grandparents are affected by alzheimer's disease. It is difficult to watch a highly creative woman and an electrical engineer fade away.

[Reply UgyTIomDXMuKf3NTo294AaABAg.9TtQ3j7qvll9TtqSmVNrJu]
        Hey a heartAuthentication/MembershipTo access authenticated posts, like membership only posts, you need to provide cookies to authenticate your requests.fromhttpimportcookiejarfromyoutube_community_tab.requests_handlerimportrequests_cachefromyoutube_community_tab.community_tabimportCommunityTabcookie_jar=cookiejar.MozillaCookieJar("cookies.txt")cookie_jar.load()requests_cache.cookies=cookie_jarct=CommunityTab("UCMwGHR0BTZuLsmjY_NT5Pwg")ct.load_posts()membership_post=Nonewhilect.posts_continuation_token:forpostinct.posts:ifpost.sponsor_only_badgeisnotNone:membership_post=postbreakif(membership_postisnotNone):breakct.load_posts(expire_after=EXPIRATION_TIME)assert(membership_postisnotNone)