Skip to content

Commit

Permalink
2.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz89B committed Aug 9, 2021
1 parent a930d12 commit 6f584da
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
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.1.6" name="Viaplay" provider-name="emilsvennesson">
<addon id="plugin.video.viaplay" version="2.1.7" name="Viaplay" provider-name="emilsvennesson">
<requires>
<import addon="script.module.requests" version="2.9.1" />
<import addon="script.module.iso8601" version="0.1.11" />
Expand All @@ -16,7 +16,7 @@
<description lang="nb_NO">Se innhold fra Viaplay.</description>
<description lang="sv_SE">Titta på innehåll från Viaplay.</description>
<description lang="pl_PL">Oglądaj treści z Viaplay.</description>
<news>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>2021.08.09 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</language>
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2021.08.09 v.2.1.7
+ Fixed M3U playlist generator @Mariusz89B

2021.08.09 v.2.1.6
+ Added M3U playlist generator @Mariusz89B

Expand Down
14 changes: 9 additions & 5 deletions resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def generate_m3u():
elif country_id == '2':
chann = 'kanaler'
elif country_id == '3':
chann = 'kanavia'
chann = 'channels'
elif country_id == '4':
chann = 'channels'

Expand All @@ -86,20 +86,23 @@ def generate_m3u():
response = helper.vp.make_request(url=url, method='get')
channels_block = response['_embedded']['viaplay:blocks'][0]['_embedded']['viaplay:blocks']
channels = [x['viaplay:channel']['content']['title'] for x in channels_block]
guids = [x['viaplay:channel']['_embedded']['viaplay:products'][1]['system']['guid'] for x in channels_block]
guids = [x['viaplay:channel']['_embedded']['viaplay:products'][1]['epg']['channelGuids'][0] for x in channels_block]

for i in range(len(channels)):
title = channels[i] + ' ' + helper.get_country_code().upper()
try:
title = capitalize(title.replace('-poland', '').replace('-', ' '))
except:
pass
guid = guids[i] + '-' + helper.get_country_code().upper()

guid = guids[i]
data += '#EXTINF:-1,%s\nplugin://plugin.video.viaplay/play?guid=%s&url=None&tve=true\n' % (title, guid)

f = xbmcvfs.File(path + file_name, 'w')
f.write(data)
f = xbmcvfs.File(path + file_name, 'wb')
if sys.version_info[0] > 2:
f.write(data)
else:
f.write(bytearray(data, 'utf-8'))
f.close()
xbmcgui.Dialog().notification('Viaplay', helper.language(30064), xbmcgui.NOTIFICATION_INFO)

Expand Down Expand Up @@ -195,6 +198,7 @@ def sport():
helper.add_item(i['title'], plugin.url_for(list_products, url=i['_links']['self']['href']))
helper.eod()


@plugin.route('/channels')
def channels():
channels_dict = helper.vp.get_channels(plugin.args['url'][0])
Expand Down
17 changes: 17 additions & 0 deletions resources/lib/viaplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,25 @@ def log_out(self):
def get_stream(self, guid, pincode=None, tve='false'):
"""Return a dict with the stream URL:s and available subtitle URL:s."""
stream = {}

if 'ch-' in guid:
country_code = self.get_country_code()
url = 'https://epg.viaplay.{c1}/xdk-{c2}/channel/{guid}/'.format(c1=country_code, c2=country_code,guid=guid)
response = self.make_request(url=url, method='get')['_embedded']['viaplay:products']

for i in response:
start_time_obj = self.parse_datetime(i['epg']['startTime'], localize=True)
end_time_obj = self.parse_datetime(i['epg']['endTime'], localize=True)

now = datetime.now()
date_today = now.date()

if start_time_obj <= now <= end_time_obj:
guid = i['system']['guid'] + '-' + country_code.upper()

#url = 'https://play.viaplay.%s/api/stream/byguid' % self.country
url = 'https://play.viaplay.%s/api/stream/bymediaguid' % self.country

params = {
'deviceId': self.get_deviceid(),
'deviceName': 'web',
Expand Down

0 comments on commit 6f584da

Please sign in to comment.