From f8f0cf1da1813182abe7bf367aee0c9a861d2ec3 Mon Sep 17 00:00:00 2001 From: Andy Gardner Date: Thu, 11 Jan 2018 23:41:17 +0200 Subject: [plugin.video.redbull.tv] v2.0.2 --- plugin.video.redbull.tv/__init__.py | 0 plugin.video.redbull.tv/addon.xml | 2 +- .../resources/lib/redbulltv_client.py | 16 ++++++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) delete mode 100644 plugin.video.redbull.tv/__init__.py diff --git a/plugin.video.redbull.tv/__init__.py b/plugin.video.redbull.tv/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/plugin.video.redbull.tv/addon.xml b/plugin.video.redbull.tv/addon.xml index 30b5626..58e8f5d 100644 --- a/plugin.video.redbull.tv/addon.xml +++ b/plugin.video.redbull.tv/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/plugin.video.redbull.tv/resources/lib/redbulltv_client.py b/plugin.video.redbull.tv/resources/lib/redbulltv_client.py index 8124273..b23075b 100644 --- a/plugin.video.redbull.tv/resources/lib/redbulltv_client.py +++ b/plugin.video.redbull.tv/resources/lib/redbulltv_client.py @@ -1,5 +1,5 @@ -import re, urllib2 -import utils +import re, urllib2, os +import resources.lib.utils as utils class RedbullTVClient(object): REDBULL_API = "https://appletv.redbull.tv/" @@ -29,10 +29,15 @@ class RedbullTVClient(object): description = element.findtext("description") image = element.find("image").get("src1080") url = element.findtext("mediaURL") + base_url = '' # Try find the specific stream based on the users preferences try: - playlists = urllib2.urlopen(url).read() + response = urllib2.urlopen(url) + # Required to get base url in case of a redirect, to use for relative paths + base_url = response.geturl() + playlists = response.read() + resolution = self.get_resolution_code(self.resolution) media_url = re.search( "RESOLUTION=" + resolution + ".*\n(.*)", @@ -42,6 +47,10 @@ class RedbullTVClient(object): else: url = media_url + # if url is relative, add the base path + if base_url != '' and not url.startswith('http'): + url = os.path.dirname(base_url) + '/' + url + return {"title":name, "url":url, "summary":description, "image": image, "is_stream":True} def get_element_details(self, element, url=None): @@ -108,4 +117,3 @@ class RedbullTVClient(object): for item in xml_elements: items.append(self.get_element_details(item, url)) return items - \ No newline at end of file -- cgit v1.2.3