aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Christopher Rosell <chrippa@tanuki.se>2012-08-15 14:57:58 +0200
committerGravatar Christopher Rosell <chrippa@tanuki.se>2012-08-15 14:57:58 +0200
commit0c5563f5e4e6ab8da7dfd5f5c15e7be0e3445c15 (patch)
tree41d89fc99d1b5cd51821d439d2f5dce51352ee97 /src
parent327585ccd49ca5af013c25d6e1eb851570e7a095 (diff)
Prebuffer some data before outputing to player/file.
This is a simple way to check if stream server is dead/has problems before launching a player/file output.
Diffstat (limited to 'src')
-rw-r--r--src/livestreamer/cli.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/livestreamer/cli.py b/src/livestreamer/cli.py
index 5ce15c5..9dc1098 100644
--- a/src/livestreamer/cli.py
+++ b/src/livestreamer/cli.py
@@ -105,6 +105,11 @@ def output_stream(stream, args):
except livestreamer.StreamError as err:
exit(("Could not open stream - {0}").format(err))
+ try:
+ prebuffer = fd.read(8192)
+ except IOError:
+ exit("Failed to read data from stream")
+
if args.output:
if args.output == "-":
out = stdout
@@ -134,6 +139,8 @@ def output_stream(stream, args):
import msvcrt
msvcrt.setmode(out.fileno(), os.O_BINARY)
+ out.write(prebuffer)
+
try:
write_stream(fd, out, progress)
except KeyboardInterrupt: