From dfbd7778d10c15cf2e12e9007beba5458a3f3ab1 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Wed, 26 Dec 2018 18:45:50 -0800 Subject: Make accounts.txt more human-readable --- youtube/accounts.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'youtube') diff --git a/youtube/accounts.py b/youtube/accounts.py index e7d3ea5..bc0e017 100644 --- a/youtube/accounts.py +++ b/youtube/accounts.py @@ -19,7 +19,7 @@ except FileNotFoundError: def save_accounts(): 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)) + f.write(json.dumps(to_save, indent=4)) def add_account(username, password, save): cookiejar = http.cookiejar.LWPCookieJar() @@ -27,7 +27,7 @@ def add_account(username, password, save): if successful: accounts[username] = { "save":save, - "cookies":cookiejar.as_lwp_str(ignore_discard=False, ignore_expires=False), + "cookies":cookiejar.as_lwp_str(ignore_discard=False, ignore_expires=False).split('\n'), } if save: save_accounts() @@ -41,7 +41,7 @@ def cookiejar_from_lwp_str(lwp_str): return cookiejar def account_cookiejar(username): - return cookiejar_from_lwp_str(accounts[username]['cookies']) + return cookiejar_from_lwp_str('\n'.join(accounts[username]['cookies'])) def get_account_login_page(query_string): style = ''' -- cgit v1.2.3