aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Christopher Rosell <chrippa@tanuki.se>2012-09-29 22:04:44 +0200
committerGravatar Christopher Rosell <chrippa@tanuki.se>2012-09-29 22:04:44 +0200
commitef86768ac8520e94dcd336b3acc98c0572382371 (patch)
tree054f146b0848fa52056758aabdce7a59960fc92a /src
parent6ace47a5c2d9e4fc910ec39846a2d9540cb665b7 (diff)
cli: Add option to load plugins from custom directories.
Diffstat (limited to 'src')
-rw-r--r--src/livestreamer/__init__.py8
-rw-r--r--src/livestreamer/cli.py16
2 files changed, 16 insertions, 8 deletions
diff --git a/src/livestreamer/__init__.py b/src/livestreamer/__init__.py
index ca176d0..a34d90b 100644
--- a/src/livestreamer/__init__.py
+++ b/src/livestreamer/__init__.py
@@ -82,16 +82,14 @@ class Livestreamer(object):
return self.plugins
def load_builtin_plugins(self):
- for loader, name, ispkg in pkgutil.iter_modules(plugins.__path__):
- file, pathname, desc = imp.find_module(name, plugins.__path__)
- self.load_plugin(name, file, pathname, desc)
+ self.load_plugins(plugins.__path__[0])
def load_plugins(self, path):
"""
Attempt to load plugins from the *path* directory.
"""
- for loader, name, ispkg in pkgutil.iter_modules(path):
- file, pathname, desc = imp.find_module(name, path)
+ for loader, name, ispkg in pkgutil.iter_modules([path]):
+ file, pathname, desc = imp.find_module(name, [path])
self.load_plugin(name, file, pathname, desc)
def load_plugin(self, name, file, pathname, desc):
diff --git a/src/livestreamer/cli.py b/src/livestreamer/cli.py
index d2a31f6..8c8935b 100644
--- a/src/livestreamer/cli.py
+++ b/src/livestreamer/cli.py
@@ -60,13 +60,15 @@ outputopt.add_argument("-O", "--stdout", action="store_true",
help="Write stream to stdout instead of playing it")
pluginopt = parser.add_argument_group("plugin options")
+pluginopt.add_argument("--plugin-dirs", metavar="directory",
+ help="Attempts to load plugins from these directories. Multiple directories can be used by separating them with a ;.")
pluginopt.add_argument("-c", "--cmdline", action="store_true",
help="Print command-line used internally to play stream, this may not be available on all streams")
pluginopt.add_argument("-e", "--errorlog", action="store_true",
help="Log possible errors from internal command-line to a temporary file, use when debugging")
pluginopt.add_argument("-r", "--rtmpdump", metavar="path",
help="Specify location of rtmpdump executable, eg. /usr/local/bin/rtmpdump")
-pluginopt.add_argument("-j", "--jtv-cookie", metavar="cookie",
+pluginopt.add_argument("--jtv-cookie", metavar="cookie",
help="Specify JustinTV cookie to allow access to subscription channels")
pluginopt.add_argument("--gomtv-cookie", metavar="cookie",
help="Specify GOMTV cookie to allow access to streams")
@@ -241,7 +243,6 @@ def output_stream(stream, args):
except:
pass
-
def handle_url(args):
try:
channel = livestreamer.resolve_url(args.url)
@@ -281,11 +282,17 @@ def handle_url(args):
else:
msg(("Found streams: {0}").format(validstreams))
-
def print_plugins():
pluginlist = list(livestreamer.get_plugins().keys())
msg(("Installed plugins: {0}").format(", ".join(pluginlist)))
+def load_plugins(dirs):
+ dirs = [os.path.expanduser(d) for d in dirs.split(";")]
+ for directory in dirs:
+ if os.path.isdir(directory):
+ livestreamer.load_plugins(directory)
+ else:
+ logger.warning("Plugin directory {0} does not exist!", directory)
def main():
arglist = sys.argv[1:]
@@ -311,6 +318,9 @@ def main():
livestreamer.set_plugin_option("gomtv", "password", gomtv_password)
livestreamer.set_loglevel(args.loglevel)
+ if args.plugin_dirs:
+ load_plugins(args.plugin_dirs)
+
if args.url:
handle_url(args)
elif args.plugins: