From ad594ff4721492e2f55103d42a49c8bcb718068b Mon Sep 17 00:00:00 2001 From: im85288 Date: Sat, 6 Jun 2015 12:05:14 +0100 Subject: [PATCH] user preferences --- default.py | 3 + resources/lib/Entrypoint.py | 19 ++ resources/lib/PersonInfo.py | 169 ------------------ resources/lib/UserPreferences.py | 78 ++++++++ .../script-emby-kodi-UserPreferences.xml | 129 +++++++++++++ resources/skins/default/media/box.png | Bin 0 -> 244 bytes resources/skins/default/media/radio-off.png | Bin 0 -> 197 bytes resources/skins/default/media/radio-on.png | Bin 0 -> 329 bytes resources/skins/default/media/separator.png | Bin 0 -> 1436 bytes resources/skins/default/media/white.png | Bin 0 -> 263 bytes 10 files changed, 229 insertions(+), 169 deletions(-) delete mode 100644 resources/lib/PersonInfo.py create mode 100644 resources/lib/UserPreferences.py create mode 100644 resources/skins/default/1080i/script-emby-kodi-UserPreferences.xml create mode 100644 resources/skins/default/media/box.png create mode 100644 resources/skins/default/media/radio-off.png create mode 100644 resources/skins/default/media/radio-on.png create mode 100644 resources/skins/default/media/separator.png create mode 100644 resources/skins/default/media/white.png 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 0000000000000000000000000000000000000000..6885d23f5e4b7f38fa8c3399f4d50ddcddb9501b GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzwj^(N7a$D;Kb?2i11Zh|kH}&M z25w;xW@MN(M*=9wUgGKN%6^Yalv70I%Ikz5Kq1-8kcblJ{M_8syb>Unfx)>bHL)Z$ zMWH;iBtya7(>EYRFO?lA9^vWY7!q;#?R7)O1_K_}i{5(^R?avmFfGdPID^!QPx+_5 z-IrpxvQqDVF4L9rJ6}qs?P^%exxsttF}Aa;0uBs}EO3G+!TjBO#+crQ^4*_p>lt)2 V{}@dFm3tOsxu>h2%Q~loCIDM`NpAoE literal 0 HcmV?d00001 diff --git a/resources/skins/default/media/radio-off.png b/resources/skins/default/media/radio-off.png new file mode 100644 index 0000000000000000000000000000000000000000..6127c6fd743c42c9bf5205fe713edb347a36b6f8 GIT binary patch literal 197 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJ9#0p?kch)?!yLI940vweH2=MI z@0tyn2M-DGpS~58$jhR?xy|Ivlt~^n4IO;^e)W5{UTf|7xboo?4!bLJ88|CKuFqaR zDfHPvz7Gt!^D5Zh9N1tk%viv-hV_6pNBIF|=9dRv*-p^D@kNQNT*0R0Azw@S1Alwv w$xe&brCj0^+;cy&^uUw=W4_f-JKq*CnjX!MU!oYH0dyCGr>mdKI;Vst0COiy!vFvP literal 0 HcmV?d00001 diff --git a/resources/skins/default/media/radio-on.png b/resources/skins/default/media/radio-on.png new file mode 100644 index 0000000000000000000000000000000000000000..c05537d9a279939f6c6449ae3735fce184bbd56e GIT binary patch literal 329 zcmV-P0k-~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V$)(FXj(>T5vOH*ju^1VAT8n0 zojN!aNwnU9h|jH}qX5Zi7tNdu0RRfVR6D~;AK1x)QFf3NzaP=+9g<_3 zF_0eC+%3PR1O`AwRb5lx$~WVG94iIBj(R@A+guASVXk=KNu>JEE_a2Z_K9LQpIj#N zWv$@Pd2vY`i&(@NZruE^eV^(*&0cGcrJ_dQx$<-ApP!Q=W}AnB$^reCe|TK;-hEvF N_9zZh_wAWq{sW5_ZYcl& literal 0 HcmV?d00001 diff --git a/resources/skins/default/media/white.png b/resources/skins/default/media/white.png new file mode 100644 index 0000000000000000000000000000000000000000..136602c62b5c777dbd23c678f700fecc9b963b37 GIT binary patch literal 263 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Y)RhkEFVdQ&MBb@0Df;e82|tP literal 0 HcmV?d00001