Skip to content

Streamlink is starting download before user's response for file overwrite #4248

@ghost

Description

Checklist

Streamlink version

Latest stable release

Description

When file output option -o is used to an existing file, Streamlink prints confirmation message for file overwrite and asks for user's response.
However, before the response, Streamlink has already started downloading and continues. If the user responds with "n", this will result in a waste of bandwidth. It can also be confusing when used with -l debug, as the debug messages are printed as if confirmation is ignored.

It would be better to check the output file before opening the stream.

In the debug log below, I responded with "n" after [stream.segmented][debug] Closing writer thread message.

Debug log

[cli][debug] OS:         macOS 10.12.6
[cli][debug] Python:     3.9.9
[cli][debug] Streamlink: 3.0.3
[cli][debug] Requests(2.26.0), Socks(1.7.1), Websocket(1.2.3)
[cli][debug] Arguments:
[cli][debug]  url=https://www.dailymotion.com/video/x853fvr
[cli][debug]  stream=['480p']
[cli][debug]  --loglevel=debug
[cli][debug]  --output=video.ts
[cli][debug]  --hls-duration=20
[cli][info] Found matching plugin dailymotion for URL https://www.dailymotion.com/video/x853fvr
[plugins.dailymotion][debug] Found media ID: x853fvr
[utils.l10n][debug] Language code: en_US
[cli][info] Available streams: 112p_alt (worst), 112p, 184p_alt, 184p, 288p_alt, 288p, 480p_alt, 480p, 720p_alt, 720p, 1080p_alt, 1080p (best)
[cli][info] Opening stream: 480p (hls)
[stream.hls][debug] Reloading playlist
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] First Sequence: 0; Last Sequence: 53
[stream.hls][debug] Start offset: 0; Duration: 20; Start Sequence: 0; End Sequence: 53
[stream.hls][debug] Adding segment 0 to queue
[stream.hls][debug] Adding segment 1 to queue
[stream.hls][debug] Adding segment 2 to queue
[stream.hls][debug] Adding segment 3 to queue
[stream.hls][debug] Adding segment 4 to queue
[stream.hls][debug] Adding segment 5 to queue
[stream.hls][debug] Adding segment 6 to queue
[stream.hls][info] Stopping stream early after 20
[stream.segmented][debug] Closing worker thread
[stream.hls][debug] Segment 0 complete
[cli][debug] Checking file output
File video.ts already exists! Overwrite it? [y/N] [stream.hls][debug] Segment 1 complete
[stream.hls][debug] Segment 2 complete
[stream.hls][debug] Segment 3 complete
[stream.hls][debug] Segment 4 complete
[stream.hls][debug] Segment 5 complete
[stream.hls][debug] Segment 6 complete
[stream.segmented][debug] Closing writer thread
n
[cli][info] Closing currently open stream...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions