Skip to content

Instantly share code, notes, and snippets.

@henkman
Created May 4, 2014 15:41
Show Gist options
  • Save henkman/4515ffbe2c4714169077 to your computer and use it in GitHub Desktop.
Save henkman/4515ffbe2c4714169077 to your computer and use it in GitHub Desktop.
from livestreamer.exceptions import PluginError, NoStreamsError
from livestreamer.plugin import Plugin
from livestreamer.stream import RTMPStream
from livestreamer.plugin.api import http
import re
class CastAMP(Plugin):
_reChannel = re.compile("live/([^$]+)$")
_reStream = re.compile("'streamer': '([^']+)'")
@classmethod
def can_handle_url(self, url):
return "castamp.com" in url
def _get_streams(self):
m = self._reChannel.search(self.url)
if not m:
raise NoStreamsError(self.url)
res = http.get("http://castamp.com/embed.php?c={0}&ch=1".format(m.group(1)))
m = self._reStream.search(res.text)
if not m:
raise NoStreamsError(self.url)
if not RTMPStream.is_usable(self.session):
raise PluginError("rtmpdump is not usable but required by CastAMP plugin")
streams = {}
streams["live"] = RTMPStream(self.session, {
"rtmp": m.group(1),
"pageUrl": self.url,
"live": True
})
return streams
__plugin__ = CastAMP
@TicTac9k1
Copy link

Really appreciate your effort for making this, I've tried it out though I'm getting this result;

C:\Program Files (x86)\Livestreamer>livestreamer.exe castamp.com/live/lkmmweikrmrmewqww142e
[cli][info] Found matching plugin castamp for URL castamp.com/live/lkmmweikrmrmewqww142e
Available streams: live (worst, best)

C:\Program Files (x86)\Livestreamer>livestreamer.exe castamp.com/live/lkmmweikrmrmewqww142e best
[cli][info] Found matching plugin castamp for URL castamp.com/live/lkmmweikrmrmewqww142e
[cli][info] Available streams: live (worst, best)
[cli][info] Opening stream: live (rtmp)
[cli][error] No data returned from stream

While there should be stream data because the stream is in fact live

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment