Skip to content

Commit

Permalink
update and rename to Magentasport
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hubsif committed Jan 16, 2019
1 parent 81168a1 commit a8fef61
Show file tree
Hide file tree
Showing 30 changed files with 67 additions and 130 deletions.
22 changes: 14 additions & 8 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.telekomsport" name="Telekom Sport" version="1.2.2" provider-name="hubsif">
<addon id="plugin.video.magentasport" name="Magenta Sport" version="2.0.0" provider-name="hubsif">
<requires>
<import addon="xbmc.python" version="2.5.0"/>
</requires>
Expand All @@ -9,16 +9,22 @@
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
<summary lang="de">Telekom Sport</summary>
<summary lang="en">Telekom Sports</summary>
<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>
<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>
<description lang="he">לחוות את העולם הגדול של הספורט. כדורגל, הוקי קרח, כדורסל ועוד לצפות לפי דרישה. כל התחרויות באיכות HD הטובה ביותר.</description>
<summary lang="de">Magenta Sport</summary>
<summary lang="en">Magenta Sport</summary>
<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>
<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>
<assets>
<icon>icon.png</icon>
<fanart>fanart.jpg</fanart>
<icon>resources/icon.png</icon>
<fanart>resources/fanart.jpg</fanart>
</assets>
<news>
v2.0.0 (2019-01-16)
- 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
v1.2.2 (2018-08-27)
- fix playback issue with Kodi Leia (thanks to egolus)
- use inputstream for Kodi Leia (thanks to MRLB)
Expand Down
113 changes: 45 additions & 68 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,24 @@
from datetime import datetime
from random import randint

_addon_id = 'plugin.video.telekomsport'
_addon_id = 'plugin.video.magentasport'
_addon = xbmcaddon.Addon(id=_addon_id)
_addon_name = _addon.getAddonInfo('name')
_addon_handler = int(sys.argv[1])
_addon_url = sys.argv[0]
_addon_path = xbmc.translatePath(_addon.getAddonInfo("path") )
__language__ = _addon.getLocalizedString
_icons_path = _addon_path + "/resources/icons/"
_fanart_path = _addon_path + "/resources/fanart/"
#_icons_path = _addon_path + "/resources/icons/"
#_fanart_path = _addon_path + "/resources/fanart/"

xbmcplugin.setContent(_addon_handler, 'movies')
xbmcplugin.setContent(_addon_handler, 'episodes')

base_url = "https://www.telekomsport.de/api/v1"
base_url = "https://www.magentasport.de/api/v2"
base_image_url = "https://www.magentasport.de"
oauth_url = "https://accounts.login.idm.telekom.com/oauth2/tokens"
jwt_url = "https://www.telekomsport.de/service/auth/app/login/jwt"
heartbeat_url = "https://www.telekomsport.de/service/heartbeat"
stream_url = "https://www.telekomsport.de/service/player/streamAccess"
jwt_url = "https://www.magentasport.de/service/auth/app/login/jwt"
heartbeat_url = "https://www.magentasport.de/service/heartbeat"
stream_url = "https://www.magentasport.de/service/player/streamAccess"
main_page = "/navigation"

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

# get sports categories
def addMainDirectoryItem(content, title):
for content in jsonResult['data']['league_filter']:
url = build_url({'mode': content['target_type'], content['target_type']: content['target']})
icon = "bla"
if 'BBL' in content['title']:
icon = 'bbl'
elif 'EuroLeague' in content['title']:
icon = 'euroleague'
elif 'EuroBasket' in content['title']:
icon = 'eurobasket'
elif 'Deutsche Eishockey Liga' in content['title']:
icon = 'del'
elif '3. Liga' in content['title']:
icon = '3.liga'
elif 'Frauen-Bundesliga' in content['title']:
icon = 'frauen-bundesliga'
elif 'Bayern.tv' in content['title']:
icon = 'fcbtv'
elif u'Fußball-Bundesliga' in content['title']:
icon = 'bundesliga'
elif 'UEFA Champions League' in content['title']:
icon = 'uefa'
elif 'Handball-Bundesliga' in content['title']:
icon = 'hbl'
li = xbmcgui.ListItem(title)
li.setArt({'poster': _icons_path + icon + '.png', 'fanart': _fanart_path + icon + '.jpg'})
li = xbmcgui.ListItem(content['title'])
li.setArt({'icon': base_image_url + content['logo'], 'fanart': base_image_url + content['logo']})
xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li, isFolder=True)

for content in jsonResult['data']['filter']:
if content['children']:
for child in content['children']:
addMainDirectoryItem(child, content['title'] + ' - ' + child['title'])
else:
addMainDirectoryItem(content, content['title'])

xbmcplugin.endOfDirectory(_addon_handler)


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

url = build_url({'mode': 'event', 'event': event['target']})
title = __language__(30003)
if event['metadata']['title']:
title = event['metadata']['title']
Expand All @@ -213,15 +184,17 @@ def geteventLane():
elif event['metadata']['description_bold']:
title = event['metadata']['description_bold']
eventinfo = event['metadata']['description_bold'] + ' - ' + event['metadata']['description_regular']
li = xbmcgui.ListItem('[B]' + title + '[/B] (' + eventinfo + ')', iconImage='https://www.telekomsport.de' + event['metadata']['images']['editorial'])
li = xbmcgui.ListItem('[B]' + title + '[/B] (' + eventinfo + ')', iconImage=base_image_url + event['metadata']['images']['editorial'])
li.setInfo('video', {'plot': prettydate(scheduled_start)})
li.setProperty('fanart_image', 'https://www.telekomsport.de' + event['metadata']['images']['editorial'])
li.setProperty('fanart_image', base_image_url + event['metadata']['images']['editorial'])

if event['metadata']['state'] == 'live':
li.setProperty('IsPlayable', 'true')
li.setInfo('video', {})
url = build_url({'mode': 'event', 'event': event['target'], 'live': True})
xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li)
elif not ('onlylive' in args and args['onlylive']):
url = build_url({'mode': 'event', 'event': event['target']})
xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li, isFolder=True)

xbmcplugin.endOfDirectory(_addon_handler)
Expand All @@ -237,34 +210,25 @@ def getevent():
else:
xbmcgui.Dialog().ok(_addon_name, __language__(30002))
xbmcplugin.endOfDirectory(_addon_handler, succeeded=False)
elif 'live' in args and args['live']:
if jsonResult['data']['content'][0]['group_elements'][0]['type'] == 'player':
eventVideo = jsonResult['data']['content'][0]['group_elements'][0]['data'][0]
global args
args = {'videoid': eventVideo['videoID'], 'isPay': 'True' if ('pay' in eventVideo and eventVideo['pay']) else 'False'}
getvideo()
else:
hasEventVideos = 0
for content in jsonResult['data']['content']:
for index, content in enumerate(jsonResult['data']['content']):
for group_element in content['group_elements']:
if group_element['type'] == 'eventVideos':
for eventVideo in group_element['data']:
hasEventVideos += 1

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'])):
isLivestream = 'islivestream' in jsonResult['data']['content'][0]['group_elements'][0]['data'][0] and jsonResult['data']['content'][0]['group_elements'][0]['data'][0]['islivestream']
isPay = 'pay' in jsonResult['data']['content'][0]['group_elements'][0]['data'][0] and jsonResult['data']['content'][0]['group_elements'][0]['data'][0]['pay']
url = build_url({'mode': 'video', 'videoid': jsonResult['data']['content'][0]['group_elements'][0]['data'][0]['videoID'], 'isLivestream': isLivestream, 'isPay': isPay})
xbmc.Player().play(url)
xbmcplugin.endOfDirectory(_addon_handler, succeeded=False)
else:
for content in jsonResult['data']['content']:
for group_element in content['group_elements']:
if group_element['type'] == 'eventVideos':
for eventVideo in group_element['data']:
isLivestream = 'isLivestream' in eventVideo and eventVideo['isLivestream']
isPay = 'pay' in eventVideo and eventVideo['pay']
url = build_url({'mode': 'video', 'videoid': eventVideo['videoID'], 'isLivestream': isLivestream, 'isPay': isPay})
li = xbmcgui.ListItem(eventVideo['title'], iconImage='https://www.telekomsport.de' + eventVideo['images']['editorial'])
li.setProperty('fanart_image', 'https://www.telekomsport.de' + eventVideo['images']['editorial'])
li.setProperty('IsPlayable', 'true')
li.setInfo('video', {})
xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li)
xbmcplugin.endOfDirectory(_addon_handler)
isPay = 'pay' in eventVideo and eventVideo['pay']
url = build_url({'mode': 'video', 'videoid': eventVideo['videoID'], 'isPay': isPay})
li = xbmcgui.ListItem(eventVideo['title'], iconImage=base_image_url + eventVideo['images']['editorial'])
li.setProperty('fanart_image', base_image_url + eventVideo['images']['editorial'])
li.setProperty('IsPlayable', 'true')
li.setInfo('video', {})
xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li)
xbmcplugin.endOfDirectory(_addon_handler)

def getvideo():
videoid = args['videoid']
Expand All @@ -276,14 +240,27 @@ def getvideo():
_addon.openSettings()
return
else:
jwt = get_jwt(_addon.getSetting('username'), _addon.getSetting('password'))
try:
jwt = get_jwt(_addon.getSetting('username'), _addon.getSetting('password'))
except urllib2.HTTPError, e:
response = json.loads(e.read())
msg = __language__(30005)
if 'error_description' in response:
msg += '\n\n'
msg += __language__(30011)
msg += '\n"' + response['error_description'] + '"'
xbmcgui.Dialog().ok(_addon_name, msg)
xbmcplugin.setResolvedUrl(_addon_handler, False, xbmcgui.ListItem())
return
if jwt:
auth_response = auth_media(jwt, videoid)
if auth_response != "success":
xbmcgui.Dialog().ok(_addon_name, auth_response)
xbmcplugin.setResolvedUrl(_addon_handler, False, xbmcgui.ListItem())
return
else:
xbmcgui.Dialog().ok(_addon_name, __language__(30005))
xbmcplugin.setResolvedUrl(_addon_handler, False, xbmcgui.ListItem())
return

jwt = jwt or 'empty'
Expand Down
Binary file removed fanart.jpg
Binary file not shown.
Binary file removed icon.png
Binary file not shown.
Binary file added resources/fanart.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/fanart/3.liga.jpg
Binary file not shown.
Binary file removed resources/fanart/bbl.jpg
Binary file not shown.
Binary file removed resources/fanart/bundesliga.jpg
Binary file not shown.
Binary file removed resources/fanart/del.jpg
Binary file not shown.
Binary file removed resources/fanart/eurobasket.jpg
Binary file not shown.
Binary file removed resources/fanart/euroleague.jpg
Binary file not shown.
Binary file removed resources/fanart/fcbtv.jpg
Binary file not shown.
Binary file removed resources/fanart/frauen-bundesliga.jpg
Binary file not shown.
Binary file removed resources/fanart/hbl.jpg
Binary file not shown.
Binary file removed resources/fanart/uefa.jpg
Binary file not shown.
Binary file added resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/icons/3.liga.png
Binary file not shown.
Binary file removed resources/icons/bbl.png
Binary file not shown.
Binary file removed resources/icons/bundesliga.png
Binary file not shown.
Binary file removed resources/icons/del.png
Binary file not shown.
Binary file removed resources/icons/eurobasket.png
Binary file not shown.
Binary file removed resources/icons/euroleague.png
Binary file not shown.
Binary file removed resources/icons/fcbtv.png
Binary file not shown.
Binary file removed resources/icons/film.png
Binary file not shown.
Binary file removed resources/icons/frauen-bundesliga.png
Binary file not shown.
Binary file removed resources/icons/hbl.png
Binary file not shown.
Binary file removed resources/icons/uefa.png
Binary file not shown.
4 changes: 4 additions & 0 deletions resources/language/resource.language.de_de/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ msgstr "Benutzername"
msgctxt "#30010"
msgid "Password"
msgstr "Passwort"

msgctxt "#30011"
msgid "Error response from server:"
msgstr "Fehlermeldung vom Server:"
4 changes: 4 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ msgstr ""
msgctxt "#30010"
msgid "Password"
msgstr ""

msgctxt "#30011"
msgid "Error response from server:"
msgstr ""
54 changes: 0 additions & 54 deletions resources/language/resource.language.he_il/strings.po

This file was deleted.

0 comments on commit a8fef61

Please sign in to comment.