post_comment: receive cookies given during session token retrieval (fixes 400 bad request when comment is posted)

This commit is contained in:
James Taylor 2018-12-26 20:16:14 -08:00
parent a5286e57cc
commit a9c1e804ed

View File

@ -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", "=")