From a2cfa8019833ff971afb69972038c045625502c5 Mon Sep 17 00:00:00 2001 From: Aleksei Kovura <3616242+alex3kov@users.noreply.github.com> Date: Sun, 5 Nov 2017 18:12:39 +0300 Subject: [PATCH] First draft of libsecret support (fixed formatting). --- youtube_dl/__init__.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 8f20a7ecc..bba15db35 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -50,14 +50,8 @@ from .YoutubeDL import YoutubeDL def _real_main(argv=None): - LIBSECRET_SCHEMA = Secret.Schema.new("io.github.rg3.youtube-dl.Store", - Secret.SchemaFlags.DONT_MATCH_NAME, - { - "user-name": Secret.SchemaAttributeType.STRING, - "domain-name": Secret.SchemaAttributeType.STRING - } - ) - + LIBSECRET_SCHEMA = Secret.Schema.new("io.github.rg3.youtube-dl.Store", Secret.SchemaFlags.DONT_MATCH_NAME, {"user-name": Secret.SchemaAttributeType.STRING, "domain-name": Secret.SchemaAttributeType.STRING}) + # Compatibility fixes for Windows if sys.platform == 'win32': # https://github.com/rg3/youtube-dl/issues/820 @@ -159,14 +153,14 @@ def _real_main(argv=None): if len(all_domains) > 1: parser.error('You passed URLs from more than one domain - supplying credentials from command line is not supported in this case.') domain_name = all_domains.pop() - password = Secret.password_lookup_sync(LIBSECRET_SCHEMA, { "user-name": opts.username, "domain-name": domain_name }, None) + password = Secret.password_lookup_sync(LIBSECRET_SCHEMA, {"user-name": opts.username, "domain-name": domain_name}, None) if password is None: print("Password for domain " + domain_name + " and user name " + opts.username + " not found in the keyring.") supplied_password = compat_getpass('Type account password and press [Return]: ') - attributes = { "user-name": opts.username, "domain-name": domain_name } + attributes = {"user-name": opts.username, "domain-name": domain_name} label = "Youtube-dl: " + domain_name + " password" Secret.password_store_sync(LIBSECRET_SCHEMA, attributes, Secret.COLLECTION_DEFAULT, label, supplied_password, None) - password = Secret.password_lookup_sync(LIBSECRET_SCHEMA, { "user-name": opts.username, "domain-name": domain_name }, None) + password = Secret.password_lookup_sync(LIBSECRET_SCHEMA, {"user-name": opts.username, "domain-name": domain_name}, None) opts.password = password if opts.username is not None and opts.password is None and opts.password_from_keyring is False: opts.password = compat_getpass('Type account password and press [Return]: ')