Skip to content

Commit

Permalink
2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz89B committed Oct 6, 2021
1 parent 8502b48 commit cf236d9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 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.2.0" name="Viaplay" provider-name="emilsvennesson">
<addon id="plugin.video.viaplay" version="2.2.1" 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.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>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</language>
Expand Down
55 changes: 35 additions & 20 deletions resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def list_products(url=None, search_query=None):
elif product['type'] == 'tvEvent':
add_tv_event(product)
elif product['type'] == 'clip':
add_tv_event(product)
add_event(product)
else:
helper.log('product type: {0} is not (yet) supported.'.format(product['type']))
return False
Expand Down Expand Up @@ -462,18 +462,9 @@ def add_sports_event(event):
def add_tv_event(event):
now = datetime.now()
date_today = now.date()
is_time = True

try:
start_time_obj = helper.vp.parse_datetime(event['epg']['startTime'], localize=True)
except:
start_time_obj = helper.vp.parse_datetime(str(datetime.now()), localize=True)
is_time = False
try:
end_time_obj = helper.vp.parse_datetime(event['epg']['endTime'], localize=True)
except:
end_time_obj = helper.vp.parse_datetime(str(datetime.now()), localize=True)
is_time = False
start_time_obj = helper.vp.parse_datetime(event['epg']['startTime'], localize=True)
end_time_obj = helper.vp.parse_datetime(event['epg']['endTime'], localize=True)

event_status = helper.vp.get_event_status(event)

Expand All @@ -487,14 +478,13 @@ def add_tv_event(event):
if status:
# hide non-available catchup items
start_time = str(datetime.now())[:-16]
if is_time:
if now > helper.vp.parse_datetime(event['system']['catchupAvailability']['end'], localize=True):
return

if date_today == start_time_obj.date():
start_time = '{0} {1}'.format(helper.language(30027), start_time_obj.strftime('%H:%M'))
else:
start_time = start_time_obj.strftime('%Y-%m-%d %H:%M')
if now > helper.vp.parse_datetime(event['system']['catchupAvailability']['end'], localize=True):
return

if date_today == start_time_obj.date():
start_time = '{0} {1}'.format(helper.language(30027), start_time_obj.strftime('%H:%M'))
else:
start_time = start_time_obj.strftime('%Y-%m-%d %H:%M')

if event_status != 'upcoming':
plugin_url = plugin.url_for(play, guid=event['system']['guid'] + '-%s' % helper.get_country_code().upper(), url=None, tve='true')
Expand All @@ -519,13 +509,38 @@ def add_tv_event(event):
'year': details['production'].get('year'),
'list_title': '[B]{0}:[/B] {1}'.format(coloring(start_time, event_status), title)
}

art = {
'thumb': event['content']['images']['landscape']['template'].split('{')[0] if 'landscape' in details['images'] else None,
'fanart': event['content']['images']['landscape']['template'].split('{')[0] if 'landscape' in details['images'] else None
}

helper.add_item(event_info['list_title'], plugin_url, playable=playable, info=event_info, art=art, content='episodes')

def add_event(event):
plugin_url = plugin.url_for(play, guid=event['system']['guid'], url=None, tve='false')

details = event['content']

if sys.version_info[0] > 2:
title = details.get('title')
else:
title = details.get('title').encode('utf-8')

event_info = {
'mediatype': 'video',
'title': details.get('title'),
'plot': details.get('synopsis'),
'year': details['production'].get('year'),
'list_title': '{0}'.format(title)
}

art = {
'thumb': event['content']['images']['landscape']['template'].split('{')[0] if 'landscape' in details['images'] else None,
'fanart': event['content']['images']['landscape']['template'].split('{')[0] if 'landscape' in details['images'] else None
}

helper.add_item(event_info['list_title'], plugin_url, playable=True, info=event_info, art=art, content='episodes')

def add_art(images, content_type):
artwork = {}
Expand Down

0 comments on commit cf236d9

Please sign in to comment.