Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plugin fo freedocast.com #58

Merged
merged 1 commit into from Dec 3, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/livestreamer/plugins/freedocast.py
@@ -0,0 +1,47 @@
from livestreamer.stream import RTMPStream
from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.utils import urlget

import re

class Freedocast(Plugin):
SWFURL = "http://cdn.freedocast.com/player-octo/yume/v5/infinite-hd-player-FREEDOCAST.SWF"
PlayerURL = "http://www.freedocast.com/forms/watchstream.aspx?sc={0}"

@classmethod
def can_handle_url(self, url):
return "freedocast.com" in url

def _get_streams(self):
self.logger.debug("Fetching stream info")
res = urlget(self.url)

match = re.search("\"User_channelid\".+?value=\"(.+?)\"", res.text)
if not match:
raise NoStreamsError(self.url)

headers = {
"Referer": self.url
}

res = urlget(self.PlayerURL.format(match.group(1)), headers=headers)

match = re.search("stream:\s+'(rtmp://.+?)'", res.text)
if not match:
raise NoStreamsError(self.url)

rtmp = match.group(1)

streams = {}

streams["live"] = RTMPStream(self.session, {
"rtmp": rtmp,
"pageUrl": self.url,
"swfVfy": self.SWFURL,
"live": True
})

return streams


__plugin__ = Freedocast