diff options
author | James Taylor <user234683@users.noreply.github.com> | 2018-12-24 23:55:43 -0800 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2018-12-24 23:55:43 -0800 |
commit | 8f5edfe6f994e765a0207d7bbb5897de06a2ceb4 (patch) | |
tree | 2a40aae644c54af487daf37b065121ffded67ec4 /youtube/accounts.py | |
parent | dda06bd860b735b185efa45ba55cad8f52b650f7 (diff) | |
download | yt-local-8f5edfe6f994e765a0207d7bbb5897de06a2ceb4.tar.lz yt-local-8f5edfe6f994e765a0207d7bbb5897de06a2ceb4.tar.xz yt-local-8f5edfe6f994e765a0207d7bbb5897de06a2ceb4.zip |
Accounts: use dictionary based on username instead of list
Diffstat (limited to 'youtube/accounts.py')
-rw-r--r-- | youtube/accounts.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/youtube/accounts.py b/youtube/accounts.py index db33496..a8362b9 100644 --- a/youtube/accounts.py +++ b/youtube/accounts.py @@ -13,21 +13,20 @@ try: accounts = json.loads(f.read()) except FileNotFoundError: # global var for temporary storage of account info - accounts = [] + accounts = {} def save_accounts(): - to_save = list(account for account in accounts if account['save']) + to_save = {username: account for username, account in accounts.items() if account['save']} 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, + accounts[username] = { "save":save, "cookies":cookie_jar.as_lwp_str(ignore_discard=False, ignore_expires=False), - }) + } # --------------------------------- |