fix small typos

add delete option to context menu
This commit is contained in:
marcelveldt 2016-01-13 01:26:07 +01:00
parent b24e881f18
commit 8e2cae3b13
3 changed files with 37 additions and 20 deletions

View file

@ -82,6 +82,9 @@ if __name__ == '__main__':
#Set custom song rating #Set custom song rating
options.append(utils.language(30407)) options.append(utils.language(30407))
#delete item
options.append(utils.language(30409))
#addon settings #addon settings
options.append(utils.language(30408)) options.append(utils.language(30408))
@ -119,4 +122,14 @@ if __name__ == '__main__':
if options[ret] == utils.language(30408): if options[ret] == utils.language(30408):
#Open addon settings #Open addon settings
xbmc.executebuiltin("Addon.OpenSettings(plugin.video.emby)") 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")

View file

@ -272,6 +272,7 @@
<string id="30406">Remove from Emby favorites</string> <string id="30406">Remove from Emby favorites</string>
<string id="30407">Set custom song rating</string> <string id="30407">Set custom song rating</string>
<string id="30408">Emby addon settings</string> <string id="30408">Emby addon settings</string>
<string id="30409">Delete item from the server</string>
</strings> </strings>

View file

@ -428,26 +428,27 @@ def BrowseContent(viewname, type="", folderid=None, filter=""):
#get the actual listing #get the actual listing
if filter == "recent": 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": 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": 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": 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: else:
listing = emby.getFilteredSection(folderid, itemtype=itemtype, recursive=False).get("Items",[]) listing = emby.getFilteredSection(folderid, itemtype=itemtype, recursive=False)
#process the listing #process the listing
for item in listing: if listing:
li = createListItemFromEmbyItem(item) for item in listing.get("Items"):
if item.get("IsFolder") == True: li = createListItemFromEmbyItem(item)
#for folders we add an additional browse request, passing the folderId if item.get("IsFolder") == True:
path = "%s?id=%s&mode=browsecontent&type=%s&folderid=%s" % (sys.argv[0], viewname, type, item.get("Id")) #for folders we add an additional browse request, passing the folderId
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=True) path = "%s?id=%s&mode=browsecontent&type=%s&folderid=%s" % (sys.argv[0], viewname, type, item.get("Id"))
else: xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=True)
#playable item, set plugin path and mediastreams else:
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=li.getProperty("path"), listitem=li) #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])) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
@ -479,14 +480,16 @@ def createListItemFromEmbyItem(item):
allart = art.getAllArtwork(item) allart = art.getAllArtwork(item)
if item["Type"] in ["Photo","PhotoAlbum"]: if item["Type"] is "Photo":
#listitem setup for pictures... #listitem setup for pictures...
img_path = allart.get('Primary') img_path = allart.get('Primary')
li.setProperty("path",img_path) li.setProperty("path",img_path)
picture = doUtils.downloadUrl("{server}/Items/%s/Images" %itemid)[0] picture = doUtils.downloadUrl("{server}/Items/%s/Images" %itemid)
if picture.get("Width") > picture.get("Height"): if picture:
li.setArt( {"fanart": img_path}) #add image as fanart for use with skinhelper auto thumb/backgrund creation picture = picture[0]
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" }) 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.setThumbnailImage(img_path)
li.setIconImage('DefaultPicture.png') li.setIconImage('DefaultPicture.png')
else: else: