Skip to content

Commit

Permalink
2.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz89B committed Jan 28, 2022
1 parent 23189df commit 077a6fb
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 47 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# dummy file to init the directory
# dummy file to init the directory
4 changes: 2 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.viaplay" version="2.2.6" name="Viaplay" provider-name="emilsvennesson, mariusz89b">
<addon id="plugin.video.viaplay" version="2.2.7" name="Viaplay" provider-name="emilsvennesson, mariusz89b">
<requires>
<import addon="script.module.requests" version="2.9.1" />
<import addon="script.module.iso8601" version="0.1.11" />
Expand All @@ -17,7 +17,7 @@
<description lang="sv_SE">Titta på innehåll från Viaplay.</description>
<description lang="pl_PL">Oglądaj treści z Viaplay.</description>
<description lang="lt_LT">Žiūrėkite turinį iš Viaplay.</description>
<news>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
<news>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
</news>
<platform>all</platform>
<language>sv dk no fi en pl lt</language>
Expand Down
12 changes: 12 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion default.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from resources.lib import addon

if __name__ == '__main__':
addon.run()
addon.run()
2 changes: 1 addition & 1 deletion resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# dummy file to init the directory
# dummy file to init the directory
68 changes: 41 additions & 27 deletions resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
Expand Down Expand Up @@ -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
Expand All @@ -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()


Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)
25 changes: 12 additions & 13 deletions resources/lib/kodihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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':
Expand Down
15 changes: 13 additions & 2 deletions resources/lib/viaplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import xbmc
import xbmcvfs
import xbmcgui
import xbmcplugin
from xbmcaddon import Addon

class Viaplay(object):
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit 077a6fb

Please sign in to comment.