aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/livestreamer/plugins/svtplay.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/livestreamer/plugins/svtplay.py')
-rw-r--r--src/livestreamer/plugins/svtplay.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/livestreamer/plugins/svtplay.py b/src/livestreamer/plugins/svtplay.py
index 3ca85a9..a3bfa5a 100644
--- a/src/livestreamer/plugins/svtplay.py
+++ b/src/livestreamer/plugins/svtplay.py
@@ -3,11 +3,10 @@ from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.stream import RTMPStream
from livestreamer.utils import urlget, swfverify, verifyjson
-import json, re
-
+import re
class SVTPlay(Plugin):
- JSONURL = "http://svtplay.se/live/{0}?output=json"
+ JSONURL = "http://svtplay.se/live/{0}"
SWFURL = "http://www.svtplay.se/public/swf/video/svtplayer-2012.15.swf"
PageURL = "http://www.svtplay.se"
@@ -18,9 +17,10 @@ class SVTPlay(Plugin):
def _get_channel_id(self, url):
self.logger.debug("Fetching channel id")
- data = urlget(url)
+ res = urlget(url)
+
- match = re.search(b'data-json-href="/live/(\d+)"', data)
+ match = re.search('data-json-href="/live/(\d+)"', res.text)
if match:
return int(match.group(1))
@@ -31,15 +31,13 @@ class SVTPlay(Plugin):
raise NoStreamsError(self.url)
self.logger.debug("Fetching stream info")
- data = urlget(self.JSONURL.format(channelid))
+ res = urlget(self.JSONURL.format(channelid), params=dict(output="json"))
- try:
- info = json.loads(str(data, "utf8"))
- except ValueError as err:
- raise PluginError(("Unable to parse JSON: {0})").format(err))
+ if res.json is None:
+ raise PluginError("No JSON data in stream info")
streams = {}
- video = verifyjson(info, "video")
+ video = verifyjson(res.json, "video")
videos = verifyjson(video, "videoReferences")
self.logger.debug("Verifying SWF: {0}", self.SWFURL)
@@ -58,7 +56,6 @@ class SVTPlay(Plugin):
})
streams[str(video["bitrate"]) + "k"] = stream
-
return streams
__plugin__ = SVTPlay