aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/livestreamer/plugins/justintv.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/livestreamer/plugins/justintv.py')
-rw-r--r--src/livestreamer/plugins/justintv.py17
1 files changed, 5 insertions, 12 deletions
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))