From 3710c139fb4cafe2db93c60ba05b134be90fe807 Mon Sep 17 00:00:00 2001 From: Rob McGhee Date: Wed, 6 Jul 2016 19:42:57 +0100 Subject: [PATCH 1/3] Emby API Key Add the option to read an API Key from the config file and submit that instead of needing a password. Doesn't remove the use of password so is backwards compatible with users current config file --- beetsplug/embyupdate.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/beetsplug/embyupdate.py b/beetsplug/embyupdate.py index 73fa3dcc3..b9adde36a 100644 --- a/beetsplug/embyupdate.py +++ b/beetsplug/embyupdate.py @@ -104,24 +104,26 @@ class EmbyUpdate(BeetsPlugin): port = config['emby']['port'].get() username = config['emby']['username'].get() password = config['emby']['password'].get() + token = config['emby']['apikey'].get() # Get user information from the Emby API. user = get_user(host, port, username) if not user: self._log.warning(u'User {0} could not be found.'.format(username)) return + + if not token: + # Create Authentication data and headers. + auth_data = password_data(username, password) + headers = create_headers(user[0]['Id']) - # Create Authentication data and headers. - auth_data = password_data(username, password) - headers = create_headers(user[0]['Id']) - - # Get authentication token. - token = get_token(host, port, headers, auth_data) - if not token: - self._log.warning( - u'Could not get token for user {0}', username - ) - return + # Get authentication token. + token = get_token(host, port, headers, auth_data) + if not token: + self._log.warning( + u'Could not get token for user {0}', username + ) + return # Recreate headers with a token. headers = create_headers(user[0]['Id'], token=token) From 2dad86291e35c05e3739c867187d6c9b2026727e Mon Sep 17 00:00:00 2001 From: Rob McGhee Date: Thu, 7 Jul 2016 22:46:33 +0100 Subject: [PATCH 2/3] Emby API Key Corrected the use of spaces rather than tabs. Add the option to use an Emby API key to authenticate rather than a password --- beetsplug/embyupdate.py | 26 +++++++++++++------------- docs/changelog.rst | 5 +++++ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/beetsplug/embyupdate.py b/beetsplug/embyupdate.py index b9adde36a..2a2f792f5 100644 --- a/beetsplug/embyupdate.py +++ b/beetsplug/embyupdate.py @@ -104,26 +104,26 @@ class EmbyUpdate(BeetsPlugin): port = config['emby']['port'].get() username = config['emby']['username'].get() password = config['emby']['password'].get() - token = config['emby']['apikey'].get() + token = config['emby']['apikey'].get() # Get user information from the Emby API. user = get_user(host, port, username) if not user: self._log.warning(u'User {0} could not be found.'.format(username)) return - - if not token: - # Create Authentication data and headers. - auth_data = password_data(username, password) - headers = create_headers(user[0]['Id']) - # Get authentication token. - token = get_token(host, port, headers, auth_data) - if not token: - self._log.warning( - u'Could not get token for user {0}', username - ) - return + if not token: + # Create Authentication data and headers. + auth_data = password_data(username, password) + headers = create_headers(user[0]['Id']) + + # Get authentication token. + token = get_token(host, port, headers, auth_data) + if not token: + self._log.warning( + u'Could not get token for user {0}', username + ) + return # Recreate headers with a token. headers = create_headers(user[0]['Id'], token=token) diff --git a/docs/changelog.rst b/docs/changelog.rst index efb6cc260..82172f545 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,11 @@ Changelog ========= +* :doc:`/plugins/embyupdate`: Use the option of Emby's API Key's rather than + a password. Add an apikey to your config file for this to work. Does not + break the use of password as an authentication method + + 1.4.0 (in development) ---------------------- From af24277ad39fcf2bfa9dc238ad0e891b30571cb3 Mon Sep 17 00:00:00 2001 From: Rob McGhee Date: Wed, 20 Jul 2016 21:17:45 +0100 Subject: [PATCH 3/3] Emby API Key Update Added note to the Emby Plugin Documentation --- docs/plugins/embyupdate.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/plugins/embyupdate.rst b/docs/plugins/embyupdate.rst index 3e4c9687f..f2826040c 100644 --- a/docs/plugins/embyupdate.rst +++ b/docs/plugins/embyupdate.rst @@ -9,6 +9,7 @@ To use ``embyupdate`` plugin, enable it in your configuration (see :ref:`using-p host: localhost port: 8096 username: user + apikey: apikey password: password To use the ``embyupdate`` plugin you need to install the `requests`_ library with:: @@ -30,4 +31,5 @@ The available options under the ``emby:`` section are: - **port**: The Emby server port. Default: 8096 - **username**: A username of a Emby user that is allowed to refresh the library. -- **password**: That user's password. +- **apikey**: An Emby API key +- **password**: If no API key is present then enter the user aboves password.