Skip to content

Commit

Permalink
Merge pull request #24 from piejanssens/master
Browse files Browse the repository at this point in the history
address kodi review comments + catch missing epg time markers
  • Loading branch information
piejanssens committed Nov 1, 2020
2 parents 54bc677 + 672d4dd commit 88c6bea
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 27 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ content available on [Red Bull TV](https://www.redbull.com/discover).
</table>

## Releases
### v3.2.1 (2020-10-31)
- Fix OK dialog (@dagwiers)
- Catch missing EPG time markers (@dagpiejanssens)

### v3.2.0 (2020-10-29)
- Support VOD playback from EPG via context menu (@piejanssens)
- Add YouTube integration (@piejanssens)
Expand Down
24 changes: 16 additions & 8 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.redbull.tv" name="Red Bull TV" version="3.2.0" provider-name="nedge2k, andy-g, piejanssens">
<addon id="plugin.video.redbull.tv" name="Red Bull TV" version="3.2.1" provider-name="piejanssens">
<requires>
<import addon="script.module.dateutil" version="2.8.0"/>
<import addon="script.module.routing" version="0.2.0"/>
<import addon="xbmc.python" version="2.26.0"/>
<import addon="script.module.dateutil" version="2.8.0" />
<import addon="script.module.routing" version="0.2.0" />
<import addon="xbmc.python" version="2.26.0" />
</requires>
<extension point="xbmc.python.pluginsource" library="resources/lib/addon_entry.py">
<provides>video</provides>
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en">Watch Red Bull TV, live and on demand.</summary>
<description lang="en">Red Bull TV gives you front-row access to live events, the best inaction sports, new music and entertainment, and thrilling videos from world adventurers.</description>
<disclaimer lang="en">This add-on is not endorsed by Red Bull GmbH and is provided 'as is' without any warranty of any kind.
</disclaimer>
<summary lang="en_GB">Watch Red Bull TV, live and on demand.</summary>
<description lang="en_GB">Red Bull TV gives you front-row access to live events, the best inaction sports, new music and entertainment, and thrilling videos from world adventurers.</description>
<disclaimer lang="en_GB">This add-on is not endorsed by Red Bull GmbH and is provided 'as is' without any warranty of any kind.</disclaimer>
<summary lang="nl_NL">Bekijk Red Bull TV, live en op aanvraag.</summary>
<description lang="nl_NL">Red Bull TV geeft je toegang vanop de eerste rij voor live evenementen, de beste actie sporten, muziek en entertainment, en spannende videos van avonturiers.</description>
<disclaimer lang="nl_NL">Deze add-on wordt niet herkend door Red Bull GmbH en wordt zonder enige garantie van welke aard dan ook aangeboden.</disclaimer>
<license>GPL-2.0-only</license>
<forum>https://forum.kodi.tv/showthread.php?tid=355054</forum>
<website>http:https://www.redbull.tv/</website>
<platform>all</platform>
<source>https://github.com/add-ons/plugin.video.redbull.tv</source>
Expand All @@ -25,6 +29,10 @@
<screenshot>resources/media/screenshot04.jpg</screenshot>
</assets>
<news>
v3.2.1
- Fix OK dialog
- Catch missing EPG time markers

v3.2.0
- Support VOD playback from EPG via context menu
- Add YouTube integration (requires YouTube add-on)
Expand Down
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 @@ -65,6 +65,10 @@ msgctxt "#30225"
msgid "This event is scheduled to start on:"
msgstr ""

msgctxt "#30228"
msgid "Best of Red Bull TV"
msgstr ""

### SETTINGS
msgctxt "#30860"
msgid "Integration"
Expand Down
4 changes: 4 additions & 0 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ msgctxt "#30225"
msgid "This event is scheduled to start on:"
msgstr "Dit evenement is gepland om te starten op:"

msgctxt "#30228"
msgid "Beste van Red Bull TV"
msgstr ""

### SETTINGS
msgctxt "#30860"
msgid "Integration"
Expand Down
4 changes: 1 addition & 3 deletions resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def index():
poster=addon_icon()
),
info_dict=dict(
plot='Best of Red Bull TV',
plot=localize(30228),
),
is_playable=True
),
Expand Down Expand Up @@ -138,7 +138,6 @@ def search():


def build_menu(items_url):
from xbmc import executebuiltin
from xbmcplugin import addDirectoryItem, endOfDirectory, setContent
setContent(plugin.handle, 'videos')
list_items = []
Expand Down Expand Up @@ -172,7 +171,6 @@ def build_menu(items_url):
for list_item in list_items:
addDirectoryItem(handle=plugin.handle, url=list_item.getPath(), listitem=list_item, isFolder=('/play/' not in list_item.getPath()))

executebuiltin('Container.SetViewMode({mode})'.format(mode=55)) # Wide List
endOfDirectory(plugin.handle)


Expand Down
30 changes: 20 additions & 10 deletions resources/lib/iptvmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from __future__ import absolute_import, division, unicode_literals

from xbmc import log

class IPTVManager:
""" Interface to IPTV Manager """
Expand Down Expand Up @@ -48,6 +49,7 @@ def send_channels(self): # pylint: disable=no-method-argument,no-self-use
@via_socket
def send_epg(self): # pylint: disable=no-method-argument,no-self-use
""" Return JSON-EPG formatted information to IPTV Manager. """
import re
from collections import defaultdict
from datetime import datetime
from dateutil.tz import UTC
Expand All @@ -57,16 +59,24 @@ def send_epg(self): # pylint: disable=no-method-argument,no-self-use
redbull = RedBullTV()

epg = defaultdict(list)

for item in redbull.get_epg().get('items'):
epg['redbulltv'].append(dict(
start=datetime.strptime(item.get('start_time'), "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=UTC).isoformat(),
stop=datetime.strptime(item.get('end_time'), "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=UTC).isoformat(),
title=item.get('title'),
description=item.get('long_description'),
subtitle=item.get('subheading'),
genre='Sport',
image=redbull.get_image_url(item.get('id'), item.get('resources'), 'landscape'),
stream=url_for('play_uid', uid=item.get('id'))
))
if (
item.get('start_time')
and item.get('end_time')
and re.match('\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z', item.get('start_time')) # pylint: disable=anomalous-backslash-in-string
and re.match('\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z', item.get('end_time'))): # pylint: disable=anomalous-backslash-in-string
epg['redbulltv'].append(dict(
start=datetime.strptime(item.get('start_time'), "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=UTC).isoformat(),
stop=datetime.strptime(item.get('end_time'), "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=UTC).isoformat(),
title=item.get('title'),
description=item.get('long_description'),
subtitle=item.get('subheading'),
genre='Sport',
image=redbull.get_image_url(item.get('id'), item.get('resources'), 'landscape'),
stream=url_for('play_uid', uid=item.get('id'))
))
else:
log("Invalid start or end time for Red Bull item ID {uid}".format(uid=item.get('id')))

return dict(version=1, epg=epg)
6 changes: 0 additions & 6 deletions tests/xbmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,6 @@ def getRating(self):
return 0


def executebuiltin(string, wait=False): # pylint: disable=unused-argument
"""A stub implementation of the xbmc executebuiltin() function"""
assert isinstance(string, basestring)
assert isinstance(wait, bool)


def executeJSONRPC(jsonrpccommand):
"""A reimplementation of the xbmc executeJSONRPC() function"""
assert isinstance(jsonrpccommand, basestring)
Expand Down

0 comments on commit 88c6bea

Please sign in to comment.