diff --git a/__init__.py b/__init__.py index b53149b..415c393 100644 --- a/__init__.py +++ b/__init__.py @@ -1 +1 @@ -# dummy file to init the directory +# dummy file to init the directory \ No newline at end of file diff --git a/addon.xml b/addon.xml index 2c0afcb..1f9271e 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@  - + @@ -17,7 +17,7 @@ Titta på innehåll från Viaplay. Oglądaj treści z Viaplay. Žiūrėkite turinį iš Viaplay. - 2022.01.27 v2.2.6[CR]+ Fixed login error[CR][CR]2022.01.25 v2.2.5[CR]+ Fixes[CR][CR]2022.01.23 v2.2.4[CR]+ Fixed external authorization[CR][CR]2021.11.09 v2.2.3[CR]+ Added viaplay.lt[CR][CR]2021.10.24 v2.2.2[CR]+ Fixed plot[CR][CR]2021.10.06 v2.2.1[CR]+ Fixed category sport matches abbreviations[CR][CR]2021.09.29 v2.2.0[CR]+ Fixed subtitles[CR][CR]2021.09.27 v2.1.9[CR]+ Fixed product categories[CR][CR]2021.08.17 v2.1.8[CR]+ Fixed html import error[CR][CR]2021.08.11 v2.1.7[CR]+ Fixed M3U playlist generator[CR][CR]2021.08.09 v2.1.6[CR]+ Added M3U playlist generator[CR][CR]2021.08.08 v2.1.5[CR]+ Added setting "Hide previously aired Live-Tv programmes"[CR][CR]2021.08.07 v2.1.4[CR]+ Added watched and purchased categories for viaplay.pl[CR]+ Fixed category error[CR][CR]2021.08.05 v.2.1.3[CR]+ Added viaplay.pl + 2022.01.27 v2.2.7[CR]+ Fixed logout[CR][CR]2022.01.27 v2.2.6[CR]+ Fixed login error[CR][CR]2022.01.25 v2.2.5[CR]+ Fixes[CR][CR]2022.01.23 v2.2.4[CR]+ Fixed external authorization[CR][CR]2021.11.09 v2.2.3[CR]+ Added viaplay.lt[CR][CR]2021.10.24 v2.2.2[CR]+ Fixed plot[CR][CR]2021.10.06 v2.2.1[CR]+ Fixed category sport matches abbreviations[CR][CR]2021.09.29 v2.2.0[CR]+ Fixed subtitles[CR][CR]2021.09.27 v2.1.9[CR]+ Fixed product categories[CR][CR]2021.08.17 v2.1.8[CR]+ Fixed html import error[CR][CR]2021.08.11 v2.1.7[CR]+ Fixed M3U playlist generator[CR][CR]2021.08.09 v2.1.6[CR]+ Added M3U playlist generator[CR][CR]2021.08.08 v2.1.5[CR]+ Added setting "Hide previously aired Live-Tv programmes"[CR][CR]2021.08.07 v2.1.4[CR]+ Added watched and purchased categories for viaplay.pl[CR]+ Fixed category error[CR][CR]2021.08.05 v.2.1.3[CR]+ Added viaplay.pl all sv dk no fi en pl lt diff --git a/changelog.txt b/changelog.txt index 729088a..5614c98 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,15 @@ +2022.01.28 v.2.2.7 ++ Fixed logout @Mariusz89B + +2022.01.27 v.2.2.6 ++ Fixed login error @Mariusz89B + +2022.01.25 v.2.2.5 ++ Fixes @Mariusz89B + +2022.01.23 v.2.2.4 ++ Fixed external authorization @rysson @notoco + 2021.11.09 v.2.2.3 + Added viaplay.lt @Mariusz89B diff --git a/default.py b/default.py index 88ccab7..eef9260 100644 --- a/default.py +++ b/default.py @@ -2,4 +2,4 @@ from resources.lib import addon if __name__ == '__main__': - addon.run() + addon.run() \ No newline at end of file diff --git a/resources/__init__.py b/resources/__init__.py index b53149b..415c393 100644 --- a/resources/__init__.py +++ b/resources/__init__.py @@ -1 +1 @@ -# dummy file to init the directory +# dummy file to init the directory \ No newline at end of file diff --git a/resources/lib/addon.py b/resources/lib/addon.py index 0849063..550a7ab 100644 --- a/resources/lib/addon.py +++ b/resources/lib/addon.py @@ -31,9 +31,11 @@ def run(): mode = params.get('mode', None) action = params.get('action', '') - gen = params.get('guid', '') + gen = params.get('guid', '') + if action == 'BUILD_M3U': generate_m3u() + elif gen != '': id = params.get('url', '') tve = params.get('tve', '') @@ -166,8 +168,14 @@ def search(): @plugin.route('/vod') def vod(): """List categories and collections from the VOD pages (movies, series, kids, store).""" + from itertools import groupby, chain + from operator import itemgetter + helper.add_item(helper.language(30041), plugin.url_for(categories, url=plugin.args['url'][0])) collections = helper.vp.get_collections(plugin.args['url'][0]) + + add_lst = [] + for i in collections: if i['type'] == 'list-featurebox': # skip feature box for now continue @@ -182,11 +190,29 @@ def vod(): elif 'a6-03' in i['id']: i['title'] = '16+' elif 'a6-04' in i['id']: - i['title'] = 'Filmy' + add_lst.append(i['_links']['self']['href']) + i = None + elif 'cfed1737-7efb-484c-aca9-a851901a6-05' in i['id']: + add_lst.append(i['_links']['self']['href']) + i = None + elif 'cfed1737-7efb-484c-aca9-a851901a6-06' in i['id']: + add_lst.append(i['_links']['self']['href']) + i = None else: i['title'] = '' - helper.add_item(i['title'], plugin.url_for(list_products, url=i['_links']['self']['href'])) + try: + helper.add_item(i['title'], plugin.url_for(list_products, url=i['_links']['self']['href'])) + except: + pass + + ordered_lst = "" + + for url in add_lst: + ordered_lst += url + + helper.add_item('Filmy', plugin.url_for(list_products, url=ordered_lst)) + helper.eod() @@ -247,9 +273,6 @@ def log_out(): confirm = helper.dialog('yesno', helper.language(30042), helper.language(30043)) if confirm: helper.vp.log_out() - # send Kodi back to home screen - xbmc.executebuiltin('XBMC.Container.Update(path, replace)') - xbmc.executebuiltin('XBMC.ActivateWindow(Home)') @plugin.route('/list_products') @@ -590,27 +613,18 @@ def coloring(text, meaning): def show_error(error): - if sys.version_info[0] > 2: - if error == 'UserNotAuthorizedForContentError': - message = helper.language(30020) - elif error == 'PurchaseConfirmationRequiredError': - message = helper.language(30021) - elif error == 'UserNotAuthorizedRegionBlockedError': - message = helper.language(30022) - elif error == 'ConcurrentStreamsLimitReachedError': - message = helper.language(30050) - else: - message = error + if error == 'UserNotAuthorizedForContentError': + message = helper.language(30020) + elif error == 'PurchaseConfirmationRequiredError': + message = helper.language(30021) + elif error == 'UserNotAuthorizedRegionBlockedError': + message = helper.language(30022) + elif error == 'ConcurrentStreamsLimitReachedError': + message = helper.language(30050) + elif error == 'PersistentLoginError': + message = error else: - if error == b'UserNotAuthorizedForContentError': - message = helper.language(30020) - elif error == b'PurchaseConfirmationRequiredError': - message = helper.language(30021) - elif error == b'UserNotAuthorizedRegionBlockedError': - message = helper.language(30022) - elif error == b'ConcurrentStreamsLimitReachedError': - message = helper.language(30050) - else: - message = error + message = error + helper.dialog(dialog_type='ok', heading=helper.language(30017), message=message) \ No newline at end of file diff --git a/resources/lib/kodihelper.py b/resources/lib/kodihelper.py index 84ee2fd..11d3411 100644 --- a/resources/lib/kodihelper.py +++ b/resources/lib/kodihelper.py @@ -93,21 +93,20 @@ def log_out(self): confirm = self.dialog('yesno', self.language(30042), self.language(30043)) if confirm: self.vp.log_out() - # send Kodi back to home screen - xbmc.executebuiltin("Action(Back,%s)" % xbmcgui.getCurrentWindowId()) def authorize(self): - try: - self.vp.validate_session() - return True - except self.vp.ViaplayError as error: - cookie_error = 'MissingSessionCookieError' - login_error = 'PersistentLoginError' + if xbmc.getCondVisibility('!Window.IsVisible(Home)'): + try: + self.vp.validate_session() + return True + except self.vp.ViaplayError as error: + cookie_error = 'MissingSessionCookieError' + login_error = 'PersistentLoginError' - if not error.value == login_error or error.value == cookie_error: - raise - else: - return self.device_registration() + if not error.value == login_error or error.value == cookie_error: + raise + else: + return self.device_registration() def device_registration(self): """Presents a dialog with information on how to activate the device. @@ -199,7 +198,7 @@ def add_item(self, title, url, folder=True, playable=False, info=None, art=None, def eod(self): """Tell Kodi that the end of the directory listing is reached.""" - xbmcplugin.endOfDirectory(self.handle) + xbmcplugin.endOfDirectory(self.handle, cacheToDisc=False) def play(self, guid=None, url=None, pincode=None, tve='false'): if url and url != 'None': diff --git a/resources/lib/viaplay.py b/resources/lib/viaplay.py index 7dbf89d..bee21a0 100644 --- a/resources/lib/viaplay.py +++ b/resources/lib/viaplay.py @@ -24,6 +24,7 @@ import xbmc import xbmcvfs import xbmcgui +import xbmcplugin from xbmcaddon import Addon class Viaplay(object): @@ -212,8 +213,18 @@ def log_out(self): params = { 'deviceKey': self.device_key } - self.make_request(url=url, method='get', params=params) - return True + + res = self.make_request(url=url, method='get', params=params) + if res: + cookie_file = os.path.join(self.settings_folder, 'cookie_file') + if os.path.exists(cookie_file): + os.remove(cookie_file) + + xbmc.executebuiltin('Container.Update') + + xbmc.executebuiltin("Dialog.Close(all, true)") + xbmc.executebuiltin("ActivateWindow(Home)") + def get_stream(self, guid, pincode=None, tve='false'): """Return a dict with the stream URL:s and available subtitle URL:s."""