aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Christopher Rosell <chrippa@tanuki.se>2012-08-04 00:15:49 +0200
committerGravatar Christopher Rosell <chrippa@tanuki.se>2012-08-04 00:15:49 +0200
commitc139d50cc4050cdcf9f43b82c5bb8a5d24582041 (patch)
tree8e2a65db27660e39ddecbd01e3f9f60fb1ebc71a
parent9232721b1998665a55fcf6bebe46cc8eac57bf68 (diff)
livestreamer.plugins.ownedtv: Fetch SWF URL from page.
-rw-r--r--src/livestreamer/plugins/ownedtv.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/livestreamer/plugins/ownedtv.py b/src/livestreamer/plugins/ownedtv.py
index 47ab2f3..5501443 100644
--- a/src/livestreamer/plugins/ownedtv.py
+++ b/src/livestreamer/plugins/ownedtv.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-from livestreamer.compat import urllib
+from livestreamer.compat import urllib, bytes, str
from livestreamer.plugins import Plugin, PluginError, NoStreamsError, register_plugin
from livestreamer.stream import RTMPStream
from livestreamer.utils import urlget, swfverify
@@ -24,7 +24,6 @@ urlopener = urllib.build_opener(RelativeRedirectHandler)
class OwnedTV(Plugin):
ConfigURL = "http://www.own3d.tv/livecfg/{0}"
- SWFURL = "http://static.ec.own3d.tv/player/Own3dPlayerV2_94.swf"
CDN = {
"cdn1": "rtmp://fml.2010.edgecastcdn.net/202010",
"cdn2": "rtmp://owned.fc.llnwd.net:1935/owned",
@@ -35,23 +34,33 @@ class OwnedTV(Plugin):
def can_handle_url(self, url):
return "own3d.tv" in url
- def _get_channel_id(self, url):
+ def _get_channel_info(self, url):
data = urlget(url, opener=urlopener)
+ channelid = None
+ swfurl = None
+
match = re.search(b'flashvars.config = "livecfg/(\d+)', data)
if match:
- return int(match.group(1))
+ channelid = int(match.group(1))
match = re.search(b"document.location.hash='/live/(\d+)'", data)
if match:
- return int(match.group(1))
+ channelid = int(match.group(1))
match = re.search(b"xajax_load_live_config\((\d+),", data)
if match:
- return int(match.group(1))
+ channelid = int(match.group(1))
+
+ match = re.search(b"""swfobject.embedSWF\(\n.+"(.+)", "player",""", data)
+ if match:
+ swfurl = str(match.group(1), "utf8")
+
+ return (channelid, swfurl)
+
def _get_streams(self):
- channelid = self._get_channel_id(self.url)
+ (channelid, swfurl) = self._get_channel_info(self.url)
if not channelid:
raise NoStreamsError(self.url)
@@ -67,7 +76,7 @@ class OwnedTV(Plugin):
channels = dom.getElementsByTagName("channels")[0]
clip = channels.getElementsByTagName("clip")[0]
- swfhash, swfsize = swfverify(self.SWFURL)
+ swfhash, swfsize = swfverify(swfurl)
for item in clip.getElementsByTagName("item"):
base = item.getAttribute("base")