Skip to content

Commit

Permalink
Update to fix broken streaming - upstream moved away from Brightcove …
Browse files Browse the repository at this point in the history
…and now serve their own playlist files
  • Loading branch information
shiznix committed Jul 26, 2019
1 parent d83d32f commit f718b6b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 58 deletions.
4 changes: 2 additions & 2 deletions addon.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<addon id="plugin.video.catchuptv.au.ten" name="tenplay" provider-name="Aussie Add-ons" version="1.0.0">
<addon id="plugin.video.catchuptv.au.ten" name="tenplay" provider-name="Aussie Add-ons" version="1.2.0">
<requires>
<import addon="xbmc.python" version="2.1.0" />
<import addon="script.module.aussieaddonscommon" />
Expand Down Expand Up @@ -122,4 +122,4 @@
[B]Version v0.4.0[/B]
- Initial version
</news></extension>
</addon>
</addon>
1 change: 1 addition & 0 deletions resources/lib/comm.py
Expand Up @@ -62,6 +62,7 @@ def get_episodes(params):
e.airdate = episode['customFields']['start_date_act']
e.page = int(page)
e.id = episode['id']
e.hlsurl = episode['HLSURL']
e.total_episodes = int(data['total_count'])
if e.total_episodes > 30:
e.query = urllib.quote(params['query'])
Expand Down
59 changes: 3 additions & 56 deletions resources/lib/play.py
Expand Up @@ -9,68 +9,15 @@
_url = sys.argv[0]
_handle = int(sys.argv[1])


def parse_m3u8(data, qual=-1):
"""
Parse the retrieved m3u8 stream list into a list of dictionaries
then return the url for the highest quality stream.
"""
ver = 0
if '#EXT-X-VERSION:3' in data:
ver = 3
data.remove('#EXT-X-VERSION:3')
if '#EXT-X-VERSION:4' in data:
ver = 4
data.remove('#EXT-X-VERSION:4')
count = 1
m3u_list = []
while count < len(data):
if ver == 3 or ver == 0:
line = data[count]
line = line.strip('#EXT-X-STREAM-INF:')
line = line.strip('PROGRAM-ID=1,')
if 'CODECS' in line:
line = line[:line.find('CODECS')]
if line.endswith(','):
line = line[:-1]
line = line.strip()
line = line.split(',')
linelist = [i.split('=') for i in line]
linelist.append(['URL', data[count + 1]])
m3u_list.append(dict((i[0], i[1]) for i in linelist))
count += 2

if ver == 4:
line = data[count]
line = line.strip('#EXT-X-STREAM-INF:')
line = line.strip('PROGRAM-ID=1,')
values = line.split(',')
for value in values:
if value.startswith('BANDWIDTH'):
bw = value
elif value.startswith('RESOLUTION'):
res = value
url = data[count + 1]
m3u_list.append(
dict([bw.split('='), res.split('='), ['URL', url]]))
count += 3

sorted_m3u_list = sorted(m3u_list, key=lambda k: int(k['BANDWIDTH']))
utils.log('Available streams are: {0}'.format(sorted_m3u_list))
stream = sorted_m3u_list[qual]['URL']
return stream


def play_video(params):
"""
Determine content and pass url to Kodi for playback
"""
try:
with session.Session() as sess:
url = config.BRIGHTCOVE_URL.format(params['id'])
data = sess.get(url).text.splitlines()
streamurl = parse_m3u8(data)
play_item = xbmcgui.ListItem(path=streamurl)
url = (params['hlsurl'] + '&format=m3u8')
utils.log("M3U8 URL: %s" % url)
play_item = xbmcgui.ListItem(path=url)
xbmcplugin.setResolvedUrl(_handle, True, play_item)
except Exception:
utils.handle_error('Unable to play video')

0 comments on commit f718b6b

Please sign in to comment.