Giter VIP home page Giter VIP logo

livestreamer's People

Contributors

asermax avatar athoik avatar blxd avatar boekkooi avatar breunigs avatar chhe avatar chrippa avatar danielkza avatar darvelo avatar daslicious avatar ell avatar feverqwe avatar gapato avatar hannespetur avatar henkman avatar intact avatar jaimemf avatar jantore avatar john-peterson avatar jtsymon avatar kasper93 avatar mammothb avatar meise avatar monkeyphysics avatar paulguy avatar pavlos256 avatar toadking avatar weinerrinkler avatar wolftankk avatar wormeyman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

livestreamer's Issues

global name 'file' is not defined

Traceback (most recent call last):
File "/usr/bin/livestreamer", line 9, in
load_entry_point('livestreamer==1.0.0', 'console_scripts', 'livestreamer')()
File "/usr/lib/python3.2/site-packages/livestreamer/cli.py", line 159, in main
handle_url(args)
File "/usr/lib/python3.2/site-packages/livestreamer/cli.py", line 131, in handle_url
output_stream(stream, args)
File "/usr/lib/python3.2/site-packages/livestreamer/cli.py", line 78, in output_stream
fd = stream.open()
File "/usr/lib/python3.2/site-packages/livestreamer/stream.py", line 21, in open
stream = self.cmd(**self.params)
File "/usr/lib/python3.2/site-packages/pbs.py", line 415, in call
if isinstance(err, file): stderr = err
NameError: global name 'file' is not defined

after installing python-pbs I am now getting this error

pkg_resources.DistributionNotFound: requests>=0.12.1

└─╼ livestreamer http://twitch.tv/day9tv live (⌐■_■)
Traceback (most recent call last):
File "/usr/bin/livestreamer", line 5, in
from pkg_resources import load_entry_point
File "/usr/lib/python3.2/site-packages/pkg_resources.py", line 2816, in
working_set.require(requires)
File "/usr/lib/python3.2/site-packages/pkg_resources.py", line 690, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3.2/site-packages/pkg_resources.py", line 588, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: requests>=0.12.1

I have the current livestreamer from git, python-pbs from git, and this is the error I am getting
Thanks

Can't get it to work under windows

I have RTMPDump version 2.4 git-6230845 2011-9-25 and VLC 2.0.2. I put rtmpdump and vlc in path and when I start livestreamer with url and quality (best) it launches vlc but see nothing in cmd and nothing plays on VLC.

sites on ustream cannot be accessed

livestreamer -c http://www.ustream.tv/channel/nied4maps-ii

will get the following result :

[cli][info] Found matching plugin ustreamtv for URL http://www.ustream.tv/channel/nied4maps-ii
Traceback (most recent call last):
File "/usr/local/bin/livestreamer", line 9, in
load_entry_point('livestreamer==1.3.2', 'console_scripts', 'livestreamer')()
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/cli.py", line 328, in main
handle_url(args)
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/cli.py", line 255, in handle_url
streams = channel.get_streams()
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/plugins/init.py", line 67, in get_streams
streams = self._get_streams()
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/plugins/ustreamtv.py", line 43, in _get_streams
packet = AMF0Packet.deserialize(BytesIO(res.content))
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/packet.py", line 41, in deserialize
return cls._deserialize(io)
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/amf0.py", line 114, in _deserialize
message = AMF0Message.deserialize(io=io)
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/packet.py", line 41, in deserialize
return cls._deserialize(io)
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/amf0.py", line 62, in _deserialize
value = io.read_script_value()
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/packet.py", line 291, in read_script_value
return self.read_script_object(ScriptData.Object())
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/packet.py", line 353, in read_script_object
value = self.read_script_value()
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/packet.py", line 291, in read_script_value
return self.read_script_object(ScriptData.Object())
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/packet.py", line 353, in read_script_object
value = self.read_script_value()
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/packet.py", line 291, in read_script_value
return self.read_script_object(ScriptData.Object())
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/packet.py", line 353, in read_script_object
value = self.read_script_value()
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/packet.py", line 288, in read_script_value
return self.read_script_string()
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3.2-py2.7.egg/livestreamer/packages/flashmedia/packet.py", line 347, in read_script_string
return str(val, "utf8")
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe8 in position 999: unexpected end of data

using ubuntu precise amd64 12GB RAM
uname -a
Linux mainpc-desktop 3.2.0-30-generic #48-Ubuntu SMP Fri Aug 24 16:52:48 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux


BTW... not all ustream have problem... only some of them.. (some ustrems works fine)

Remove Distuitls Check

Dear @chrippa,

Aftrer the change in commit 167b49f

deps.append("sh>=1.07,<2.0")

There is no need for distutils check and no need to import distutils.

from distutils.version import LooseVersion
        if LooseVersion(sh.__version__) >= LooseVersion("1.07"):

Add Plugin for ilive.to

Dear @chrippa,

Please find below a plugin for ilive.to

from livestreamer.compat import unquote
from livestreamer.stream import RTMPStream
from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.utils import urlget

import re

class ILive(Plugin):
    SWFURL = "http://cdn.static.ilive.to/jwplayer/player.swf"

    @classmethod
    def can_handle_url(self, url):
        return "ilive.to" in url

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

        match = re.search(".+?flashvars=\"&streamer=(.+)?&file=(.+?).flv&.+?\"", res.text)
        if not match:
            raise NoStreamsError(self.url)

        rtmp = unquote(match.group(1))
        playpath = match.group(2)

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

        return streams


__plugin__ = ILive

The above stream service uses redirect, but we need a fix in order to get it working.

When we are trying to connect to rtmp://live.ilive.to/redirect the tcUrl is different. Port is added.

DEBUG: tcUrl    : rtmp://live.ilive.to:1935/redirect

With the change below in _update_redirect, redirect now works.

            if "rtmp" in self.params:
                if tcurl in self.params["rtmp"]:
                    self.params["rtmp"] = self.params["rtmp"].replace(tcurl, redirect)
                else:
                    self.params["rtmp"] = redirect

Are there any improvements before push the plugin?

Thanks,

EDIT1. Channels are here http://www.ilive.to/channels

Playback stops in few seconds after start on twitch.tv with live quality

  • Arch Linux i686
  • packages version:
    • livestreamer-git 20121023-1
    • mplayer2-git 20120924-6
    • ffmpeg-git 20121027-1
    • x264-git 20121027-1
    • rtmpdump-git 20121027-1
───╼ ~ livestreamer -l debug twitch.tv/apoctv best
[cli][info] Found matching plugin justintv for URL twitch.tv/apoctv
[plugin.justintv][debug] Fetching stream info
[cli][info] Opening stream: best
[cli][debug] Pre-buffering 8192 bytes
[cli][info] Starting player: mplayer
[cli][debug] Writing stream to output
MPlayer2 95e81df (C) 2000-2012 MPlayer Team

Playing -.
Reading from stdin...
Detected file format: FLV (Flash Video) (libavformat)
[flv @ 0x8756880]max_analyze_duration reached
[flv @ 0x8756880]Estimating duration from bitrate, this may be inaccurate
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (aac), -aid 0
Clip info:
 author: 
 copyright: 
 description: 
 keywords: 
 rating: 
 title: 
 presetname: Custom
 creationdate: Sat Oct 27 12:27:39 2012
 videodevice: XSplitBroadcaster
 avclevel: 32
 avcprofile: 100
 videokeyframe_frequency: 0
 audiodevice: VHAudioCustom
 audiochannels: 2
 audioinputvolume: 100
 bufferSize: 4000k
 maxBitrate: 4000k
 xsplitBroadcasterVersion: 1.3.0.51
 xsplitCoreVersion: 1.1.1210.1801 Version 1.1
 xsplitGameSourceVersion: 1.1.1.15
 xsplitMediaLibVersion: 2.0.0.149
Load subtitles in .
Forced video codec: ffh264vdpau
Selected video codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration) [libavcodec]
Selected audio codec: AAC (Advanced Audio Coding) [libavcodec]
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Starting playback...
VIDEO:  1280x720  60.000 fps  400.0 kbps (50.0 kB/s)
VO: [vdpau] 1280x720 => 1280x720 H.264 VDPAU acceleration 
[vdpau] Got display refresh rate 59.883 Hz.
[vdpau] If that value looks wrong give the -vo vdpau:fps=X suboption manually.
A:  14.5 V:  14.5 A-V: -0.000 ct: -0.000   0/  0  1%  0%  1.2% 0 0 

No module named stream

ceback (most recent call last):
File "/usr/local/bin/livestreamer", line 9, in
load_entry_point('livestreamer==1.3', 'console_scripts', 'livestreamer')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2279, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1989, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "/usr/local/lib/python2.7/dist-packages/livestreamer-1.3-py2.7.egg/livestreamer/init.py", line 6, in
from .stream import StreamError
ImportError: No module named stream

I guess the commits for stream.py broke something?

pkg_resources.DistributionNotFound: pbs

Traceback (most recent call last):
File "/usr/bin/livestreamer", line 5, in
from pkg_resources import load_entry_point
File "/usr/lib/python3.2/site-packages/pkg_resources.py", line 2736, in
working_set.require(requires)
File "/usr/lib/python3.2/site-packages/pkg_resources.py", line 690, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3.2/site-packages/pkg_resources.py", line 588, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pbs

DistributionNotFound: pbs

File "/usr/bin/livestreamer", line 5, in
from pkg_resources import load_entry_point
File "/usr/lib/python3.2/site-packages/pkg_resources.py", line 2736, in
working_set.require(requires)
File "/usr/lib/python3.2/site-packages/pkg_resources.py", line 690, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3.2/site-packages/pkg_resources.py", line 588, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pbs

I am getting this error with the current version

Feature Request: espn3

I love watching twitch.tv with this, Is there any chance you could add a site like espn3 which does live sports? Thanks

Plugin: Mips

Dear @chrippa,

I just wrote a plugin for mips.tv

from livestreamer.stream import RTMPStream
from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.utils import urlget

import re

class Mips(Plugin):
    SWFURL = "http://mips.tv/content/scripts/eplayer.swf"
    PlayerURL = "http://mips.tv/embedplayer/{0}/1/500/400"
    BalancerURL = "http://www.mips.tv:1935/loadbalancer"

    @classmethod
    def can_handle_url(self, url):
        return "mips.tv" in url

    def _get_streams(self):
        channelname = self.url.rstrip("/").rpartition("/")[2].lower()

        self.logger.debug("Fetching stream info")

        headers = {
            "Referer": self.url
        }

        res = urlget(self.PlayerURL.format(channelname), headers=headers)

        match = re.search("'FlashVars', '(id=\d+)&", res.text)
        if not match:
            raise NoStreamsError(self.url)

        channelname += "?" + match.group(1)

        res = urlget(self.BalancerURL, headers=headers)

        match = re.search("redirect=(.+)", res.text)
        if not match:
            raise NoStreamsError(self.url)

        rtmp = match.group(1)

        streams = {}

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

        return streams


__plugin__ = Mips

Are there any improvements before push the plugin?

Thanks

Test URL's found from here:
http://livetvstreaming.ucoz.com/news/al_jazeera_sport/2012-09-02-1837
http://mips.tv/aflam4you1
http://mips.tv/aflam4you4

Could not open stream

I'm getting this error every time I try to open a stream:
error: Could not open stream - Error while executing subprocess

I'm using Ubuntu 12.04 and have the last git of rtmpdump installed. It happens for both twitch.tv and own3d.tv streams.

GOMTV VOD support

I am curious if the gomtv plugin can be extended to also support the gomtv.net paid VODs at, e.g.,

http://www.gomtv.net/2012gsls5/vod/70988/?set=7

Authentication is already implemented I guess, however, it would be nice if the sets are automatically incremented when one set finished. I will give it a try to implement this support, but I have no experience implementing this type of problems. Any suggestions would be great :D

Greets Janick

VLC fails on Ubuntu 12.04

Ubuntu 12.04 here.

rtmpdump version from repo: 2.4~20110711.gitc28f1bab-1

michal@michal-F5N ~/Pobrane/chrippa-livestreamer-ad4b6b9 $ livestreamer http://pl.twitch.tv/ignproleague 360p

michal@michal-F5N ~/Pobrane/chrippa-livestreamer-ad4b6b9 $ VLC media player 2.0.1 Twoflower (revision 2.0.1-0-gf432547)
[0x8c15908] main libvlc: Uruchamianie vlc z domyślnym interfejsem. Użyj 'cvlc' aby używać vlc bez interfejsu.
"sni-qt/4261" WARN 13:10:38.405 void StatusNotifierItemFactory::connectToSnw() Invalid interface to SNW_SERVICE
[0xb7000cd8] main stream error: cannot pre fill buffer

Any ideas?

Question about memory

I used livestreamer to dump the 4 WCS streams to watch later.

The RAM used got bigger and bigger. From what I have seen livestreamer use rtmpdump so maybe the problem is on this side ?

I give you the command i used. It seems the RAM used is the filesize, maybe it's normal and can't be worked around. If so i am thinking to stop regulary the script and change to output file.

Tell me if it's normal. So I will look to kill the script at some time and use some name increment.

I used

livestreamer "http://ko.twitch.tv/sc2_4" best -o /media/stream4_1.flv
and livestreamer "http://ko.twitch.tv/sc2_4" best -O > /media/stream4_1.flv
with same memory growth.

The option --fifo is only to make some kind of livestreamer --fifo | vlc ? Or could it help to dump the file and not store on RAM ?

I understand the main goal of the script is not to save but to display. Should I use a player like mplayer and use mplayer to dump ?

rtmpdump version

error: Could not open stream - Installed rtmpdump does not support --jtv argument

global name 'file' is not defined

File "C:\Python32\Scripts\livestreamer-script.py", line 9, in
load_entry_point('livestreamer==1.3', 'console_scripts', 'livestreamer')()
File "C:\Python32\lib\site-packages\livestreamer-1.3-py3.2.egg\livestreamer\cl
i.py", line 315, in main
handle_url(args)
File "C:\Python32\lib\site-packages\livestreamer-1.3-py3.2.egg\livestreamer\cl
i.py", line 277, in handle_url
output_stream(stream, args)
File "C:\Python32\lib\site-packages\livestreamer-1.3-py3.2.egg\livestreamer\cl
i.py", line 220, in output_stream
if is_win32 and type(out) is file:
NameError: global name 'file' is not defined

Memory Usage

Dear all,

I am running the follwing script:

from livestreamer import Livestreamer

url = "hlsvariant://http://alfatileorasi-i.akamaihd.net/hls/live/206280/alfatileorasi/master.m3u8"

while True:
    livestreamer = Livestreamer()
    channel = livestreamer.resolve_url(url)
    streams = channel.get_streams()
    stream = streams["best"]

    print "Reopening Stream ", stream

    fd = stream.open()
    cnt = 1
    while True:
        data = fd.read(4096)
        if len(data) == 0:
            break
        if cnt > 500:
            break
        cnt += 1
        # do something with data

    # All streams are not guaranteed to support .close()
    if hasattr(fd, "close"):
        fd.close()
athoik@pc:/tmp$ python test.py
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x2541710>
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x2549d10>
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x2549490>
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x27b2fd0>
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x27c3ad0>
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x2821810>
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x2821890>
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x2852ed0>
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x284fd90>
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x2896a10>
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x2890290>
Reopening Stream  <livestreamer.stream.hls.HLSStream object at 0x284f690>
...

And the memory is increasing over the time. Is there a way to release memory?

If we are using livestreamer as library in a python program after some "zapping" all available memory is consumed..

own3d.tv problems

Unable to parse status XML: junk after document element: line 2, column 0)

Plugin: Freedocast

Hello,

I just wrote a plugin for freedocast.com

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):
        playpath = self.url.rstrip("/").rpartition("/")[2].lower()

        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)

        RefererHeaders = {
            "Referer": self.url
        }

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

        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

There are test streams from here: http://www.freedocast.com/channels.aspx?pn=1&order=l

@chrippa are there any improvements?

Thanks.

Plugin: Add yycast.com plugin

Dear @chrippa ,

I am attaching a yycast.com plugin.

from livestreamer.stream import RTMPStream
from livestreamer.plugins import Plugin, PluginError, NoStreamsError

import re

class YYCast(Plugin):
    StreamURL = "rtmp://212.7.212.22:1935/lb/{0}"
    SWFURL = "http://cdn.yycast.com/player/player.swf"
    PageURL = "http://www.yycast.com"

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

    def _get_redirected_stream_url(self, channelname):
        try:
            from sh import rtmpdump
            r = rtmpdump(rtmp=self.StreamURL.format(channelname), swfVfy=self.SWFURL, pageUrl=self.PageURL, live=True, verbose=True)
            r = None
        except Exception as e:
            if not e.__dict__["stderr"]:
                raise NoStreamsError(self.url)
            self.StreamURL = re.findall("redirect,\s+STRING:\s+(rtmp://.*?)>", e.stderr)
            if not self.StreamURL:
                raise NoStreamsError(self.url)
            self.logger.debug("Redirected Stream URL is {0}", self.StreamURL[0])
            self.StreamURL = self.StreamURL[0] + "/{0}"

    def _get_streams(self):
        channelname = self.url.rstrip("/").rpartition("/")[2].lower()

        self._get_redirected_stream_url(channelname)

        streams = {}

        try:
            stream = RTMPStream(self.session, {
                "rtmp": self.StreamURL.format(channelname),
                "swfVfy": self.SWFURL,
                "pageUrl": self.PageURL,
                "live": True
               })
            streams["live"] = stream
        except IOError:
            raise NoStreamsError(self.url)

        return streams


__plugin__ = YYCast

Please review the code, make suggestions and i will commit them, when coding style and logic is ok.

yycast.com uses redirects, and currently rtmpdump is not handling redirects. So in _get_redirected_stream_url we find the redirected rtmp stream (an exception must occurred!).

DEBUG: Property: <Name:           redirect, STRING:     rtmp://xxx.yyy.zzz.ddd:1935/live/_definst_>

Maybe _get_redirected_stream_url must be more generic? Does sh works in Windows?

There are several yycast live streams here : http://cricfree.tv/live/index.php

Test example:

livestreamer http://yycast.com/gtgr56tg live -l debug

New twitch.tv layout is adding extra characters to the rtmpdump jtv token

Here's an example of the console command generated by livestreamer:

rtmpdump --swfUrl http://www.justin.tv/widgets/live_embed_player.swf --jtv 73bb005b37fb119ba4ad02261139812723209fbd:{"swfDomains": <<<<  ["justin.tv", "jtvx.com", "xarth.com", "twitchtv.com", "twitch.tv", "newjtv.com", "jtvnw.net", "wdtinc.com", "imapweather.com", "facebook.com", "starcrafting.com"], "streamName": "akamai4_349@24975", "expiration": 1339884084.1537421, "server": "akamai"} --flv - --live --rtmp rtmp://live-cdn.jtvnw.net/live/akamai4_349@24975 --swfsize 633838 --swfhash a123dac970e3164aa2bf997e00d568cc4de31835cfaf32c5c03ae39698f5283d | mplayer2 -quiet  -

The command causes livestreamer to fail, but the stream works fine if I remove the 4 < signs from the command manually.

Add Plugin for cast3d.tv

Dear @chrippa ,

Please find below a plugin for cast3d.tv

from livestreamer.compat import urlparse
from livestreamer.stream import RTMPStream
from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.utils import urlget

import re

class Cast3d(Plugin):
    SWFURL = "http://www.cast3d.biz/player.swf"
    PlayerURL = "http://www.cast3d.tv/embed.php?channel={0}&vw=580&vh=390&domain=www.cast3d.tv"

    @classmethod
    def can_handle_url(self, url):
        return "cast3d.tv" in url

    def _get_streams(self):
        channelname = urlparse(self.url).path.rstrip("/").rpartition("/")[-1].lower()

        self.logger.debug("Fetching stream info")

        headers = {
            "Referer": self.url,
            "Accept-Encoding": "deflate"
        }

        res = urlget(self.PlayerURL.format(channelname), headers=headers)

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

        rtmp = match.group(1)

        if rtmp.startswith("http://"):
            raise PluginError("VOD {0} found on url {1}".format(rtmp,self.url))

        redirect = False
        if "redirect" in rtmp:
            redirect = True

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

        return streams


__plugin__ = Cast3d

Some videos are VOD like this one:

http://www.cast3d.tv/channel/games14

I am raising plugin Error, or is better to raise NoStreamsError?

Some videos are using rtmp redirect like this one:

http://www.cast3d.tv/channel/hrewgwegweg

When streamer contains the redirect i am enabling the redirect flag. Is better to keep always on?

Are there any improvements before push the plugin?

Thanks

PS. Happy new Year!

Feature: twitch.tv / justin.tv archived video (VOD) support

Hi!

I am wondering if it could be possible to extend the justin.tv plugin to also support archived videos that have urls like

http://nl.twitch.tv/jeffroiscool/b/299079587

The important part is the 299079587 video id. This ID can be used with the twitch.tv api to obtain the video url by, e.g.,

http://api.justin.tv/api/clip/show/299079587.xml

(see http://www.fakegaming.eu/TwitchTV/source/download.txt / http://www.fakegaming.eu/TwitchTV/download.php for a php implementation). Perhaps there is also another way to do this using some established livestreamer features. I primarily want to use it to automatically download archived videos to watch them, e.g., on my mobile phone.

rtmpdump: unrecognized option `--jtv'

Hi I installed rtmpdump using : git://git.ffmpeg.org/rtmpdump
But I launch

livestream http://twitch.tv/followgrubby 720p

I got this error :

rtmpdump: unrecognized option `--jtv'

Fixing justintv channel name parser if mature content is enabled.

Patch

0001-fixing.justintv.channel.name.parser.for.mature.content.patch

Currently livestreamer justin.tv/poker_videos best return error: No streams found on this URL: http://justin.tv/poker_videos because without a login session www.justin.tv/poker_videos is redirected to www.justin.tv/poker_videos/mature_content.

There's no need to check the page content at this stage because if an offline or nonexisting channel is given http://usher.justin.tv/find/channel.xml return <nodes><nodes> which makes livestreamer justin.tv/channel best return error: No streams found on this URL: justin.tv/channel at cli.py#L155.

Reading the channel name from url instead of the page content is also robust to page changes and therefore a better solution.

Livestreamer attribute close

Hello,

When trying the following example from the docs an error occurres!

from livestreamer import Livestreamer

url = "http://twitch.tv/day9tv"
livestreamer = Livestreamer()
channel = livestreamer.resolve_url(url)
streams = channel.get_streams()

stream = streams["720p"]
fd = stream.open()

while True:
    data = fd.read(1024)
    if len(data) == 0:
        break

    # do something with data

fd.close()

We are getting the following error:

    fd.close()
AttributeError: 'RTMPStream' object has no attribute 'close'

Seems ustreams modified the site and make command not 100% work

Command :
livestreamer -l debug http://www.ustream.tv/channel/narita-live-asahi-north-camera live

Output :
[cli][info] Found matching plugin ustreamtv for URL http://www.ustream.tv/channel/narita-live-asahi-north-camera
[plugin.ustreamtv][debug] Fetching stream info
[cli][info] Opening stream: live
[cli][debug] Pre-buffering 8192 bytes
error: Failed to read data from stream

Sympton : it is ok to playback via browser and some sites (not too many) in ustream.com is okay
System : ubuntu 12.04 on AMD64 cpu 12GB Memory

Thanks!

2 feature suggestions

1 - Bookmarking: instead of typing the url and the quality, being able to load a stream with just a word would be cool!

2 - Periodical resync: if some lag happens, the stream tends to fall behind the actual streaming process, a periodical sync with the stream flow would be nice!

HLSStream does not work without EXT-X-STREAM-INF

Hello everybody,

I just wrote a plugin for streamingvideoprovider.co.uk, but livestreamer cannot parse the HSL Stream.

I notice that HLSStream is unable to work with HLS Streams that do not provide the tag EXT-X-STREAM-INF. Although it is possible to have HLS streams that do not provide such information.

streamingvideoprovider.co.uk returns the following m3u8, not containing EXT-X-STREAM-INF.

#EXTM3U
#EXT-X-MEDIA-SEQUENCE:2809
#EXT-X-TARGETDURATION:6
#EXTINF:8,
/hls/7zlyq17szhc0o0wwsg4o/2809.ts
#EXTINF:5,
/hls/7zlyq17szhc0o0wwsg4o/2810.ts
#EXTINF:5,
/hls/7zlyq17szhc0o0wwsg4o/2811.ts

The idea was to use livestreamer for channels exist here: http://www.cybc.com.cy/index.php/watch-live

RIK SAT High http://hls1.webvideocore.net/hls/7zlyq17szhc0o0wwsg4o/index.m3u8
RIK SAT Low http://hls1.webvideocore.net/hls/321zr8ytcoaokgos4o80/index.m3u8

Here is my plugin:

from livestreamer.stream import HLSStream
from livestreamer.plugins import Plugin, PluginError, NoStreamsError
from livestreamer.utils import urlget

from time import time
import re

class Streamingvideoprovider(Plugin):
    HLSStreamURL = "http://player.webvideocore.net/index.php?l=info&a=ajax_video_info&file={0}&rid={1}"
    PlaylistURL = None

    @classmethod
    def can_handle_url(self, url):
        return "streamingvideoprovider.co.uk" in url

    def _get_streams(self):
        channelname = self.url.rstrip("/").rpartition("/")[2].lower()
        unixtime = str(int(time()))
        try:
            res = urlget(self.HLSStreamURL.format(channelname, unixtime))
            self.PlaylistURL = re.search("'(http://.+\.m3u8)'", res.text).group(1)
            self.logger.info(self.PlaylistURL)
            streams = HLSStream.parse_variant_playlist(self.session,
                                                       self.PlaylistURL)
        except IOError:
            raise NoStreamsError(self.url)

        return streams


__plugin__ = Streamingvideoprovider

Thanks,
@athoik

Feature: Add HTTP Streaming Server

Dear all,

Inspired from the rtmpgw stream process, it would be great to have this in livestreamer.

In the GET the client can send the URL and then livestreamer will send the data to socket instead of sending to STDOUT or to PIPE.

Probably using twisted framework a mutlithreaded server can be build!

Using the following code (i know is ugly, but it works), i was able to stream data to player!

import socket
from livestreamer import Livestreamer

HOST = '192.168.1.2'      # Symbolic name meaning the local host
PORT = 2886               # Arbitrary non-privileged port

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)

conn, addr = s.accept()
print 'Connected by', addr
print conn.recv(1024)
conn.send("HTTP/1.0 200 OK%sContent-Type: video/mpeg\r\n\r\n" % "\r\nServer: HTTP-RTMP Stream Server 007\r\n")
#print conn.recv(1024)

url = "XXX" #FILME

livestreamer = Livestreamer()
channel = livestreamer.resolve_url(url)
streams = channel.get_streams()

stream = streams["best"]
print "Stream... ", stream
fd = stream.open()

while True:
    data = fd.read(1024)
    if len(data) == 0:
        break
    conn.send(data)

conn.close()
# All streams are not guaranteed to support .close()
if hasattr(fd, "close"):
    fd.close()

What do you think of this?

Create a plugin for raw-rtmp

Dear all,

I would like to discuss a new feature for livestreamer. A plugin for raw rtmp commands.

The idea is to have livestreamer as a library, a library that can handle rtmpdump, instead of calling the rtmpdump directly.

Most probably the RTMPStream class should be used and parser should created for the arguments, that will be passed to RTMPStream.

            stream = RTMPStream(self.session, {
                "rtmp": rtmp,
                "swfVfy": swfurl,
                "live": True,
                ...
                ...
            })

Do you find this usefull?

Its ok to create a plugin?

Livestream Channel API

Dear all,

I would like to specially thank @chrippa and all guys participating on the project. Keep the amazing job!

I bielieve there is a possibility to use Livestream Channel API in order to receive HLS live streams.

Here you can find information about the Channel API:

http://www.livestream.com/userguide/index.php?title=Channel_API_2.0

(note below, api is 3.0)

http://xCHANNELx.api.channel.livestream.com/3.0/info.xml
http://xCHANNELx.api.channel.livestream.com/3.0/playlist.m3u8

Add the character 'x' at the beginning and at the end of the channel name.
Replace all underscore ("_") characters (if any) in the channel name by a hyphen ("-")
Append .api.channel.livestream.com/2.0 to the above formed string. 

We can directly call the playlist.m3u8 (and see if there is a live stream).

Example:

URL:

http://xastratelevisionx.api.channel.livestream.com/3.0/playlist.m3u8

Returns:

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=250000
http://ichunk.livestream.com/212.96/livestreamiphone/astratelevision-livestream/playlist.m3u8?wowzasessionid=117107580
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=52
http://ichunk.livestream.com/212.96/livestreamiphone/astratelevision-livestream/playlist.m3u8?wowzaaudioonly&wowzasessionid=117107580

Thanks,
@athoik

twitch.tv livestream configuration

Thanks for cool app, but i had to update config to make vlc wotk with live stream.

first, you have to remove cache option from vlc argument
second, yoy have to add "-" as the last argument to vlc

"e:\VLC\vlc.exe -"

this line works,

thx.

"
E:\Livestreamer\livestreamer.exe twitch.tv/sltvmain 360p

[cli][info] Found matching plugin justintv for URL twitch.tv/sltvmain
[plugin.justintv][debug] Fetching stream info
[cli][info] Opening stream: 360p
[cli][debug] Pre-buffering 8192 bytes
[cli][info] Starting player: E:\VLC\vlc.exe -
[cli][debug] Writing stream to output

"

Laggy Streams (caching problem)

VLC opens files with a 300ms buffer and its causing problems for us people with less than perfect internet connections.

Perhaps opening VLC with a custom buffer size could help I'm still getting intermittent issues with 3000ms so customisable setting would be a must and 3000ms seems excessive as a default since actual files don't need it.

The other idea is to use rtmpgw instead and write the stream to HTTP this allows for the client to pause-play and the stream to still be valid and uses VLCs network buffer setting instead.

twitch.tv doesn't work

Hi,

this project looks very promising, thanks for creating it! :)
I have installed the latest git versions of both livestreamer and rtmpdump (on Linux).

I tried different twitch.tv streams, none of them seems to work. VLC player just opens and does nothing.
When I run livestreamer with -c and then copy and paste it into the terminal, it stops with different error messages (depending on the stream I try):
INFO: Connected... [this is before every error message]
ERROR: Closing connection: NetStream.Play.StreamNotFound
ERROR: RTMP_ReadPacket, failed to read RTMP packet header [the second time I tried the same stream/command, I just got a StreamNotFound]
ERROR: Closing connection: NetStream.Play.Failed

Any ideas?
Thank you

fails on http://www.own3d.tv/live/330

works very well on almost anything i've thrown at it except this stream:

$ livestreamer http://www.own3d.tv/live/330 best -o test.flv
RTMPDump v2.4
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
Connecting ...
WARNING: HandShake: client signature does not match!
INFO: Connected...
Starting Live Stream

any idea what might be causing it?

own3d.tv online status

Currently the only plugin that can't be used to test the online status of a stream is the own3d plugin. The problem is that in the XML data (http://www.own3d.tv/livecfg/channelid) that livestreamer looks at, the attribute "live" is always set to "true" even when the stream is offline.

If anyone finds a way to check online status (that doesn't involve fetching the stream itself, which the flash player does) please post your findings here.

OSError: [Errno 13] Permission denied

I have an error when I try to play a twitch stream.
rtmpdump: git version
the same error is on python2.7 as well as on python3.1
os: linux 32 bit

livestreamer --rtmpdump=. --player=mplayer http://pl.twitch.tv/rockalone best
[cli][info] Found matching plugin justintv for URL http://pl.twitch.tv/rockalone
[cli][info] Opening stream: best
Traceback (most recent call last):
File "/usr/bin/livestreamer", line 9, in
load_entry_point('livestreamer==1.2.0', 'console_scripts', 'livestreamer')()
File "/usr/lib/python2.7/site-packages/livestreamer-1.2.0-py2.7.egg/livestreamer/cli.py", line 282, in main
handle_url(args)
File "/usr/lib/python2.7/site-packages/livestreamer-1.2.0-py2.7.egg/livestreamer/cli.py", line 244, in handle_url
output_stream(stream, args)
File "/usr/lib/python2.7/site-packages/livestreamer-1.2.0-py2.7.egg/livestreamer/cli.py", line 153, in output_stream
fd = stream.open()
File "/usr/lib/python2.7/site-packages/livestreamer-1.2.0-py2.7.egg/livestreamer/stream.py", line 74, in open
if "jtv" in self.params and not self._has_jtv_support():
File "/usr/lib/python2.7/site-packages/livestreamer-1.2.0-py2.7.egg/livestreamer/stream.py", line 81, in _has_jtv_support
help = self.cmd(help=True, _err_to_out=True)
File "/usr/lib/python2.7/site-packages/pbs-0.108-py2.7.egg/pbs.py", line 431, in call
cwd=call_args["cwd"], stdin=stdin, stdout=stdout, stderr=stderr)
File "/usr/lib/python2.7/subprocess.py", line 679, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied

TypeError: request() got an unexpected keyword argument 'config'

~ $ livestreamer twitch.tv/day9tv
[cli][info] Found matching plugin justintv for URL twitch.tv/day9tv
Traceback (most recent call last):
  File "/usr/bin/livestreamer", line 9, in <module>
    load_entry_point('livestreamer==1.3.2', 'console_scripts', 'livestreamer')()
  File "/usr/lib/python3.3/site-packages/livestreamer/cli.py", line 328, in main
    handle_url(args)
  File "/usr/lib/python3.3/site-packages/livestreamer/cli.py", line 255, in handle_url
    streams = channel.get_streams()
  File "/usr/lib/python3.3/site-packages/livestreamer/plugins/__init__.py", line 67, in get_streams
    streams = self._get_streams()
  File "/usr/lib/python3.3/site-packages/livestreamer/plugins/justintv.py", line 193, in _get_streams
    rtmpstreams = self._get_rtmp_streams()
  File "/usr/lib/python3.3/site-packages/livestreamer/plugins/justintv.py", line 106, in _get_rtmp_streams
    res = urlget(url, params=params)
  File "/usr/lib/python3.3/site-packages/livestreamer/utils.py", line 128, in urlget
    **args)
  File "/usr/lib/python3.3/site-packages/livestreamer/utils.py", line 120, in urlopen
    res = requests.request(method, url, config=RequestsConfig, timeout=15, **args)
  File "/usr/lib/python3.3/site-packages/requests/api.py", line 38, in request
    return session.request(method=method, url=url, **kwargs)
TypeError: request() got an unexpected keyword argument 'config'

Versions:
python==3.3.0
livestreamer==1.4
requests==1.0.3

Livestreamer process closes randomly while streaming (with a possible cause)

I had some time to make a small GUI Application for Livestreamer that retrieves a stream list from twitch and gives the ability to watch them using LiveStreamer. But I noticed something weird about the LiveStreamer process. It works normally for sometime and then it closes with no appearant reason. The console output it gives is this:
[cli][info] Found matching plugin justintv for URL twitch.tv/therainman
[cli][info] Opening stream: iphonehigh
[cli][info] Starting player: "C:\Program Files\VideoLAN\VLC\vlc.exe" --file-caching=5000
[cli][info] Stream ended

After many times that this happened to me, I noticed a possible cause to this problem which could be frequent pauses of the stream, causing the livestreamer process to crash in some way. I have a pretty slow 3G internet (I can barely watch twitch streams with the "iphonehigh" quality) the stream stops frequently to load up, especially if I'm browsing at the same time. A friend of mine also tested it, but instead of the stream stopping to load he was just pausing it from time to time as he has a faster internet connection... and the livestreamer process also closes for him.

I wonder what's making it behave this way ? is it some kind of lost syncronization between the livestreamer and the player ?

GOM VOD broken since at least revision 52db64b603

With the latest stable i get error: Failed to connect to key check server: timed out

I tried to debug a little bit the script but even trying to "echo" NODEIP, NODEID etc i get a weird error IndentationError: unexpected indent

I am a sysadmin and only decent with scripts and php...

So i downgraded livestreamer with
cd ~
pip uninstall livestreamer
git clone https://github.com/chrippa/livestreamer.git
cd livestreamer
git checkout 52db64b
python setup.py install

And VOD with PASSWORD and COOKIES can be downloaded. Dunno what is the problem atm, I will look at revision to see what could be broken.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.