Merge pull request #2117 from mousey/master

Emby API Key
This commit is contained in:
Adrian Sampson 2016-07-20 23:42:09 -04:00
commit d0c2bb1d76
3 changed files with 20 additions and 11 deletions

View file

@ -104,6 +104,7 @@ 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)
@ -111,17 +112,18 @@ class EmbyUpdate(BeetsPlugin):
self._log.warning(u'User {0} could not be found.'.format(username))
return
# 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
# 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)

View file

@ -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)
----------------------

View file

@ -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.