Skip to content

Commit 0c251f6

Browse files
authored
Merge pull request #2332 from goggle/srgssr_2.2.1
[script.module.srgssr] 2.2.1
2 parents b8e8697 + 379706d commit 0c251f6

File tree

3 files changed

+65
-6
lines changed

3 files changed

+65
-6
lines changed

script.module.srgssr/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ Currently, these Kodi plugins use `script.module.srgssr`:
66

77
* [plugin.video.srfplaytv](https://github.com/goggle/plugin.video.srfplaytv)
88
* [plugin.video.rtsplaytv](https://github.com/goggle/plugin.video.rtsplaytv)
9-
* [plugin.video.rsiplaytv](https://github.com/goggle/plugin.video.rsiplaytv)
9+
* [plugin.video.rsiplaytv](https://github.com/goggle/plugin.video.rsiplaytv)
10+
* [plugin.video.swiplaytv](https://github.com/goggle/plugin.video.swiplaytv)

script.module.srgssr/addon.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.module.srgssr" name="SRG SSR" version="2.2.0" provider-name="Alexander Seiler">
2+
<addon id="script.module.srgssr" name="SRG SSR" version="2.2.1" provider-name="Alexander Seiler">
33
<requires>
44
<import addon="xbmc.python" version="3.0.0"/>
55
<import addon="script.module.inputstreamhelper" version="0.5.10"/>

script.module.srgssr/lib/srgssr.py

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,10 +906,68 @@ def build_date_menu(self, date_string):
906906
"""
907907
self.log(f'build_date_menu, date_string = {date_string}')
908908

909-
# API v3 use the date in sortable format, i.e. year first
909+
# Note: We do not use `build_menu_apiv3` here because the structure
910+
# of the response is quite different from other typical responses.
911+
# If it is possible to integrate this into `build_menu_apiv3` without
912+
# too many changes, it might be a good idea.
913+
mode = 60
910914
elems = date_string.split('-')
911-
query = f'videos-by-date/{elems[2]}-{elems[1]}-{elems[0]}'
912-
return self.build_menu_apiv3(query)
915+
query = (f'tv-program-guide?date={elems[2]}-{elems[1]}-{elems[0]}'
916+
f'&businessUnits={self.bu}')
917+
js = json.loads(self.open_url(self.apiv3_url + query))
918+
data = utils.try_get(js, 'data', list, [])
919+
for item in data:
920+
if not isinstance(item, dict):
921+
continue
922+
channel = utils.try_get(
923+
item, 'channel', data_type=dict, default={})
924+
name = utils.try_get(channel, 'title')
925+
if not name:
926+
continue
927+
image = utils.try_get(channel, 'imageUrl')
928+
list_item = xbmcgui.ListItem(label=name)
929+
list_item.setProperty('IsPlayable', 'false')
930+
list_item.setArt({'thumb': image, 'fanart': image})
931+
channel_date_id = name.replace(' ', '-') + '_' + date_string
932+
cache_id = self.addon_id + '.' + channel_date_id
933+
programs = utils.try_get(
934+
item, 'programList', data_type=list, default=[])
935+
self.cache.set(cache_id, programs)
936+
self.log(f'build_date_menu: Cache set with id = {cache_id}')
937+
url = self.build_url(mode=mode, name=cache_id)
938+
xbmcplugin.addDirectoryItem(
939+
handle=self.handle, url=url, listitem=list_item, isFolder=True)
940+
941+
def build_specific_date_menu(self, cache_id):
942+
"""
943+
Builds a list of available videos from a specific channel
944+
and specific date given by cache_id from `build_date_menu`.
945+
946+
Keyword arguments:
947+
cache_id -- cache id set by `build_date_menu`
948+
"""
949+
self.log(f'build_specific_date_menu, cache_id = {cache_id}')
950+
program_list = self.cache.get(cache_id)
951+
952+
# videos might be listed multiple times, but we only
953+
# want them a single time:
954+
already_seen = set()
955+
for pitem in program_list:
956+
media_urn = utils.try_get(pitem, 'mediaUrn')
957+
if not media_urn or 'video' not in media_urn:
958+
continue
959+
if media_urn in already_seen:
960+
continue
961+
already_seen.add(media_urn)
962+
name = utils.try_get(pitem, 'title')
963+
image = utils.try_get(pitem, 'imageUrl')
964+
subtitle = utils.try_get(pitem, 'subtitle')
965+
list_item = xbmcgui.ListItem(label=name)
966+
list_item.setInfo('video', {'plotoutline': subtitle})
967+
list_item.setArt({'thumb': image, 'fanart': image})
968+
url = self.build_url(mode=100, name=media_urn)
969+
xbmcplugin.addDirectoryItem(
970+
handle=self.handle, url=url, listitem=list_item, isFolder=True)
913971

914972
def build_search_menu(self):
915973
"""
@@ -1321,7 +1379,7 @@ def read_searches(self, filename):
13211379
with open(file_path, 'r') as f:
13221380
json_file = json.load(f)
13231381
try:
1324-
return[entry['search'] for entry in json_file]
1382+
return [entry['search'] for entry in json_file]
13251383
except KeyError:
13261384
self.log(f'Unexpected file structure for {filename}.')
13271385
return []

0 commit comments

Comments
 (0)