From 0b0be39ebf40379a6cc9262a2b8c54223cdba062 Mon Sep 17 00:00:00 2001 From: Christopher Rosell Date: Wed, 13 Jun 2012 16:06:27 +0200 Subject: Added global options module. - Removed argument handlers from plugins and use options instead. - Removed arguments to stream.open() and use options instead. - Added rtmpdump option to override location manually. --- src/livestreamer/plugins/justintv.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/livestreamer/plugins/justintv.py') diff --git a/src/livestreamer/plugins/justintv.py b/src/livestreamer/plugins/justintv.py index c6d1219..5fc7cc5 100644 --- a/src/livestreamer/plugins/justintv.py +++ b/src/livestreamer/plugins/justintv.py @@ -4,6 +4,7 @@ from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_p from livestreamer.stream import RTMPStream from livestreamer.utils import swfverify, urlget from livestreamer.compat import urllib, str +from livestreamer import options import xml.dom.minidom, re, sys, random @@ -13,20 +14,10 @@ class JustinTV(Plugin): MetadataURL = "http://www.justin.tv/meta/{0}.xml?on_site=true" SWFURL = "http://www.justin.tv/widgets/live_embed_player.swf" - cookie = None - @classmethod def can_handle_url(self, url): return ("justin.tv" in url) or ("twitch.tv" in url) - @classmethod - def handle_parser(self, parser): - parser.add_argument("--jtv-cookie", metavar="cookie", help="JustinTV cookie to allow access to subscription channels") - - @classmethod - def handle_args(self, args): - self.cookie = args.jtv_cookie - def _get_channel_name(self, url): data = urlget(url) match = re.search(b"live_facebook_embed_player\.swf\?channel=(\w+)", data) @@ -35,8 +26,10 @@ class JustinTV(Plugin): return str(match.group(1), "ascii") def _get_metadata(self, channel): - if self.cookie: - headers = {"Cookie": self.cookie} + cookie = options.get("jtvcookie") + + if cookie: + headers = {"Cookie": cookie} req = urllib.Request(self.MetadataURL.format(channel), headers=headers) else: req = urllib.Request(self.MetadataURL.format(channel)) -- cgit v1.2.3