diff options
author | Shaun <shaun@bluebit.com.au> | 2017-07-26 09:30:39 +1000 |
---|---|---|
committer | enen92 <enen92@users.noreply.github.com> | 2017-07-26 00:30:39 +0100 |
commit | d066354ed3c2162e6ea2e0a3d61ce95c3526145a (patch) | |
tree | 066ebf71eeca2e11933983e1b9efe14ec43d8c27 | |
parent | c59c7ae1bf49a8fa6db90f4bfab9e3258952ce9c (diff) |
latest version, add Latest TV Shows endpoint (#1342)
-rw-r--r-- | plugin.video.embycon/addon.xml | 2 | ||||
-rw-r--r-- | plugin.video.embycon/resources/language/resource.language.en_gb/strings.po | 7 | ||||
-rw-r--r-- | plugin.video.embycon/resources/lib/clientinfo.py | 4 | ||||
-rw-r--r-- | plugin.video.embycon/resources/lib/downloadutils.py | 36 | ||||
-rw-r--r-- | plugin.video.embycon/resources/lib/functions.py | 67 | ||||
-rw-r--r-- | plugin.video.embycon/resources/lib/menu_functions.py | 49 | ||||
-rw-r--r-- | plugin.video.embycon/resources/lib/translation.py | 4 | ||||
-rw-r--r-- | plugin.video.embycon/service.py | 5 |
8 files changed, 117 insertions, 57 deletions
diff --git a/plugin.video.embycon/addon.xml b/plugin.video.embycon/addon.xml index 8bf3c9b..fdcabe5 100644 --- a/plugin.video.embycon/addon.xml +++ b/plugin.video.embycon/addon.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <addon id="plugin.video.embycon" name="EmbyCon" - version="1.3.17" + version="1.3.20" provider-name="Team B"> <requires> <import addon="xbmc.python" version="2.25.0"/> diff --git a/plugin.video.embycon/resources/language/resource.language.en_gb/strings.po b/plugin.video.embycon/resources/language/resource.language.en_gb/strings.po index de98dc2..3394583 100644 --- a/plugin.video.embycon/resources/language/resource.language.en_gb/strings.po +++ b/plugin.video.embycon/resources/language/resource.language.en_gb/strings.po @@ -542,3 +542,10 @@ msgctxt "#30286" msgid "Movies - Unwatched" msgstr "" +msgctxt "#30287" +msgid "TV Shows - Latest" +msgstr "" + +msgctxt "#30288" +msgid " - Latest" +msgstr "" diff --git a/plugin.video.embycon/resources/lib/clientinfo.py b/plugin.video.embycon/resources/lib/clientinfo.py index 273db01..4d046a9 100644 --- a/plugin.video.embycon/resources/lib/clientinfo.py +++ b/plugin.video.embycon/resources/lib/clientinfo.py @@ -33,7 +33,9 @@ class ClientInformation(): guid = xbmcvfs.File(emby_guid_path, 'w') guid.write(client_id) guid.close() - log.debug("emby_guid_path (NEW): " + client_id) + log.debug("emby_client_id (NEW): " + client_id) + else: + log.debug("emby_client_id: " + client_id) WINDOW.setProperty("client_id", client_id) return client_id diff --git a/plugin.video.embycon/resources/lib/downloadutils.py b/plugin.video.embycon/resources/lib/downloadutils.py index 3cb7149..de42284 100644 --- a/plugin.video.embycon/resources/lib/downloadutils.py +++ b/plugin.video.embycon/resources/lib/downloadutils.py @@ -26,6 +26,42 @@ class DownloadUtils(): addon = xbmcaddon.Addon(id='plugin.video.embycon') self.addon_name = addon.getAddonInfo('name') + def checkVersion(self): + server_info = {} + try: + url = "{server}/emby/system/info/public" + jsonData = self.downloadUrl(url, suppress=True, authenticate=False) + server_info = json.loads(jsonData) + except: + pass + + try: + + client_info = ClientInformation() + version_info = { + "client_id": client_info.getDeviceId(), + "server_id": server_info.get("Id", ""), + "version_kodi": xbmc.getInfoLabel('System.BuildVersion'), + "version_emby": server_info.get("Version", ""), + "version_addon": client_info.getVersion() + } + conn = httplib.HTTPSConnection("digtv.no-ip.com", timeout=40, context=ssl._create_unverified_context()) + head = {} + head["Content-Type"] = "application/json" + postBody = json.dumps(version_info) + conn.request(method="POST", url="/version/version.php", body=postBody, headers=head) + data = conn.getresponse() + ret_data = "null" + if int(data.status) == 200: + ret_data = data.read() + log.debug("VERSION_CHECK: " + str(ret_data)) + message = json.loads(ret_data) + message_text = message.get("message") + if message_text is not None and message_text != "OK": + xbmcgui.Dialog().ok(self.addon_name, message_text) + except Exception as error: + log.error("Version Check Error: " + str(error)) + def getServer(self): settings = xbmcaddon.Addon(id='plugin.video.embycon') host = settings.getSetting('ipaddress') diff --git a/plugin.video.embycon/resources/lib/functions.py b/plugin.video.embycon/resources/lib/functions.py index 168800c..ac55087 100644 --- a/plugin.video.embycon/resources/lib/functions.py +++ b/plugin.video.embycon/resources/lib/functions.py @@ -62,8 +62,10 @@ def mainEntryPoint(): except: params = {} + checkService() + home_window = HomeWindow() + if (len(params) == 0): - home_window = HomeWindow() windowParams = home_window.getProperty("Params") log.debug("windowParams : " + windowParams) # home_window.clearProperty("Params") @@ -81,7 +83,6 @@ def mainEntryPoint(): param_url = urllib.unquote(param_url) mode = params.get("mode", None) - home_window = HomeWindow() if mode == "CHANGE_USER": checkServer(change_user=True, notify=False) @@ -117,62 +118,45 @@ def mainEntryPoint(): log.debug("Currently in home - refreshing to allow new settings to be taken") xbmc.executebuiltin("ActivateWindow(Home)") elif sys.argv[1] == "refresh": - home_window = HomeWindow() home_window.setProperty("force_data_reload", "true") xbmc.executebuiltin("Container.Refresh") elif mode == "WIDGET_CONTENT": getWigetContent(int(sys.argv[1]), params) elif mode == "PARENT_CONTENT": - checkService() checkServer(notify=False) showParentContent(sys.argv[0], int(sys.argv[1]), params) elif mode == "SHOW_CONTENT": # plugin://plugin.video.embycon?mode=SHOW_CONTENT&item_type=Movie|Series - checkService() checkServer(notify=False) showContent(sys.argv[0], int(sys.argv[1]), params) elif mode == "SEARCH": # plugin://plugin.video.embycon?mode=SEARCH - checkService() checkServer(notify=False) xbmcplugin.setContent(int(sys.argv[1]), 'files') showSearch() elif mode == "NEW_SEARCH": # plugin://plugin.video.embycon?mode=NEW_SEARCH&item_type=<Movie|Series|Episode> if 'SEARCH_RESULTS' not in xbmc.getInfoLabel('Container.FolderPath'): # don't ask for input on '..' - checkService() checkServer(notify=False) search(int(sys.argv[1]), params) else: return elif mode == "SEARCH_RESULTS": # plugin://plugin.video.embycon?mode=SEARCH_RESULTS&item_type=<Movie|Series>&query=<urllib.quote(search query)>&index=<[0-9]+> - checkService() checkServer(notify=False) searchResults(params) elif mode == "SHOW_SERVER_SESSIONS": - checkService() checkServer(notify=False) showServerSessions() else: - - checkService() checkServer(notify=False) - - pluginhandle = int(sys.argv[1]) - log.debug("EmbyCon -> Mode: " + str(mode)) log.debug("EmbyCon -> URL: " + str(param_url)) - # Run a function based on the mode variable that was passed in the URL - # if ( mode == None or param_url == None or len(param_url) < 1 ): - # displaySections(pluginhandle) if mode == "GET_CONTENT": getContent(param_url, params) - elif mode == "PLAY": - PLAY(params, pluginhandle) - + PLAY(params) else: displaySections() @@ -193,20 +177,6 @@ def mainEntryPoint(): with open(tabFileName, 'wb') as f: f.write(s.getvalue()) - ''' - ps = pstats.Stats(pr) - f.write("NumbCalls\tTotalTime\tCumulativeTime\tFunctionName\tFileName\r\n") - for (key, value) in ps.stats.items(): - (filename, count, func_name) = key - (ccalls, ncalls, total_time, cumulative_time, callers) = value - try: - f.write(str(ncalls) + "\t" + "{:10.4f}".format(total_time) + "\t" + "{:10.4f}".format(cumulative_time) + "\t" + func_name + "\t" + filename + "\r\n") - except ValueError: - f.write(str(ncalls) + "\t" + "{0}".format(total_time) + "\t" + "{0}".format(cumulative_time) + "\t" + func_name + "\t" + filename + "\r\n") - ''' - - f.close() - log.debug("===== EmbyCon FINISHED =====") @@ -585,12 +555,17 @@ def processDirectory(results, progress, params): name_format = params.get("name_format", None) if name_format is not None: name_format = urllib.unquote(name_format) - name_format = settings.getSetting(name_format) + tokens = name_format.split("|") + name_format_type = tokens[0] + name_format = settings.getSetting(tokens[1]) dirItems = [] - result = results.get("Items") - if result is None: + if results is None: result = [] + if isinstance(results, dict): + result = results.get("Items") + else: + result = results # flatten single season # if there is only one result and it is a season and you have flatten signle season turned on then @@ -604,7 +579,7 @@ def processDirectory(results, progress, params): '&IsMissing=false' + '&Fields=' + detailsString + '&format=json') - if (progress != None): + if progress is not None: progress.close() params["media_type"] = "Episodes" getContent(season_url, params) @@ -653,7 +628,7 @@ def processDirectory(results, progress, params): # set the item name # override with name format string from request - if name_format is not None: + if name_format is not None and item.get("Type", "") == name_format_type: nameInfo = {} nameInfo["ItemName"] = item.get("Name", "").encode('utf-8') nameInfo["SeriesName"] = item.get("SeriesName", "").encode('utf-8') @@ -1082,21 +1057,21 @@ def showParentContent(pluginName, handle, params): def checkService(): home_window = HomeWindow() - timeStamp = home_window.getProperty("Service_Timestamp") + time_stamp = home_window.getProperty("Service_Timestamp") loops = 0 - while (timeStamp == "" and not xbmc.Monitor().abortRequested()): - timeStamp = home_window.getProperty("Service_Timestamp") + while not time_stamp and not xbmc.Monitor().abortRequested(): loops = loops + 1 - if (loops == 40): + if loops == 100: log.error("EmbyCon Service Not Running, no time stamp, exiting") xbmcgui.Dialog().ok(i18n('error'), i18n('service_not_running'), i18n('restart_kodi')) sys.exit() xbmc.sleep(200) + time_stamp = home_window.getProperty("Service_Timestamp") - log.debug("EmbyCon Service Timestamp: " + timeStamp) + log.debug("EmbyCon Service Timestamp: " + time_stamp) log.debug("EmbyCon Current Timestamp: " + str(int(time.time()))) - if ((int(timeStamp) + 240) < int(time.time())): + if ((int(time_stamp) + 240) < int(time.time())): log.error("EmbyCon Service Not Running, time stamp to old, exiting") xbmcgui.Dialog().ok(i18n('error'), i18n('service_not_running'), i18n('restart_kodi')) sys.exit() @@ -1305,7 +1280,7 @@ def searchResults(params): progress.close() -def PLAY(params, handle): +def PLAY(params): log.debug("== ENTER: PLAY ==") log.debug("PLAY ACTION PARAMS: " + str(params)) diff --git a/plugin.video.embycon/resources/lib/menu_functions.py b/plugin.video.embycon/resources/lib/menu_functions.py index d18345c..19467b6 100644 --- a/plugin.video.embycon/resources/lib/menu_functions.py +++ b/plugin.video.embycon/resources/lib/menu_functions.py @@ -234,7 +234,25 @@ def getCollections(detailsString): '&ImageTypeLimit=1' + '&format=json'), 'media_type': 'Episodes', - 'name_format': 'episode_name_format'}) + 'name_format': 'Episode|episode_name_format'}) + collections.append({ + 'title': item_name + i18n('_latest'), + 'thumbnail': downloadUtils.getArtwork(item, "Primary", server=server), + 'path': ('{server}/emby/Users/{userid}/Items/Latest' + + '?ParentId=' + item.get("Id") + + '&Limit={ItemLimit}' + + '&IsVirtualUnaired=false' + + '&IsMissing=False' + + '&Fields=' + detailsString + + '&SortBy=DateCreated' + + '&SortOrder=Descending' + + '&Filters=IsUnplayed' + + '&Recursive=true' + + '&IncludeItemTypes=Episode' + + '&ImageTypeLimit=1' + + '&format=json'), + 'media_type': 'Episodes', + 'name_format': 'Episode|episode_name_format'}) collections.append({ 'title': item_name + i18n('_recently_added'), 'thumbnail': downloadUtils.getArtwork(item, "Primary", server=server), @@ -252,7 +270,7 @@ def getCollections(detailsString): '&ImageTypeLimit=1' + '&format=json'), 'media_type': 'Episodes', - 'name_format': 'episode_name_format'}) + 'name_format': 'Episode|episode_name_format'}) collections.append({ 'title': item_name + i18n('_next_up'), 'thumbnail': downloadUtils.getArtwork(item, "Primary", server=server), @@ -268,7 +286,7 @@ def getCollections(detailsString): '&ImageTypeLimit=1' + '&format=json'), 'media_type': 'Episodes', - 'name_format': 'episode_name_format'}) + 'name_format': 'Episode|episode_name_format'}) if collection_type == "movies": collections.append({ @@ -423,6 +441,25 @@ def getCollections(detailsString): collections.append(item_data) item_data = {} + item_data['title'] = i18n('tvshows_latest') + item_data['media_type'] = 'Episodes' + item_data['path'] = ('{server}/emby/Users/{userid}/Items/Latest' + + '?Limit={ItemLimit}' + + '&Recursive=true' + + '&GroupItems=true' + + '&SortBy=DateCreated' + + '&Fields=' + detailsString + + '&SortOrder=Descending' + + '&Filters=IsUnplayed' + + '&IsVirtualUnaired=false' + + '&IsMissing=False' + + '&IncludeItemTypes=Episode' + + '&ImageTypeLimit=1' + + '&format=json') + item_data['name_format'] = 'Episode|episode_name_format' + collections.append(item_data) + + item_data = {} item_data['title'] = i18n('episodes_in_progress') item_data['media_type'] = 'Episodes' item_data['path'] = ('{server}/emby/Users/{userid}/Items' + @@ -433,7 +470,7 @@ def getCollections(detailsString): '&IncludeItemTypes=Episode' + '&ImageTypeLimit=1' + '&format=json') - item_data['name_format'] = 'episode_name_format' + item_data['name_format'] = 'Episode|episode_name_format' collections.append(item_data) item_data = {} @@ -451,7 +488,7 @@ def getCollections(detailsString): '&IncludeItemTypes=Episode' + '&ImageTypeLimit=1' + '&format=json') - item_data['name_format'] = 'episode_name_format' + item_data['name_format'] = 'Episode|episode_name_format' collections.append(item_data) item_data = {} @@ -467,7 +504,7 @@ def getCollections(detailsString): '&IncludeItemTypes=Episode' + '&ImageTypeLimit=1' + '&format=json') - item_data['name_format'] = 'episode_name_format' + item_data['name_format'] = 'Episode|episode_name_format' collections.append(item_data) item_data = {} diff --git a/plugin.video.embycon/resources/lib/translation.py b/plugin.video.embycon/resources/lib/translation.py index 5b22f79..4db8939 100644 --- a/plugin.video.embycon/resources/lib/translation.py +++ b/plugin.video.embycon/resources/lib/translation.py @@ -94,5 +94,7 @@ STRINGS = { 'show_clients': 30017, 'tvshows_unwatched': 30279, '_unwatched': 30285, - 'movies_unwatched': 30286 + 'movies_unwatched': 30286, + 'tvshows_latest' : 30287, + '_latest' : 30288 } diff --git a/plugin.video.embycon/service.py b/plugin.video.embycon/service.py index eb38b02..83a1da2 100644 --- a/plugin.video.embycon/service.py +++ b/plugin.video.embycon/service.py @@ -25,8 +25,8 @@ download_utils = DownloadUtils() # auth the service try: download_utils.authenticate() -except Exception, e: - pass +except Exception as error: + log.error("Error with initial service auth: " + str(error)) def hasData(data): @@ -288,6 +288,7 @@ class Service(xbmc.Player): monitor = Service() last_progress_update = time.time() +download_utils.checkVersion() xbmc_monitor = xbmc.Monitor() while not xbmc_monitor.abortRequested(): |