src/streamlink_cli/main.py
def output_stream(plugin, stream):
    """Open stream, create output and finally write the stream to output."""
    global output

    success_open = False
    for i in range(args.retry_open):
        try:
            stream_fd, prebuffer = open_stream(stream)
            success_open = True
            break
        except StreamError as err:
            log.error("Try {0}/{1}: Could not open stream {2} ({3})", i + 1, args.retry_open, stream, err)

    if not success_open:
        console.exit("Could not open stream {0}, tried {1} times, exiting", stream, args.retry_open)

    output = create_output(plugin)

    try:
        output.open()
    except (IOError, OSError) as err:
        if isinstance(output, PlayerOutput):
            console.exit("Failed to start player: {0} ({1})",
                         args.player, err)
        else:
            console.exit("Failed to open output: {0} ({1})",
                         args.output, err)

    with closing(output):
        log.debug("Writing stream to output")
        read_stream(stream_fd, output, prebuffer)

    return True
def output_stream(plugin, stream):
    global output

    success_open = False
    for i in range(args.retry_open):
        try:
            stream_fd, prebuffer = open_stream(stream)
            success_open = True
            break
        except StreamError as err:
            log.error("Try {0}/{1}: Could not open stream {2} ({3})", i + 1, args.retry_open, stream, err)

    if not success_open:
        console.exit("Could not open stream {0}, tried {1} times, exiting", stream, args.retry_open)

    output = create_output(plugin)

    try:
        output.open()
    except (IOError, OSError) as err:
        if isinstance(output, PlayerOutput):
            console.exit("Failed to start player: {0} ({1})",
                         args.player, err)
        else:
            console.exit("Failed to open output: {0} ({1})",
                         args.output, err)

    with closing(output):
        log.debug("Writing stream to output")
        read_stream(stream_fd, output, prebuffer)

    return True
def output_stream ( plugin , stream ) : global output success_open = False for i in range ( args . retry_open ) : try : stream_fd , prebuffer = open_stream ( stream ) success_open = True break except StreamError as err : log . error ( "Try {0}/{1}: Could not open stream {2} ({3})" , i + 1 , args . retry_open , stream , err ) if not success_open : console . exit ( "Could not open stream {0}, tried {1} times, exiting" , stream , args . retry_open ) output = create_output ( plugin ) try : output . open ( ) except ( IOError , OSError ) as err : if isinstance ( output , PlayerOutput ) : console . exit ( "Failed to start player: {0} ({1})" , args . player , err ) else : console . exit ( "Failed to open output: {0} ({1})" , args . output , err ) with closing ( output ) : log . debug ( "Writing stream to output" ) read_stream ( stream_fd , output , prebuffer ) return True
Open stream, create output and finally write the stream to output.
Open stream create output and finally write the stream to output .