Skip to content

Commit

Permalink
Fix testing plex media server (PMS) (#6976)
Browse files Browse the repository at this point in the history
* Fix testing plex media server (PMS)

* update changelog

* Also fix testing plex home theater

* Fix ui-notification
  • Loading branch information
p0psicles authored and medariox committed Aug 13, 2019
1 parent 977bf16 commit 0369175
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,7 @@
- Fixed FreeMobile notifier message encode error ([#6867](https://github.com/pymedusa/Medusa/pull/6867))
- Fixed charset on API v2 responses with plain text content ([#6931](https://github.com/pymedusa/Medusa/pull/6931))
- Fixed logger causing an exception in certain cases ([#6932](https://github.com/pymedusa/Medusa/pull/6932))
- Fixed testing Plex media server when using multiple hosts ([#6976](https://github.com/pymedusa/Medusa/pull/6976))

-----

Expand Down
2 changes: 1 addition & 1 deletion medusa/notifiers/plex.py
Expand Up @@ -62,7 +62,7 @@ def _notify_pht(title, message, host=None, username=None, password=None, force=F
username = username or app.PLEX_CLIENT_USERNAME
password = password or app.PLEX_CLIENT_PASSWORD

return kodi_notifier._notify_kodi(message, title=title, host=host, username=username, password=password, force=force, dest_app='PLEX') # pylint: disable=protected-access
return kodi_notifier._notify_kodi(title, message, host=host, username=username, password=password, force=force, dest_app='PLEX') # pylint: disable=protected-access

##############################################################################
# Public functions
Expand Down
16 changes: 9 additions & 7 deletions medusa/server/web/home/handler.py
Expand Up @@ -382,15 +382,16 @@ def testPHT(self, host=None, username=None, password=None):
if None is not password and set('*') == set(password):
password = app.PLEX_CLIENT_PASSWORD

host = config.clean_hosts(host)
final_result = ''
for curHost in [x.strip() for x in host.split(',')]:
for curHost in [x.strip() for x in host if x.strip()]:
cur_result = notifiers.plex_notifier.test_notify_pht(unquote_plus(curHost), username, password)
if len(cur_result.split(':')) > 2 and 'OK' in cur_result.split(':')[2]:
final_result += 'Successful test notice sent to Plex Home Theater ... {host}<br>\n'.format(host=unquote_plus(curHost))
else:
final_result += 'Test failed for Plex Home Theater ... {host}<br>\n'.format(host=unquote_plus(curHost))
final_result += 'Test failed for Plex Home Theater ... {host}<br>\n'.format(host=unquote_plus(cur_result))

ui.notifications.message('Tested Plex Home Theater(s): ', unquote_plus(host.replace(',', ', ')))
ui.notifications.message('Tested Plex Home Theater(s)', final_result)

return final_result

Expand All @@ -400,17 +401,18 @@ def testPMS(self, host=None, username=None, password=None, plex_server_token=Non
if password is not None and set('*') == set(password):
password = app.PLEX_SERVER_PASSWORD

host = config.clean_hosts(host)
final_result = ''

cur_result = notifiers.plex_notifier.test_notify_pms(unquote_plus(host), username, password, plex_server_token)
cur_result = notifiers.plex_notifier.test_notify_pms(host, username, password, plex_server_token)
if cur_result is None:
final_result += 'Successful test of Plex Media Server(s) ... {host}<br>\n'.format(host=unquote_plus(host.replace(',', ', ')))
final_result += 'Successful test of Plex Media Server(s) ... {host}<br>\n'.format(host=unquote_plus(', '.join(host)))
elif cur_result is False:
final_result += 'Test failed, No Plex Media Server host specified<br>\n'
else:
final_result += 'Test failed for Plex Media Server(s) ... {host}<br>\n'.format(host=unquote_plus(host.replace(',', ', ')))
final_result += 'Test failed for Plex Media Server(s) ... {host}<br>\n'.format(host=unquote_plus(cur_result))

ui.notifications.message('Tested Plex Media Server host(s): ', unquote_plus(host.replace(',', ', ')))
ui.notifications.message('Tested Plex Media Server(s)', final_result)

return final_result

Expand Down

0 comments on commit 0369175

Please sign in to comment.