aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-12-26 18:37:35 -0800
committerJames Taylor <user234683@users.noreply.github.com>2018-12-26 18:37:35 -0800
commit9a386145ff5db24eed5ca93977463e4885434104 (patch)
tree62f683341d12607b3c76bedf6503cca2f9c76be2 /youtube
parent90f19d2d5bfa767e55499c561950f2cafce66ecd (diff)
downloadyt-local-9a386145ff5db24eed5ca93977463e4885434104.tar.lz
yt-local-9a386145ff5db24eed5ca93977463e4885434104.tar.xz
yt-local-9a386145ff5db24eed5ca93977463e4885434104.zip
If specified, save account to disk after adding it
Diffstat (limited to 'youtube')
-rw-r--r--youtube/accounts.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/youtube/accounts.py b/youtube/accounts.py
index 312b711..e7d3ea5 100644
--- a/youtube/accounts.py
+++ b/youtube/accounts.py
@@ -23,12 +23,15 @@ def save_accounts():
def add_account(username, password, save):
cookiejar = http.cookiejar.LWPCookieJar()
- condition = _login(username, password, cookiejar)
- accounts[username] = {
- "save":save,
- "cookies":cookiejar.as_lwp_str(ignore_discard=False, ignore_expires=False),
- }
- return condition
+ successful = _login(username, password, cookiejar)
+ if successful:
+ accounts[username] = {
+ "save":save,
+ "cookies":cookiejar.as_lwp_str(ignore_discard=False, ignore_expires=False),
+ }
+ if save:
+ save_accounts()
+ return successful
def cookiejar_from_lwp_str(lwp_str):
cookiejar = http.cookiejar.LWPCookieJar()