Skip to content

Commit

Permalink
solution to channels not working in EU (#94)
Browse files Browse the repository at this point in the history
* fix for live channels not working in EU
* fixed the re-cache json api call issue
  • Loading branch information
TermeHansen authored Mar 30, 2024
1 parent fbf87de commit d6431e3
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 250 deletions.
5 changes: 4 additions & 1 deletion 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.drnu" version="6.4.0" name="DR TV" provider-name="TermeHansen">
<addon id="plugin.video.drnu" version="6.4.1" name="DR TV" provider-name="TermeHansen">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.dateutil" version="2.8.2" />
Expand Down Expand Up @@ -32,6 +32,9 @@
<screenshot>resources/media/Screenshot3.jpg</screenshot>
<screenshot>resources/media/Screenshot4.jpg</screenshot>
</assets>
<news>[B]Version 6.4.1 - 2024-03-29[/B]
- Fix live channels not working from EU
</news>
<news>[B]Version 6.4.0 - 2024-03-19[/B]
- add the new Gensyn area
- change Ultra area to not be kids area
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[B]Version 6.4.1 - 2024-03-29[/B]
- Fix live channels not working from EU

[B]Version 6.4.0 - 2024-03-19[/B]
- add the new Gensyn area
- change Ultra area to not be kids area
Expand Down
7 changes: 4 additions & 3 deletions resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def kodi_item(self, item, is_season=False):
icon_file = str(resources_path/'icons/gensyn.png')
listItem.setArt({'fanart': self.fanart_image, 'icon': icon_file})

log(f'{title} -- {item["id"]} | {item["type"]} | {item.get("path")}', level=2)
log(f'{title} -- {item["id"]} | {item["type"]} | {item.get("path")}', level=1)
if item.get('in_mylist', False):
runScript = f"RunPlugin(plugin://plugin.video.drnu/?delfavorite={item['id']})"
menuItems.append((tr(30010), runScript))
Expand Down Expand Up @@ -588,8 +588,9 @@ def route(self, query):
self.api.recache_items(clear_expired=True, progress=progress)
progress.update(100)
progress.close()
if PARAMS['re-cache'] == 2:
xbmc.executebuiltin('ActivateWindow(Home)')
if PARAMS['re-cache'] == '2':
self.showSimpleAreaSelector()
xbmc.executebuiltin('ActivateWindow(home)')

else:
area = int(get_setting('area'))
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/cronjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"method": "Addons.ExecuteAddon",
"params": {
"addonid": "plugin.video.drnu",
"params": ["?reCache=2"]
"params": ["?re-cache=2"]
},
"id": "1"
}
Expand Down
18 changes: 13 additions & 5 deletions resources/lib/tvapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ def get_programcard(self, path, data=None, use_cache=True):
'item_detail_expand': 'all',
'list_page_size': '24',
'max_list_prefetch': '3',
'path': path
'path': path,
'sub': 'Registered'
}
return self._request_get(url, params=data, use_cache=use_cache)

Expand Down Expand Up @@ -476,7 +477,7 @@ def get_stream(self, id):
'ff': 'idp,ldp,rpt',
'lang': 'da',
'resolution': 'HD-1080',
'sub': 'Anonymous'
'sub': 'Registered'
}

u = self.session.get(url, params=data, headers=headers, timeout=GET_TIMEOUT)
Expand Down Expand Up @@ -534,11 +535,18 @@ def get_livestream(self, path, with_subtitles=False):
}
return stream

def get_channel_url(self, channel, with_subtitles=False):
def get_channel_url(self, channel, with_subtitles=False, use_cache=True):
id = channel['item']['id']
url = URL + f'/channels/{id}/liveStreams?'
headers = {"X-Authorization": f'Bearer {self.profile_token()}'}
js = self._request_get(url, headers=headers, use_cache=use_cache)
links = {item['type']:item['link'] for item in js}

EU = 'Eu' if 'hlsURLEu' in links else ''
if with_subtitles:
url = channel['item']['customFields']['hlsWithSubtitlesURL']
url = links['hlsWithSubtitlesURL' + EU]
else:
url = channel['item']['customFields']['hlsURL']
url = links['hlsURL' + EU]
return url

def get_title(self, item):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_gensyn(capsys):
handle.route(items2[4]['url'])
episodes = [iteminfo(item) for item in get_items().values()]
# print(episodes[1])
assert episodes[1]['info']['title'] == 'Casper & Mandrilaftalen 1'
assert episodes[1]['info']['title'] == 'Hvaffor en hånd 1994'


def test_a_aa(capsys):
Expand Down
Loading

0 comments on commit d6431e3

Please sign in to comment.