diff --git a/default.py b/default.py index 68d0294f..775c8965 100644 --- a/default.py +++ b/default.py @@ -41,6 +41,9 @@ elif mode == "resetauth": elif mode == "adduser": entrypoint.addUser() +elif mode == "userprefs": + entrypoint.userPreferences() + elif mode == "settings": xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)') diff --git a/resources/lib/Entrypoint.py b/resources/lib/Entrypoint.py index 5cdf39f9..5118155f 100644 --- a/resources/lib/Entrypoint.py +++ b/resources/lib/Entrypoint.py @@ -17,6 +17,7 @@ from PlaybackUtils import PlaybackUtils from DownloadUtils import DownloadUtils from ReadEmbyDB import ReadEmbyDB from API import API +from UserPreferences import UserPreferences ##### Play items via plugin://plugin.video.emby/ ##### @@ -120,6 +121,23 @@ def addUser(): xbmc.log("Failed to add user to session.") xbmcgui.Dialog().notification("Error", "Unable to add/remove user from the session.", xbmcgui.NOTIFICATION_ERROR) +def userPreferences(): + doUtils = DownloadUtils() + addonSettings = xbmcaddon.Addon(id='plugin.video.emby') + userPreferencesPage = UserPreferences("script-emby-kodi-UserPreferences.xml", addonSettings.getAddonInfo('path'), "default", "1080i") + url = "{server}/mediabrowser/Users/{UserId}" + result = doUtils.downloadUrl(url) + configuration = result[u'Configuration'] + userPreferencesPage.setConfiguration(configuration) + userPreferencesPage.setName(result[u'Name']) + userPreferencesPage.setImage(API().getUserArtwork(result,"Primary")) + + userPreferencesPage.doModal() + if userPreferencesPage.isSave(): + url = "{server}/mediabrowser/Users/{UserId}/Configuration" + postdata = userPreferencesPage.getConfiguration() + doUtils.downloadUrl(url, postBody=postdata, type="POST") + ##### BROWSE EMBY CHANNELS ##### def BrowseChannels(id, folderid=None): @@ -485,6 +503,7 @@ def doMainListing(): addDirectoryItem("Settings", "plugin://plugin.video.emby/?mode=settings") addDirectoryItem("Perform manual sync", "plugin://plugin.video.emby/?mode=manualsync") addDirectoryItem("Add user to session", "plugin://plugin.video.emby/?mode=adduser") + addDirectoryItem("Configure user preferences", "plugin://plugin.video.emby/?mode=userprefs") addDirectoryItem("Perform local database reset (full resync)", "plugin://plugin.video.emby/?mode=reset") addDirectoryItem("Cache all images to Kodi texture cache (advanced)", "plugin://plugin.video.emby/?mode=texturecache") diff --git a/resources/lib/PersonInfo.py b/resources/lib/PersonInfo.py deleted file mode 100644 index be833226..00000000 --- a/resources/lib/PersonInfo.py +++ /dev/null @@ -1,169 +0,0 @@ - -import sys -import xbmc -import xbmcgui -import xbmcaddon -import json as json -import urllib -from DownloadUtils import DownloadUtils -from API import API - -_MODE_GETCONTENT=0 -_MODE_ITEM_DETAILS=17 - -class PersonInfo(xbmcgui.WindowXMLDialog): - - pluginCastLink = "" - showMovies = False - personName = "" - - def __init__(self, *args, **kwargs): - xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs) - - def onInit(self): - self.action_exitkeys_id = [10, 13] - downloadUtils = DownloadUtils() - url = "{server}/mediabrowser/Persons/" + self.personName + "?format=json" - jsonData = downloadUtils.downloadUrl(url ) - result = jsonData - - name = result.get("Name") - id = result.get("Id") - - # other lib items count - contentCounts = "" - if(result.get("AdultVideoCount") != None and result.get("AdultVideoCount") > 0): - contentCounts = contentCounts + "\nAdult Count : " + str(result.get("AdultVideoCount")) - if(result.get("MovieCount") != None and result.get("MovieCount") > 0): - contentCounts = contentCounts + "\nMovie Count : " + str(result.get("MovieCount")) - if(result.get("SeriesCount") != None and result.get("SeriesCount") > 0): - contentCounts = contentCounts + "\nSeries Count : " + str(result.get("SeriesCount")) - if(result.get("EpisodeCount") != None and result.get("EpisodeCount") > 0): - contentCounts = contentCounts + "\nEpisode Count : " + str(result.get("EpisodeCount")) - - if(len(contentCounts) > 0): - contentCounts = "Total Library Counts:" + contentCounts - - #overview - overview = "" - if(len(contentCounts) > 0): - overview = contentCounts + "\n\n" - over = result.get("Overview") - if(over == None or over == ""): - overview = overview + "No details available" - else: - overview = overview + over - - #person image - image = API().getArtwork(result, "Primary") - - #get other movies - encoded = name.encode("utf-8") - encoded = urllib.quote(encoded) - url = "{server}/mediabrowser/Users/{UserId}/Items/?Recursive=True&Person=" + encoded + "&format=json" - jsonData = downloadUtils.downloadUrl(url) - otherMovieResult = jsonData - - baseName = name.replace(" ", "+") - baseName = baseName.replace("&", "_") - baseName = baseName.replace("?", "_") - baseName = baseName.replace("=", "_") - - #detailsString = getDetailsString() - #search_url = "http://" + host + ":" + port + "/mediabrowser/Users/" + userid + "/Items/?Recursive=True&Person=PERSON_NAME&Fields=" + detailsString + "&format=json" - #search_url = "http://" + host + ":" + port + "/mediabrowser/Users/" + userid + "/Items/?Recursive=True&Person=PERSON_NAME&format=json" - #search_url = urllib.quote(search_url) - #search_url = search_url.replace("PERSON_NAME", baseName) - #self.pluginCastLink = "XBMC.Container.Update(plugin://plugin.video.xbmb3c?mode=" + str(_MODE_GETCONTENT) + "&url=" + search_url + ")" - - otherItemsList = None - try: - otherItemsList = self.getControl(3010) - - items = otherMovieResult.get("Items") - if(items == None): - items = [] - - for item in items: - item_id = item.get("Id") - item_name = item.get("Name") - - type_info = "" - image_id = item_id - item_type = item.get("Type") - - if(item_type == "Season"): - image_id = item.get("SeriesId") - season = item.get("IndexNumber") - type_info = "Season " + str(season).zfill(2) - elif(item_type == "Series"): - image_id = item.get("Id") - type_info = "Series" - elif(item_type == "Movie"): - image_id = item.get("Id") - type_info = "Movie" - elif(item_type == "Episode"): - image_id = item.get("SeriesId") - season = item.get("ParentIndexNumber") - eppNum = item.get("IndexNumber") - type_info = "S" + str(season).zfill(2) + "E" + str(eppNum).zfill(2) - - thumbPath = downloadUtils.imageUrl(image_id, "Primary", 0, 200, 200) - - fanArt = downloadUtils.imageUrl(image_id, "Backdrop",0,10000,10000) - listItem = xbmcgui.ListItem(label=item_name, label2=type_info, iconImage=thumbPath, thumbnailImage=thumbPath) - listItem.setArt({"fanart":fanArt}) - - actionUrl = "plugin://plugin.video.emby?id=" + item_id + "&mode=play" - listItem.setProperty("ActionUrl", actionUrl) - - otherItemsList.addItem(listItem) - - except Exception, e: - xbmc.log("Exception : " + str(e)) - pass - - - - # set the dialog data - self.getControl(3000).setLabel(name) - self.getControl(3001).setText(overview) - self.getControl(3009).setImage(image) - - def setPersonName(self, name): - self.personName = name - - def setInfo(self, data): - self.details = data - - def onFocus(self, controlId): - pass - - def doAction(self): - pass - - def closeDialog(self): - self.close() - - def onClick(self, controlID): - - if(controlID == 3002): - self.showMovies = True - - xbmc.executebuiltin('Dialog.Close(movieinformation)') - self.close() - - elif(controlID == 3010): - - #xbmc.executebuiltin("Dialog.Close(all,true)") - - itemList = self.getControl(3010) - item = itemList.getSelectedItem() - action = item.getProperty("ActionUrl") - - xbmc.executebuiltin("RunPlugin(" + action + ")") - - self.close() - - pass - diff --git a/resources/lib/UserPreferences.py b/resources/lib/UserPreferences.py new file mode 100644 index 00000000..3fa05ff6 --- /dev/null +++ b/resources/lib/UserPreferences.py @@ -0,0 +1,78 @@ + +import sys +import xbmc +import xbmcgui +import xbmcaddon +import json as json +import urllib + +ACTION_BACK = 92 + +class UserPreferences(xbmcgui.WindowXMLDialog): + + configuration = None + save = False + name = None + image = None + + def __init__(self, *args, **kwargs): + xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs) + + def onInit(self): + self.action_exitkeys_id = [10, 13] + # set the dialog data + + cinemaMode = self.configuration.get(u'EnableCinemaMode') + self.getControl(8011).setSelected(cinemaMode) + self.getControl(8001).setLabel(self.name) + self.getControl(8002).setImage(self.image) + def save(self): + self.save = True + + def isSave(self): + return self.save + + def setConfiguration(self, configuration): + self.configuration = configuration + + def getConfiguration(self): + return self.configuration + + def setName(self, name): + self.name = name + + def setImage(self, image): + self.image = image + + def onFocus(self, controlId): + pass + + def doAction(self): + pass + + def closeDialog(self): + self.close() + + def onClick(self, controlID): + + if(controlID == 8012): + # save now + self.save() + self.close() + + elif(controlID == 8013): + #cancel + self.close() + + if(controlID == 8011): + # cinema mode + cinemamode = self.getControl(8011).isSelected() + self.configuration['EnableCinemaMode'] = cinemamode + + pass + + def onAction(self, action): + if action == ACTION_BACK: + self.close() + + diff --git a/resources/skins/default/1080i/script-emby-kodi-UserPreferences.xml b/resources/skins/default/1080i/script-emby-kodi-UserPreferences.xml new file mode 100644 index 00000000..c36de3b9 --- /dev/null +++ b/resources/skins/default/1080i/script-emby-kodi-UserPreferences.xml @@ -0,0 +1,129 @@ + + + 8011 + 0 + + + 560 + 140 + 800 + 800 + + + box.png + 100 + + + box.png + 100 + 700 + + + user image + 80 + 100 + + + 90 + 30 + 40 + 20% + left + font16 + ffeeeeee + + + + 320 + 30 + left + 40 + 100% + font16 + ffeeeeee + + + + separator + -10 + 103 + 101% + 1 + separator.png + + + 50 + 600 + vertical + left + 20 + + + 8 + 8012 + 8012 + 100 + 785 + left + 70 + radio-on.png + radio-off.png + white.png + 750 + 32 + 32 + 30 + B3dddddd + + + + + + + separator + 70 + -10 + 101% + 1 + separator.png + + + Save + 150 + 20 + 230 + 8011 + 8013 + 8013 + font14 + + FFededed + B3dddddd + FF000000 + 40 + ff333333 + box.png + box.png + + + Cancel + 430 + 20 + 230 + 8011 + 8012 + 8012 + font14 + + FFededed + B3dddddd + FF000000 + 40 + ff333333 + box.png + box.png + + + + + \ No newline at end of file diff --git a/resources/skins/default/media/box.png b/resources/skins/default/media/box.png new file mode 100644 index 00000000..6885d23f Binary files /dev/null and b/resources/skins/default/media/box.png differ diff --git a/resources/skins/default/media/radio-off.png b/resources/skins/default/media/radio-off.png new file mode 100644 index 00000000..6127c6fd Binary files /dev/null and b/resources/skins/default/media/radio-off.png differ diff --git a/resources/skins/default/media/radio-on.png b/resources/skins/default/media/radio-on.png new file mode 100644 index 00000000..c05537d9 Binary files /dev/null and b/resources/skins/default/media/radio-on.png differ diff --git a/resources/skins/default/media/separator.png b/resources/skins/default/media/separator.png new file mode 100644 index 00000000..1beff46e Binary files /dev/null and b/resources/skins/default/media/separator.png differ diff --git a/resources/skins/default/media/white.png b/resources/skins/default/media/white.png new file mode 100644 index 00000000..136602c6 Binary files /dev/null and b/resources/skins/default/media/white.png differ