aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/livestreamer/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/livestreamer/plugins')
-rw-r--r--src/livestreamer/plugins/__init__.py38
-rw-r--r--src/livestreamer/plugins/justintv.py17
-rw-r--r--src/livestreamer/plugins/ownedtv.py6
-rw-r--r--src/livestreamer/plugins/svtplay.py6
-rw-r--r--src/livestreamer/plugins/ustreamtv.py6
-rw-r--r--src/livestreamer/plugins/youtube.py6
6 files changed, 37 insertions, 42 deletions
diff --git a/src/livestreamer/plugins/__init__.py b/src/livestreamer/plugins/__init__.py
index 7e91f16..4c70fdc 100644
--- a/src/livestreamer/plugins/__init__.py
+++ b/src/livestreamer/plugins/__init__.py
@@ -1,20 +1,24 @@
-import pkgutil
-import imp
-
-from livestreamer.logger import Logger
-
-plugins_loaded = {}
+from livestreamer.options import Options
class Plugin(object):
+ options = Options()
+
def __init__(self, url):
self.url = url
- self.args = None
- self.logger = Logger("plugin." + self.module)
+ self.logger = self.session.logger.new_module("plugin." + self.module)
@classmethod
- def can_handle_url(self, url):
+ def can_handle_url(cls, url):
raise NotImplementedError
+ @classmethod
+ def set_option(cls, key, value):
+ cls.options.set(key, value)
+
+ @classmethod
+ def get_option(cls, key):
+ return cls.options.get(key)
+
def get_streams(self):
ranking = ["iphonelow", "iphonehigh", "240p", "320k", "360p", "850k",
"480p", "1400k", "720p", "2400k", "hd", "1080p", "live"]
@@ -39,18 +43,4 @@ class NoStreamsError(PluginError):
class NoPluginError(PluginError):
pass
-def load_plugins(plugins):
- for loader, name, ispkg in pkgutil.iter_modules(plugins.__path__):
- file, pathname, desc = imp.find_module(name, plugins.__path__)
- imp.load_module(name, file, pathname, desc)
- return plugins_loaded
-
-def get_plugins():
- return plugins_loaded
-
-def register_plugin(name, klass):
- plugins_loaded[name] = klass
- klass.module = name
-
-__all__ = ["Plugin", "PluginError", "NoStreamsError", "NoPluginError",
- "load_plugins", "get_plugins", "register_plugin"]
+__all__ = ["Plugin", "PluginError", "NoStreamsError", "NoPluginError"]
diff --git a/src/livestreamer/plugins/justintv.py b/src/livestreamer/plugins/justintv.py
index 62702c6..c3e7826 100644
--- a/src/livestreamer/plugins/justintv.py
+++ b/src/livestreamer/plugins/justintv.py
@@ -1,12 +1,16 @@
-from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin
+from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.stream import RTMPStream
from livestreamer.utils import swfverify, urlget
from livestreamer.compat import urllib, str
-from livestreamer import options
+from livestreamer.options import Options
import xml.dom.minidom, re, sys, random
class JustinTV(Plugin):
+ options = Options({
+ "cookie": None
+ })
+
StreamInfoURL = "http://usher.justin.tv/find/{0}.xml?type=any&p={1}&b_id=true&chansub_guid={2}&private_code=null&group=&channel_subscription={2}"
MetadataURL = "http://www.justin.tv/meta/{0}.xml?on_site=true"
SWFURL = "http://www.justin.tv/widgets/live_embed_player.swf"
@@ -19,7 +23,7 @@ class JustinTV(Plugin):
return url.rstrip("/").rpartition("/")[2]
def _get_metadata(self, channel):
- cookie = options.get("jtvcookie")
+ cookie = self.options.get("cookie")
if cookie:
headers = {"Cookie": cookie}
@@ -64,7 +68,7 @@ class JustinTV(Plugin):
chansub = None
- if options.get("jtvcookie"):
+ if self.options.get("cookie") is not None:
self.logger.debug("Attempting to authenticate using cookie")
metadata = self._get_metadata(channelname)
@@ -101,7 +105,7 @@ class JustinTV(Plugin):
for child in node.childNodes:
info[child.tagName] = self._get_node_text(child)
- stream = RTMPStream({
+ stream = RTMPStream(self.session, {
"rtmp": ("{0}/{1}").format(info["connect"], info["play"]),
"swfUrl": self.SWFURL,
"swfhash": swfhash,
@@ -128,4 +132,5 @@ class JustinTV(Plugin):
return self._get_streaminfo(channelname)
-register_plugin("justintv", JustinTV)
+
+__plugin__ = JustinTV
diff --git a/src/livestreamer/plugins/ownedtv.py b/src/livestreamer/plugins/ownedtv.py
index 132dd93..1d2fac4 100644
--- a/src/livestreamer/plugins/ownedtv.py
+++ b/src/livestreamer/plugins/ownedtv.py
@@ -1,5 +1,5 @@
from livestreamer.compat import urllib, bytes, str
-from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin
+from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.stream import RTMPStream
from livestreamer.utils import urlget, swfverify
@@ -93,7 +93,7 @@ class OwnedTV(Plugin):
name = streamel.getAttribute("label").lower().replace(" ", "_")
playpath = streamel.getAttribute("name")
- stream = RTMPStream({
+ stream = RTMPStream(self.session, {
"rtmp": ("{0}/{1}").format(base, playpath),
"live": True,
"swfhash": swfhash,
@@ -113,4 +113,4 @@ class OwnedTV(Plugin):
return streams
-register_plugin("own3dtv", OwnedTV)
+__plugin__ = OwnedTV
diff --git a/src/livestreamer/plugins/svtplay.py b/src/livestreamer/plugins/svtplay.py
index d52ae05..3ca85a9 100644
--- a/src/livestreamer/plugins/svtplay.py
+++ b/src/livestreamer/plugins/svtplay.py
@@ -1,5 +1,5 @@
from livestreamer.compat import str
-from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin
+from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.stream import RTMPStream
from livestreamer.utils import urlget, swfverify, verifyjson
@@ -49,7 +49,7 @@ class SVTPlay(Plugin):
if not ("url" in video and "playerType" in video and video["playerType"] == "flash"):
continue
- stream = RTMPStream({
+ stream = RTMPStream(self.session, {
"rtmp": video["url"],
"pageUrl": self.PageURL,
"swfhash": swfhash,
@@ -61,4 +61,4 @@ class SVTPlay(Plugin):
return streams
-register_plugin("svtplay", SVTPlay)
+__plugin__ = SVTPlay
diff --git a/src/livestreamer/plugins/ustreamtv.py b/src/livestreamer/plugins/ustreamtv.py
index d7d37f7..4f0d3fd 100644
--- a/src/livestreamer/plugins/ustreamtv.py
+++ b/src/livestreamer/plugins/ustreamtv.py
@@ -1,5 +1,5 @@
from livestreamer.compat import str, bytes
-from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin
+from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.stream import RTMPStream
from livestreamer.utils import urlget
@@ -41,7 +41,7 @@ class UStreamTV(Plugin):
fmsurl = get_amf_value(data, "fmsUrl")
if playpath:
- stream = RTMPStream({
+ stream = RTMPStream(self.session, {
"rtmp": ("{0}/{1}").format(cdnurl or fmsurl, playpath),
"pageUrl": self.url,
"swfUrl": self.SWFURL,
@@ -51,4 +51,4 @@ class UStreamTV(Plugin):
return streams
-register_plugin("ustreamtv", UStreamTV)
+__plugin__ = UStreamTV
diff --git a/src/livestreamer/plugins/youtube.py b/src/livestreamer/plugins/youtube.py
index 398657c..606a57e 100644
--- a/src/livestreamer/plugins/youtube.py
+++ b/src/livestreamer/plugins/youtube.py
@@ -1,5 +1,5 @@
from livestreamer.compat import str, bytes, parse_qs
-from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin
+from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.stream import HTTPStream
from livestreamer.utils import urlget, verifyjson
@@ -76,7 +76,7 @@ class Youtube(Plugin):
if not "url" in streaminfo:
continue
- stream = HTTPStream(streaminfo["url"][0])
+ stream = HTTPStream(self.session, streaminfo["url"][0])
if streaminfo["itag"][0] in formatmap:
quality = formatmap[streaminfo["itag"][0]]
@@ -87,4 +87,4 @@ class Youtube(Plugin):
return streams
-register_plugin("youtube", Youtube)
+__plugin__ = Youtube