aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/accounts.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2019-07-23 23:53:04 -0700
committerJames Taylor <user234683@users.noreply.github.com>2019-07-23 23:57:45 -0700
commite00c3cf99f06e6f0c097e019219760cf26d16cbe (patch)
tree3d722ffaf11760d811e8d4f26106d045d0c63126 /youtube/accounts.py
parentcb1c899a4570e8644dad572c7f00a3d96c844a2f (diff)
downloadyt-local-e00c3cf99f06e6f0c097e019219760cf26d16cbe.tar.lz
yt-local-e00c3cf99f06e6f0c097e019219760cf26d16cbe.tar.xz
yt-local-e00c3cf99f06e6f0c097e019219760cf26d16cbe.zip
Remove ad-hoc response saving from code, create a debug setting for fetch_url
Diffstat (limited to 'youtube/accounts.py')
-rw-r--r--youtube/accounts.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/youtube/accounts.py b/youtube/accounts.py
index c35b6cc..d2e8a41 100644
--- a/youtube/accounts.py
+++ b/youtube/accounts.py
@@ -162,10 +162,8 @@ def _login(username, password, cookiejar, use_tor):
Taken from youtube-dl
"""
- login_page = util.fetch_url(_LOGIN_URL, yt_dl_headers, report_text='Downloaded login page', cookiejar_receive=cookiejar, use_tor=use_tor).decode('utf-8')
- '''with open('debug/login_page', 'w', encoding='utf-8') as f:
- f.write(login_page)'''
- #print(cookiejar.as_lwp_str())
+ login_page = util.fetch_url(_LOGIN_URL, yt_dl_headers, report_text='Downloaded login page', cookiejar_receive=cookiejar, use_tor=use_tor, debug_name='login_page').decode('utf-8')
+
if login_page is False:
return
@@ -189,10 +187,7 @@ def _login(username, password, cookiejar, use_tor):
'Google-Accounts-XSRF': 1,
}
headers.update(yt_dl_headers)
- result = util.fetch_url(url, headers, report_text=note, data=data, cookiejar_send=cookiejar, cookiejar_receive=cookiejar, use_tor=use_tor).decode('utf-8')
- #print(cookiejar.as_lwp_str())
- '''with open('debug/' + note, 'w', encoding='utf-8') as f:
- f.write(result)'''
+ result = util.fetch_url(url, headers, report_text=note, data=data, cookiejar_send=cookiejar, cookiejar_receive=cookiejar, use_tor=use_tor, debug_name=note).decode('utf-8')
result = re.sub(r'^[^\[]*', '', result)
return json.loads(result)
@@ -321,12 +316,10 @@ def _login(username, password, cookiejar, use_tor):
return False
try:
- check_cookie_results = util.fetch_url(check_cookie_url, headers=yt_dl_headers, report_text="Checked cookie", cookiejar_send=cookiejar, cookiejar_receive=cookiejar, use_tor=use_tor).decode('utf-8')
+ check_cookie_results = util.fetch_url(check_cookie_url, headers=yt_dl_headers, report_text="Checked cookie", cookiejar_send=cookiejar, cookiejar_receive=cookiejar, use_tor=use_tor, debug_name='check_cookie_results').decode('utf-8')
except (urllib.error.URLError, compat_http_client.HTTPException, socket.error) as err:
return False
- '''with open('debug/check_cookie_results', 'w', encoding='utf-8') as f:
- f.write(check_cookie_results)'''
if 'https://myaccount.google.com/' not in check_cookie_results:
warn('Unable to log in')