add_account function

This commit is contained in:
James Taylor 2018-12-24 23:50:39 -08:00
parent 3d1a1189e7
commit dda06bd860

View File

@ -20,6 +20,16 @@ def save_accounts():
with open(os.path.join(settings.data_dir, 'accounts.txt'), 'w', encoding='utf-8') as f:
f.write(json.dumps(to_save))
def add_account(username, password, save):
cookie_jar = http.cookiejar.LWPCookieJar()
_login(username, password, cookie_jar)
accounts.append({
"username": username,
"save":save,
"cookies":cookie_jar.as_lwp_str(ignore_discard=False, ignore_expires=False),
})
# ---------------------------------
# Code ported from youtube-dl
# ---------------------------------