Message if PMS item could not be deleted

This commit is contained in:
tomkat83 2016-10-23 16:37:26 +02:00
parent 45a9f8081b
commit 0b2ccde834
5 changed files with 15 additions and 10 deletions

View file

@ -266,6 +266,7 @@
<string id="30411">Set custom song rating (0-5)</string>
<string id="30412">Force transcode</string>
<string id="30413">Enable Plex context menu in Kodi</string>
<string id="30414">Could not delete the Plex item. Is item deletion enabled on the Plex Media Server?</string>
<!-- add-on settings -->
<string id="30500">Verify Host SSL Certificate (more secure)</string>

View file

@ -298,6 +298,7 @@
<string id="30411">Set custom song rating (0-5)</string>
<string id="30412">Transkodieren erzwingen</string>
<string id="30413">Plex Kontextmenu in Kodi aktivieren</string>
<string id="30414">Konnte das Element nicht löschen. Ist diese Option auf dem Plex Medien Server aktiviert?</string>
<string id="33033">Kodi wird jetzt neu gestartet um die Änderungen anzuwenden.</string>

View file

@ -535,13 +535,11 @@ def delete_item_from_pms(plexid):
Returns True if successful, False otherwise
"""
xml = downloadutils.DownloadUtils().downloadUrl(
if downloadutils.DownloadUtils().downloadUrl(
'{server}/library/metadata/%s' % plexid,
action_type="DELETE")
try:
xml.attrib
except AttributeError:
log.error('Could not delete Plex id %s' % plexid)
return False
log.info(xml.dump)
action_type="DELETE") is True:
log.info('Successfully deleted Plex id %s from the PMS' % plexid)
return True
else:
log.error('Could not delete Plex id %s from the PMS' % plexid)
return False

View file

@ -191,4 +191,5 @@ class ContextMenu(object):
if delete:
log.info("Deleting Plex item with id %s", self.item_id)
delete_item_from_pms(self.item_id)
if delete_item_from_pms(self.item_id) is False:
dialog(type_="ok", heading="{plex}", line1=lang(30414))

View file

@ -319,6 +319,10 @@ class DownloadUtils():
log.info('Received text:')
log.info(r.text)
return True
elif r.status_code == 403:
# E.g. deleting a PMS item
log.error('PMS sent 403: Forbidden error for url %s' % url)
return None
else:
log.error('Unknown answer from PMS %s with status code %s. '
'Message:' % (url, r.status_code))