aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/livestreamer/plugins
diff options
context:
space:
mode:
authorGravatar Christopher Rosell <chrippa@tanuki.se>2012-08-15 19:49:54 +0200
committerGravatar Christopher Rosell <chrippa@tanuki.se>2012-08-15 19:49:54 +0200
commite8eedda5453aca95996c3d99380b1070c23f1dd9 (patch)
treecde1377ef38effe6f12ec28dfc824be6b2e07552 /src/livestreamer/plugins
parent0c5563f5e4e6ab8da7dfd5f5c15e7be0e3445c15 (diff)
Add logging.
Diffstat (limited to 'src/livestreamer/plugins')
-rw-r--r--src/livestreamer/plugins/__init__.py9
-rw-r--r--src/livestreamer/plugins/justintv.py17
-rw-r--r--src/livestreamer/plugins/ownedtv.py6
-rw-r--r--src/livestreamer/plugins/svtplay.py7
-rw-r--r--src/livestreamer/plugins/ustreamtv.py3
-rw-r--r--src/livestreamer/plugins/youtube.py2
6 files changed, 31 insertions, 13 deletions
diff --git a/src/livestreamer/plugins/__init__.py b/src/livestreamer/plugins/__init__.py
index c2f9d80..7e91f16 100644
--- a/src/livestreamer/plugins/__init__.py
+++ b/src/livestreamer/plugins/__init__.py
@@ -1,14 +1,15 @@
-#!/usr/bin/env python3
-
import pkgutil
import imp
+from livestreamer.logger import Logger
+
plugins_loaded = {}
class Plugin(object):
def __init__(self, url):
self.url = url
self.args = None
+ self.logger = Logger("plugin." + self.module)
@classmethod
def can_handle_url(self, url):
@@ -49,3 +50,7 @@ def get_plugins():
def register_plugin(name, klass):
plugins_loaded[name] = klass
+ klass.module = name
+
+__all__ = ["Plugin", "PluginError", "NoStreamsError", "NoPluginError",
+ "load_plugins", "get_plugins", "register_plugin"]
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
diff --git a/src/livestreamer/plugins/ownedtv.py b/src/livestreamer/plugins/ownedtv.py
index 5501443..418dd07 100644
--- a/src/livestreamer/plugins/ownedtv.py
+++ b/src/livestreamer/plugins/ownedtv.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python3
-
from livestreamer.compat import urllib, bytes, str
from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin
from livestreamer.stream import RTMPStream
@@ -35,6 +33,8 @@ class OwnedTV(Plugin):
return "own3d.tv" in url
def _get_channel_info(self, url):
+ self.logger.debug("Fetching channel info")
+
data = urlget(url, opener=urlopener)
channelid = None
@@ -65,6 +65,7 @@ class OwnedTV(Plugin):
if not channelid:
raise NoStreamsError(self.url)
+ self.logger.debug("Fetching stream info")
data = urlget(self.ConfigURL.format(channelid))
try:
@@ -76,6 +77,7 @@ class OwnedTV(Plugin):
channels = dom.getElementsByTagName("channels")[0]
clip = channels.getElementsByTagName("clip")[0]
+ self.logger.debug("Verifying SWF: {0}", swfurl)
swfhash, swfsize = swfverify(swfurl)
for item in clip.getElementsByTagName("item"):
diff --git a/src/livestreamer/plugins/svtplay.py b/src/livestreamer/plugins/svtplay.py
index 62c7555..d52ae05 100644
--- a/src/livestreamer/plugins/svtplay.py
+++ b/src/livestreamer/plugins/svtplay.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
from livestreamer.compat import str
from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin
from livestreamer.stream import RTMPStream
@@ -18,6 +16,8 @@ class SVTPlay(Plugin):
return "svtplay.se" in url
def _get_channel_id(self, url):
+ self.logger.debug("Fetching channel id")
+
data = urlget(url)
match = re.search(b'data-json-href="/live/(\d+)"', data)
@@ -30,6 +30,7 @@ class SVTPlay(Plugin):
if not channelid:
raise NoStreamsError(self.url)
+ self.logger.debug("Fetching stream info")
data = urlget(self.JSONURL.format(channelid))
try:
@@ -40,6 +41,8 @@ class SVTPlay(Plugin):
streams = {}
video = verifyjson(info, "video")
videos = verifyjson(video, "videoReferences")
+
+ self.logger.debug("Verifying SWF: {0}", self.SWFURL)
swfhash, swfsize = swfverify(self.SWFURL)
for video in videos:
diff --git a/src/livestreamer/plugins/ustreamtv.py b/src/livestreamer/plugins/ustreamtv.py
index a7b88a7..d7d37f7 100644
--- a/src/livestreamer/plugins/ustreamtv.py
+++ b/src/livestreamer/plugins/ustreamtv.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python3
-
from livestreamer.compat import str, bytes
from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin
from livestreamer.stream import RTMPStream
@@ -35,6 +33,7 @@ class UStreamTV(Plugin):
if not channelid:
raise NoStreamsError(self.url)
+ self.logger.debug("Fetching stream info")
data = urlget(self.AMFURL.format(channelid))
playpath = get_amf_value(data, "streamName")
diff --git a/src/livestreamer/plugins/youtube.py b/src/livestreamer/plugins/youtube.py
index 804ddbc..398657c 100644
--- a/src/livestreamer/plugins/youtube.py
+++ b/src/livestreamer/plugins/youtube.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python3
-
from livestreamer.compat import str, bytes, parse_qs
from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin
from livestreamer.stream import HTTPStream