From a9c1e804ed936f34e551333f62e165cf2e20b50c Mon Sep 17 00:00:00 2001 From: James Taylor Date: Wed, 26 Dec 2018 20:16:14 -0800 Subject: post_comment: receive cookies given during session token retrieval (fixes 400 bad request when comment is posted) --- youtube/post_comment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube/post_comment.py b/youtube/post_comment.py index 57e9e2e..baa2ff9 100644 --- a/youtube/post_comment.py +++ b/youtube/post_comment.py @@ -108,7 +108,7 @@ def post_comment(parameters, fields): # Tokens retrieved from disable_polymer pages only work with that format. Tokens retrieved on mobile only work using mobile requests # Additionally, tokens retrieved without sending the same cookie won't work. So this is necessary even if the bgr and stuff was reverse engineered. headers = {'User-Agent': common.mobile_user_agent} - mobile_page = common.fetch_url('https://m.youtube.com/watch?v=' + video_id, headers, report_text="Retrieved session token for comment", cookiejar_send=cookiejar).decode() + mobile_page = common.fetch_url('https://m.youtube.com/watch?v=' + video_id, headers, report_text="Retrieved session token for comment", cookiejar_send=cookiejar, cookiejar_receive=cookiejar).decode() match = xsrf_token_regex.search(mobile_page) if match: token = match.group(1).replace("%3D", "=") -- cgit v1.2.3