Skip to content

cli: fix errors on missing stdin fd #6239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

bastimeyer
Copy link
Member

Follow-up of c587485

  • Fix AttributeError when asking for input for required plugin args
  • Fix AttributeError when confirming file output path

master - file output

$ streamlink httpstream://file:///dev/zero best -o /tmp/recording </dev/null
[cli][info] Found matching plugin http for URL httpstream://file:///dev/zero
[cli][info] Available streams: live (worst, best)
[cli][info] Opening stream: live (http)
[cli][info] Writing output to
/tmp/recording
[cli][error] File /tmp/recording already exists, use --force to overwrite it.
$ streamlink httpstream://file:///dev/zero best -o /tmp/recording 0>&-
[cli][info] Found matching plugin http for URL httpstream://file:///dev/zero
[cli][info] Available streams: live (worst, best)
[cli][info] Opening stream: live (http)
[cli][info] Writing output to
/tmp/recording
Traceback (most recent call last):
  File "/home/basti/venv/streamlink-313/bin/streamlink", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 967, in main
    exit_code = run(parser)
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 947, in run
    exit_code = handle_url_wrapper()
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 550, in handle_url_wrapper
    handle_url()
    ~~~~~~~~~~^^
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 614, in handle_url
    handle_stream(plugin, streams, stream_name)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 462, in handle_stream
    success = output_stream(stream, formatter)
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 364, in output_stream
    output = create_output(formatter)
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 119, in create_output
    filename = check_file_output(formatter.path(args.output, args.fs_safe_rules), args.force)
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 88, in check_file_output
    if sys.stdin.isatty():
       ^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'isatty'

master - required plugin args

$ streamlink clubbingtv.com </dev/null
Traceback (most recent call last):
  File "/home/basti/venv/streamlink-313/bin/streamlink", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 967, in main
    exit_code = run(parser)
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 947, in run
    exit_code = handle_url_wrapper()
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 550, in handle_url_wrapper
    handle_url()
    ~~~~~~~~~~^^
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 584, in handle_url
    options = setup_plugin_options(streamlink, args, pluginname, pluginclass)
  File "/home/basti/repos/streamlink/src/streamlink_cli/argparser.py", line 1544, in setup_plugin_options
    value = user_input_requester.ask(prompt)
  File "/home/basti/repos/streamlink/src/streamlink_cli/console.py", line 21, in ask
    raise OSError("no TTY available")
OSError: no TTY available
$ streamlink clubbingtv.com 0>&-
Traceback (most recent call last):
  File "/home/basti/venv/streamlink-313/bin/streamlink", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 967, in main
    exit_code = run(parser)
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 947, in run
    exit_code = handle_url_wrapper()
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 550, in handle_url_wrapper
    handle_url()
    ~~~~~~~~~~^^
  File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 584, in handle_url
    options = setup_plugin_options(streamlink, args, pluginname, pluginclass)
  File "/home/basti/repos/streamlink/src/streamlink_cli/argparser.py", line 1544, in setup_plugin_options
    value = user_input_requester.ask(prompt)
  File "/home/basti/repos/streamlink/src/streamlink_cli/console.py", line 20, in ask
    if not sys.stdin.isatty():
           ^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'isatty'

PR - file output

$ streamlink httpstream://file:///dev/zero best -o /tmp/recording </dev/null
[cli][info] Found matching plugin http for URL httpstream://file:///dev/zero
[cli][info] Available streams: live (worst, best)
[cli][info] Opening stream: live (http)
[cli][info] Writing output to
/tmp/recording
[cli][error] File /tmp/recording already exists, use --force to overwrite it.
$ streamlink httpstream://file:///dev/zero best -o /tmp/recording 0>&-
[cli][info] Found matching plugin http for URL httpstream://file:///dev/zero
[cli][info] Available streams: live (worst, best)
[cli][info] Opening stream: live (http)
[cli][info] Writing output to
/tmp/recording
[cli][error] File /tmp/recording already exists, use --force to overwrite it.

PR - required plugin args

$ streamlink clubbingtv.com </dev/null
error: no TTY available
$ streamlink clubbingtv.com 0>&-
error: no TTY available

Follow-up of c587485

- Fix `AttributeError` when confirming file output path
- Fix `AttributeError`/`OSError` when asking for required plugin args
@bastimeyer bastimeyer merged commit 23a98cc into streamlink:master Oct 11, 2024
23 checks passed
@bastimeyer bastimeyer deleted the cli/fix-error-on-missing-stdin branch October 11, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant