From cef1194373fe48df7c862344eb63e99567768e54 Mon Sep 17 00:00:00 2001 From: Tomas Melin Date: Mon, 20 Jun 2016 00:10:14 +0300 Subject: [PATCH] Add warning message for user when listing geo restricted material Provides error message gotten as response from api while requesting a stream not accessible in the current region. Signed-off-by: Tomas Melin --- addon.py | 2 ++ mtgapi.py | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/addon.py b/addon.py index 80fc314..2330b6d 100644 --- a/addon.py +++ b/addon.py @@ -154,6 +154,8 @@ def listEpisodes(self, episodes_url): url = streams['medium'] elif 'low' in streams and streams['low'] is not None: url = streams['low'] + elif 'msg' in streams and streams['msg'] is not None: + return items.append((url, item)) xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_EPISODE) diff --git a/mtgapi.py b/mtgapi.py index 49fad17..758f31a 100644 --- a/mtgapi.py +++ b/mtgapi.py @@ -15,6 +15,7 @@ import urllib2 try: import xbmc + import xbmcgui except: class xbmc(object): @staticmethod @@ -59,6 +60,13 @@ def _http_request(self, url): content = connection.read() connection.close() return content + except urllib2.HTTPError, e: + data = e.read() + reason = json.loads(data.decode('iso-8859-1').encode('utf-8')) + xbmcgui.Dialog().ok(("HTTP Error: " + str(e.code) + " " + e.reason), + reason['msg']) + return data + except Exception as ex: raise JsonApiException(ex) @@ -225,7 +233,7 @@ def get_streams(self, episode): try: return data['streams'] except: - return {} + return data @staticmethod def test():