From 96c33449eefbf0c5257c56aa8109628351a18b59 Mon Sep 17 00:00:00 2001 From: Christopher Rosell Date: Thu, 19 Jan 2012 22:50:30 +0100 Subject: Plugins can now add extra arguments to the cli. --- src/livestreamer/cli.py | 6 ++++++ src/livestreamer/plugins/__init__.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/livestreamer/cli.py b/src/livestreamer/cli.py index 7bb57e2..3239e81 100644 --- a/src/livestreamer/cli.py +++ b/src/livestreamer/cli.py @@ -59,6 +59,9 @@ def print_plugins(): def main(): + for name, plugin in livestreamer.get_plugins().items(): + plugin.handle_parser(parser) + arglist = sys.argv[1:] if os.path.exists(livestreamer.RCFILE): @@ -66,6 +69,9 @@ def main(): args = parser.parse_args(arglist) + for name, plugin in livestreamer.get_plugins().items(): + plugin.handle_args(args) + if args.url: handle_url(args) elif args.plugins: diff --git a/src/livestreamer/plugins/__init__.py b/src/livestreamer/plugins/__init__.py index 3999574..1f4c268 100644 --- a/src/livestreamer/plugins/__init__.py +++ b/src/livestreamer/plugins/__init__.py @@ -15,6 +15,12 @@ class Plugin(object): def stream_cmdline(self, stream, filename): raise NotImplementedError + def handle_parser(self, parser): + pass + + def handle_args(self, args): + self.args = args + def load_plugins(plugins): for loader, name, ispkg in pkgutil.iter_modules(plugins.__path__): -- cgit v1.2.3