Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix testing plex media server (PMS) #6976

Merged
merged 4 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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