From 9232721b1998665a55fcf6bebe46cc8eac57bf68 Mon Sep 17 00:00:00 2001 From: Christopher Rosell Date: Fri, 3 Aug 2012 23:59:08 +0200 Subject: livestreamer.plugins.justintv: Only request metadata when needed. --- src/livestreamer/plugins/justintv.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/livestreamer/plugins/justintv.py b/src/livestreamer/plugins/justintv.py index 5fc7cc5..32348d2 100644 --- a/src/livestreamer/plugins/justintv.py +++ b/src/livestreamer/plugins/justintv.py @@ -9,8 +9,7 @@ from livestreamer import options import xml.dom.minidom, re, sys, random class JustinTV(Plugin): - StreamInfoURL = "http://usher.justin.tv/find/{0}.xml?type=any&p={1}" - StreamInfoURLSub = "http://usher.justin.tv/find/{0}.xml?type=any&p={1}&b_id=true&chansub_guid={2}&private_code=null&group=&channel_subscription={2}" + 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" @@ -68,13 +67,13 @@ class JustinTV(Plugin): else: return tag - metadata = self._get_metadata(channelname) - randomp = int(random.random() * 999999) + chansub = None + if options.get("cookie"): + metadata = self._get_metadata(channelname) + chansub = metadata["chansub_guid"] - if "chansub_guid" in metadata: - url = self.StreamInfoURLSub.format(channelname, randomp, metadata["chansub_guid"]) - else: - url = self.StreamInfoURL.format(channelname, randomp) + randomp = int(random.random() * 999999) + url = self.StreamInfoURL.format(channelname, randomp, chansub) data = urlget(url) -- cgit v1.2.3