Skip to content

Commit a8fef61

Browse files
committed
update and rename to Magentasport
use online sports category images fix crash issue with live stream shortcut in Leia remove single event category shortcut, fixes playback issue show error dialog on authentication failure some minor code cleanup
1 parent 81168a1 commit a8fef61

30 files changed

Lines changed: 67 additions & 130 deletions

addon.xml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<addon id="plugin.video.telekomsport" name="Telekom Sport" version="1.2.2" provider-name="hubsif">
2+
<addon id="plugin.video.magentasport" name="Magenta Sport" version="2.0.0" provider-name="hubsif">
33
<requires>
44
<import addon="xbmc.python" version="2.5.0"/>
55
</requires>
@@ -9,16 +9,22 @@
99
<extension point="xbmc.addon.metadata">
1010
<platform>all</platform>
1111
<license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
12-
<summary lang="de">Telekom Sport</summary>
13-
<summary lang="en">Telekom Sports</summary>
14-
<description lang="de">Erlebe die große Welt des Sports. Fußball, Eishockey, Basketball und mehr live und auf Abruf. Alle Wettbewerbe in bester HD-Qualität.</description>
15-
<description lang="en">Experience the big world of sports. Soccer, Ice Hockey, Basketball and more live and on demand. All competitions in best HD quality.</description>
16-
<description lang="he">לחוות את העולם הגדול של הספורט. כדורגל, הוקי קרח, כדורסל ועוד לצפות לפי דרישה. כל התחרויות באיכות HD הטובה ביותר.</description>
12+
<summary lang="de">Magenta Sport</summary>
13+
<summary lang="en">Magenta Sport</summary>
14+
<description lang="de">Bei MagentaSport mit Sky Sport Kompakt sehen Sie die Original Sky Konferenzen der Fußball-Bundesliga und der UEFA Champions League sowie alle Spiele der DKB Handball-Bundesliga. Dazu alle Spiele der 3. Liga, der Deutschen Eishockey Liga, der easyCredit Basketball Bundesliga und vieles mehr.</description>
15+
<description lang="en">At MagentaSport with Sky Sport Kompakt you can watch the original Sky Conferences of the German Bundesliga and the UEFA Champions League as well as all matches of the DKB Handball Bundesliga. Also all games of the 3rd league, the German Ice Hockey League, the easyCredit Basketball Bundesliga and much more.</description>
1716
<assets>
18-
<icon>icon.png</icon>
19-
<fanart>fanart.jpg</fanart>
17+
<icon>resources/icon.png</icon>
18+
<fanart>resources/fanart.jpg</fanart>
2019
</assets>
2120
<news>
21+
v2.0.0 (2019-01-16)
22+
- update and rename to Magentasport
23+
- use online sports category images
24+
- fix crash issue with live stream shortcut in Leia
25+
- remove single event category shortcut, fixes playback issue
26+
- show error dialog on authentication failure
27+
- some minor code cleanup
2228
v1.2.2 (2018-08-27)
2329
- fix playback issue with Kodi Leia (thanks to egolus)
2430
- use inputstream for Kodi Leia (thanks to MRLB)

default.py

Lines changed: 45 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,24 @@
2727
from datetime import datetime
2828
from random import randint
2929

30-
_addon_id = 'plugin.video.telekomsport'
30+
_addon_id = 'plugin.video.magentasport'
3131
_addon = xbmcaddon.Addon(id=_addon_id)
3232
_addon_name = _addon.getAddonInfo('name')
3333
_addon_handler = int(sys.argv[1])
3434
_addon_url = sys.argv[0]
3535
_addon_path = xbmc.translatePath(_addon.getAddonInfo("path") )
3636
__language__ = _addon.getLocalizedString
37-
_icons_path = _addon_path + "/resources/icons/"
38-
_fanart_path = _addon_path + "/resources/fanart/"
37+
#_icons_path = _addon_path + "/resources/icons/"
38+
#_fanart_path = _addon_path + "/resources/fanart/"
3939

40-
xbmcplugin.setContent(_addon_handler, 'movies')
40+
xbmcplugin.setContent(_addon_handler, 'episodes')
4141

42-
base_url = "https://www.telekomsport.de/api/v1"
42+
base_url = "https://www.magentasport.de/api/v2"
43+
base_image_url = "https://www.magentasport.de"
4344
oauth_url = "https://accounts.login.idm.telekom.com/oauth2/tokens"
44-
jwt_url = "https://www.telekomsport.de/service/auth/app/login/jwt"
45-
heartbeat_url = "https://www.telekomsport.de/service/heartbeat"
46-
stream_url = "https://www.telekomsport.de/service/player/streamAccess"
45+
jwt_url = "https://www.magentasport.de/service/auth/app/login/jwt"
46+
heartbeat_url = "https://www.magentasport.de/service/heartbeat"
47+
stream_url = "https://www.magentasport.de/service/player/streamAccess"
4748
main_page = "/navigation"
4849

4950
###########
@@ -119,41 +120,12 @@ def getMain():
119120
li.setArt({'fanart': jsonLive['data']['metadata']['web']['image']})
120121
xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li, isFolder=True)
121122

122-
# get sports categories
123-
def addMainDirectoryItem(content, title):
123+
for content in jsonResult['data']['league_filter']:
124124
url = build_url({'mode': content['target_type'], content['target_type']: content['target']})
125-
icon = "bla"
126-
if 'BBL' in content['title']:
127-
icon = 'bbl'
128-
elif 'EuroLeague' in content['title']:
129-
icon = 'euroleague'
130-
elif 'EuroBasket' in content['title']:
131-
icon = 'eurobasket'
132-
elif 'Deutsche Eishockey Liga' in content['title']:
133-
icon = 'del'
134-
elif '3. Liga' in content['title']:
135-
icon = '3.liga'
136-
elif 'Frauen-Bundesliga' in content['title']:
137-
icon = 'frauen-bundesliga'
138-
elif 'Bayern.tv' in content['title']:
139-
icon = 'fcbtv'
140-
elif u'Fußball-Bundesliga' in content['title']:
141-
icon = 'bundesliga'
142-
elif 'UEFA Champions League' in content['title']:
143-
icon = 'uefa'
144-
elif 'Handball-Bundesliga' in content['title']:
145-
icon = 'hbl'
146-
li = xbmcgui.ListItem(title)
147-
li.setArt({'poster': _icons_path + icon + '.png', 'fanart': _fanart_path + icon + '.jpg'})
125+
li = xbmcgui.ListItem(content['title'])
126+
li.setArt({'icon': base_image_url + content['logo'], 'fanart': base_image_url + content['logo']})
148127
xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li, isFolder=True)
149128

150-
for content in jsonResult['data']['filter']:
151-
if content['children']:
152-
for child in content['children']:
153-
addMainDirectoryItem(child, content['title'] + ' - ' + child['title'])
154-
else:
155-
addMainDirectoryItem(content, content['title'])
156-
157129
xbmcplugin.endOfDirectory(_addon_handler)
158130

159131

@@ -203,7 +175,6 @@ def geteventLane():
203175
xbmcplugin.addDirectoryItem(handle=_addon_handler, url="", listitem=li)
204176
eventday = scheduled_start.date()
205177

206-
url = build_url({'mode': 'event', 'event': event['target']})
207178
title = __language__(30003)
208179
if event['metadata']['title']:
209180
title = event['metadata']['title']
@@ -213,15 +184,17 @@ def geteventLane():
213184
elif event['metadata']['description_bold']:
214185
title = event['metadata']['description_bold']
215186
eventinfo = event['metadata']['description_bold'] + ' - ' + event['metadata']['description_regular']
216-
li = xbmcgui.ListItem('[B]' + title + '[/B] (' + eventinfo + ')', iconImage='https://www.telekomsport.de' + event['metadata']['images']['editorial'])
187+
li = xbmcgui.ListItem('[B]' + title + '[/B] (' + eventinfo + ')', iconImage=base_image_url + event['metadata']['images']['editorial'])
217188
li.setInfo('video', {'plot': prettydate(scheduled_start)})
218-
li.setProperty('fanart_image', 'https://www.telekomsport.de' + event['metadata']['images']['editorial'])
189+
li.setProperty('fanart_image', base_image_url + event['metadata']['images']['editorial'])
219190

220191
if event['metadata']['state'] == 'live':
221192
li.setProperty('IsPlayable', 'true')
222193
li.setInfo('video', {})
194+
url = build_url({'mode': 'event', 'event': event['target'], 'live': True})
223195
xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li)
224196
elif not ('onlylive' in args and args['onlylive']):
197+
url = build_url({'mode': 'event', 'event': event['target']})
225198
xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li, isFolder=True)
226199

227200
xbmcplugin.endOfDirectory(_addon_handler)
@@ -237,34 +210,25 @@ def getevent():
237210
else:
238211
xbmcgui.Dialog().ok(_addon_name, __language__(30002))
239212
xbmcplugin.endOfDirectory(_addon_handler, succeeded=False)
213+
elif 'live' in args and args['live']:
214+
if jsonResult['data']['content'][0]['group_elements'][0]['type'] == 'player':
215+
eventVideo = jsonResult['data']['content'][0]['group_elements'][0]['data'][0]
216+
global args
217+
args = {'videoid': eventVideo['videoID'], 'isPay': 'True' if ('pay' in eventVideo and eventVideo['pay']) else 'False'}
218+
getvideo()
240219
else:
241-
hasEventVideos = 0
242-
for content in jsonResult['data']['content']:
220+
for index, content in enumerate(jsonResult['data']['content']):
243221
for group_element in content['group_elements']:
244222
if group_element['type'] == 'eventVideos':
245223
for eventVideo in group_element['data']:
246-
hasEventVideos += 1
247-
248-
if jsonResult['data']['content'][0]['group_elements'][0]['type'] == 'player' and (not hasEventVideos or (hasEventVideos == 1 and jsonResult['data']['content'][0]['group_elements'][0]['data'][0]['videoID'] == jsonResult['data']['content'][1]['group_elements'][0]['data'][0]['videoID'])):
249-
isLivestream = 'islivestream' in jsonResult['data']['content'][0]['group_elements'][0]['data'][0] and jsonResult['data']['content'][0]['group_elements'][0]['data'][0]['islivestream']
250-
isPay = 'pay' in jsonResult['data']['content'][0]['group_elements'][0]['data'][0] and jsonResult['data']['content'][0]['group_elements'][0]['data'][0]['pay']
251-
url = build_url({'mode': 'video', 'videoid': jsonResult['data']['content'][0]['group_elements'][0]['data'][0]['videoID'], 'isLivestream': isLivestream, 'isPay': isPay})
252-
xbmc.Player().play(url)
253-
xbmcplugin.endOfDirectory(_addon_handler, succeeded=False)
254-
else:
255-
for content in jsonResult['data']['content']:
256-
for group_element in content['group_elements']:
257-
if group_element['type'] == 'eventVideos':
258-
for eventVideo in group_element['data']:
259-
isLivestream = 'isLivestream' in eventVideo and eventVideo['isLivestream']
260-
isPay = 'pay' in eventVideo and eventVideo['pay']
261-
url = build_url({'mode': 'video', 'videoid': eventVideo['videoID'], 'isLivestream': isLivestream, 'isPay': isPay})
262-
li = xbmcgui.ListItem(eventVideo['title'], iconImage='https://www.telekomsport.de' + eventVideo['images']['editorial'])
263-
li.setProperty('fanart_image', 'https://www.telekomsport.de' + eventVideo['images']['editorial'])
264-
li.setProperty('IsPlayable', 'true')
265-
li.setInfo('video', {})
266-
xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li)
267-
xbmcplugin.endOfDirectory(_addon_handler)
224+
isPay = 'pay' in eventVideo and eventVideo['pay']
225+
url = build_url({'mode': 'video', 'videoid': eventVideo['videoID'], 'isPay': isPay})
226+
li = xbmcgui.ListItem(eventVideo['title'], iconImage=base_image_url + eventVideo['images']['editorial'])
227+
li.setProperty('fanart_image', base_image_url + eventVideo['images']['editorial'])
228+
li.setProperty('IsPlayable', 'true')
229+
li.setInfo('video', {})
230+
xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li)
231+
xbmcplugin.endOfDirectory(_addon_handler)
268232

269233
def getvideo():
270234
videoid = args['videoid']
@@ -276,14 +240,27 @@ def getvideo():
276240
_addon.openSettings()
277241
return
278242
else:
279-
jwt = get_jwt(_addon.getSetting('username'), _addon.getSetting('password'))
243+
try:
244+
jwt = get_jwt(_addon.getSetting('username'), _addon.getSetting('password'))
245+
except urllib2.HTTPError, e:
246+
response = json.loads(e.read())
247+
msg = __language__(30005)
248+
if 'error_description' in response:
249+
msg += '\n\n'
250+
msg += __language__(30011)
251+
msg += '\n"' + response['error_description'] + '"'
252+
xbmcgui.Dialog().ok(_addon_name, msg)
253+
xbmcplugin.setResolvedUrl(_addon_handler, False, xbmcgui.ListItem())
254+
return
280255
if jwt:
281256
auth_response = auth_media(jwt, videoid)
282257
if auth_response != "success":
283258
xbmcgui.Dialog().ok(_addon_name, auth_response)
259+
xbmcplugin.setResolvedUrl(_addon_handler, False, xbmcgui.ListItem())
284260
return
285261
else:
286262
xbmcgui.Dialog().ok(_addon_name, __language__(30005))
263+
xbmcplugin.setResolvedUrl(_addon_handler, False, xbmcgui.ListItem())
287264
return
288265

289266
jwt = jwt or 'empty'

fanart.jpg

-335 KB
Binary file not shown.

icon.png

-14.5 KB
Binary file not shown.

resources/fanart.jpg

247 KB
Loading

resources/fanart/3.liga.jpg

-172 KB
Binary file not shown.

resources/fanart/bbl.jpg

-170 KB
Binary file not shown.

resources/fanart/bundesliga.jpg

-479 KB
Binary file not shown.

resources/fanart/del.jpg

-202 KB
Binary file not shown.

resources/fanart/eurobasket.jpg

-245 KB
Binary file not shown.

0 commit comments

Comments
 (0)