Force-push with an update which makes ensure_ascii conditional, based on the output stream's encoding. UTF8 is not guaranteed to be the output encoding.
https://docs.python.org/3/library/sys.html#sys.stdout
Prior commit:
$ PYTHONIOENCODING=ascii streamlink https://www.youtube.com/@Nuke73-Live best -j
Traceback (most recent call last):
File "/home/basti/venv/streamlink-312/bin/streamlink", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 955, in main
exit_code = run(parser)
^^^^^^^^^^^
File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 927, in run
handle_url()
File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 564, in handle_url
handle_stream(plugin, streams, stream_name)
File "/home/basti/repos/streamlink/src/streamlink_cli/main.py", line 396, in handle_stream
console.msg_json(
File "/home/basti/repos/streamlink/src/streamlink_cli/console.py", line 83, in msg_json
self.output.write(f"{msg}\n")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 2058-2061: ordinal not in range(128)
Now:
$ PYTHONIOENCODING=ascii streamlink https://www.youtube.com/@Nuke73-Live best -j | grep title
"title": "RGG-LAND \u041b\u0415\u0422\u041e 2024 \u2022 \u0414\u0435\u043d\u044c 16 \u2022 \u0427\u0430\u0441\u0442\u044c 2"
$ streamlink https://www.youtube.com/@Nuke73-Live best -j | grep title
"title": "RGG-LAND ЛЕТО 2024 • День 16 • Часть 2"