diff --git a/contextmenu.py b/contextmenu.py
index 619ba149..e7bee464 100644
--- a/contextmenu.py
+++ b/contextmenu.py
@@ -82,6 +82,9 @@ if __name__ == '__main__':
#Set custom song rating
options.append(utils.language(30407))
+ #delete item
+ options.append(utils.language(30409))
+
#addon settings
options.append(utils.language(30408))
@@ -119,4 +122,14 @@ if __name__ == '__main__':
if options[ret] == utils.language(30408):
#Open addon settings
xbmc.executebuiltin("Addon.OpenSettings(plugin.video.emby)")
-
+
+ if options[ret] == utils.language(30409):
+ #delete item from the server
+ if xbmcgui.Dialog().yesno("Do you really want to delete this item ?", "This will delete the item from the server and the file(s) from disk!"):
+ import downloadutils
+ doUtils = downloadutils.DownloadUtils()
+ url = "{server}/emby/Items/%s?format=json" % embyid
+ doUtils.downloadUrl(url, type="DELETE")
+
+ xbmc.sleep(500)
+ xbmc.executebuiltin("Container.Update")
\ No newline at end of file
diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml
index dc3c60c2..abcf07a5 100644
--- a/resources/language/English/strings.xml
+++ b/resources/language/English/strings.xml
@@ -272,6 +272,7 @@
Remove from Emby favorites
Set custom song rating
Emby addon settings
+ Delete item from the server
diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py
index 80d623ff..15994d1e 100644
--- a/resources/lib/entrypoint.py
+++ b/resources/lib/entrypoint.py
@@ -428,26 +428,27 @@ def BrowseContent(viewname, type="", folderid=None, filter=""):
#get the actual listing
if filter == "recent":
- listing = emby.getFilteredSection("", itemtype=itemtype.split(",")[0], sortby="DateCreated", recursive=True, limit=25, sortorder="Descending").get("Items",[])
+ listing = emby.getFilteredSection("", itemtype=itemtype.split(",")[0], sortby="DateCreated", recursive=True, limit=25, sortorder="Descending")
elif filter == "random":
- listing = emby.getFilteredSection("", itemtype=itemtype.split(",")[0], sortby="Random", recursive=True, limit=150, sortorder="Descending").get("Items",[])
+ listing = emby.getFilteredSection("", itemtype=itemtype.split(",")[0], sortby="Random", recursive=True, limit=150, sortorder="Descending")
elif filter == "recommended":
- listing = emby.getFilteredSection("", itemtype=itemtype.split(",")[0], sortby="SortName", recursive=True, limit=25, sortorder="Ascending", filter="IsFavorite").get("Items",[])
+ listing = emby.getFilteredSection("", itemtype=itemtype.split(",")[0], sortby="SortName", recursive=True, limit=25, sortorder="Ascending", filter="IsFavorite")
elif filter == "sets":
- listing = emby.getFilteredSection("", itemtype=itemtype.split(",")[1], sortby="SortName", recursive=True, limit=25, sortorder="Ascending", filter="IsFavorite").get("Items",[])
+ listing = emby.getFilteredSection("", itemtype=itemtype.split(",")[1], sortby="SortName", recursive=True, limit=25, sortorder="Ascending", filter="IsFavorite")
else:
- listing = emby.getFilteredSection(folderid, itemtype=itemtype, recursive=False).get("Items",[])
+ listing = emby.getFilteredSection(folderid, itemtype=itemtype, recursive=False)
#process the listing
- for item in listing:
- li = createListItemFromEmbyItem(item)
- if item.get("IsFolder") == True:
- #for folders we add an additional browse request, passing the folderId
- path = "%s?id=%s&mode=browsecontent&type=%s&folderid=%s" % (sys.argv[0], viewname, type, item.get("Id"))
- xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=True)
- else:
- #playable item, set plugin path and mediastreams
- xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=li.getProperty("path"), listitem=li)
+ if listing:
+ for item in listing.get("Items"):
+ li = createListItemFromEmbyItem(item)
+ if item.get("IsFolder") == True:
+ #for folders we add an additional browse request, passing the folderId
+ path = "%s?id=%s&mode=browsecontent&type=%s&folderid=%s" % (sys.argv[0], viewname, type, item.get("Id"))
+ xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=True)
+ else:
+ #playable item, set plugin path and mediastreams
+ xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=li.getProperty("path"), listitem=li)
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
@@ -479,14 +480,16 @@ def createListItemFromEmbyItem(item):
allart = art.getAllArtwork(item)
- if item["Type"] in ["Photo","PhotoAlbum"]:
+ if item["Type"] is "Photo":
#listitem setup for pictures...
img_path = allart.get('Primary')
li.setProperty("path",img_path)
- picture = doUtils.downloadUrl("{server}/Items/%s/Images" %itemid)[0]
- if picture.get("Width") > picture.get("Height"):
- li.setArt( {"fanart": img_path}) #add image as fanart for use with skinhelper auto thumb/backgrund creation
- li.setInfo('pictures', infoLabels={ "picturepath": img_path, "date": premieredate, "size": picture.get("Size"), "exif:width": str(picture.get("Width")), "exif:height": str(picture.get("Height")), "title": "blaat" })
+ picture = doUtils.downloadUrl("{server}/Items/%s/Images" %itemid)
+ if picture:
+ picture = picture[0]
+ if picture.get("Width") > picture.get("Height"):
+ li.setArt( {"fanart": img_path}) #add image as fanart for use with skinhelper auto thumb/backgrund creation
+ li.setInfo('pictures', infoLabels={ "picturepath": img_path, "date": premieredate, "size": picture.get("Size"), "exif:width": str(picture.get("Width")), "exif:height": str(picture.get("Height")), "title": "blaat" })
li.setThumbnailImage(img_path)
li.setIconImage('DefaultPicture.png')
else: