aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/livestreamer/plugins/justintv.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/livestreamer/plugins/justintv.py')
-rw-r--r--src/livestreamer/plugins/justintv.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/livestreamer/plugins/justintv.py b/src/livestreamer/plugins/justintv.py
index 561c1d0..62702c6 100644
--- a/src/livestreamer/plugins/justintv.py
+++ b/src/livestreamer/plugins/justintv.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python3
-
from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin
from livestreamer.stream import RTMPStream
from livestreamer.utils import swfverify, urlget
@@ -41,6 +39,7 @@ class JustinTV(Plugin):
metadata["title"] = self._get_node_if_exists(dom, "title")
metadata["access_guid"] = self._get_node_if_exists(dom, "access_guid")
+ metadata["login"] = self._get_node_if_exists(dom, "login")
return metadata
@@ -63,14 +62,22 @@ class JustinTV(Plugin):
else:
return tag
+
chansub = None
if options.get("jtvcookie"):
+ self.logger.debug("Attempting to authenticate using cookie")
+
metadata = self._get_metadata(channelname)
chansub = metadata["access_guid"]
+ if "login" in metadata:
+ self.logger.debug("Successfully logged in as {0}", metadata["login"])
+
+
randomp = int(random.random() * 999999)
url = self.StreamInfoURL.format(channelname, randomp, chansub)
+ self.logger.debug("Fetching stream info")
data = urlget(url)
# fix invalid xml
@@ -86,6 +93,7 @@ class JustinTV(Plugin):
nodes = dom.getElementsByTagName("nodes")[0]
+ self.logger.debug("Verifying SWF: {0}", self.SWFURL)
swfhash, swfsize = swfverify(self.SWFURL)
for node in nodes.childNodes:
@@ -101,10 +109,13 @@ class JustinTV(Plugin):
"live": True
})
+ sname = clean_tag(node.tagName)
+
if "token" in info:
stream.params["jtv"] = info["token"]
+ else:
+ self.logger.warning("No token found for stream {0}, this stream may fail to play", sname)
- sname = clean_tag(node.tagName)
streams[sname] = stream
return streams