From 0c5563f5e4e6ab8da7dfd5f5c15e7be0e3445c15 Mon Sep 17 00:00:00 2001 From: Christopher Rosell Date: Wed, 15 Aug 2012 14:57:58 +0200 Subject: 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. --- src/livestreamer/cli.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') 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: -- cgit v1.2.3