Skip to content

--title switch with variable arguments prevents Twitch rerun vod from playing #3206

@azizLIGHT

Description

@azizLIGHT

Bug Report

  • This is a bug report and I have read the contribution guidelines.

Description

If you use the --title switch with arguments that contain variables like {author}, {category}, or {title}, streamlink cannot play certain twitch streams (reruns, I think)

Expected / Actual behavior

I expect streamlink to open the twitch stream in my player of choice and start playing. Instead, I get errors, nothing plays, and streamlink quits.

Reproduction steps / Explicit stream URLs to test

  1. Find a twitch channel that is playing reruns, for example: reckful
  2. Launch using a command like: streamlink --loglevel debug --verbose-player --player=mpv --title "{author}" twitch.tv/reckful best
  3. See log output

Log output

[azizLIGHT@fractal ~]$ /home/azizLIGHT/Documents/Scripts/streamlink-pip/bin/streamlink --loglevel debug --verbose-player --player=mpv --title "{author}" twitch.tv/reckful best
[cli][debug] OS:         Linux-5.4.52-1-MANJARO-x86_64-with-glibc2.2.5
[cli][debug] Python:     3.8.3
[cli][debug] Streamlink: 1.5.0+31.g1913115
[cli][debug] Requests(2.24.0), Socks(1.7.1), Websocket(0.57.0)
[cli][info] Found matching plugin twitch for URL twitch.tv/reckful
[plugin.twitch][debug] Getting live HLS streams for reckful
[utils.l10n][debug] Language code: en_US
[cli][info] Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60_alt, 720p60 (best)
[cli][info] Opening stream: 720p60 (hls)
[stream.hls][debug] Reloading playlist
[stream.hls][debug] First Sequence: 3689; Last Sequence: 3702
[stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 3700; End Sequence: None
[stream.hls][debug] Adding segment 3700 to queue
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] Adding segment 3701 to queue
[stream.hls][debug] Adding segment 3702 to queue
[stream.hls][debug] Download of segment 3700 complete
[stream.hls][debug] Download of segment 3701 complete
[stream.hls][debug] Download of segment 3702 complete
[cli][info] Closing currently open stream...
[stream.segmented][debug] Closing worker thread
[stream.segmented][debug] Closing writer thread
Traceback (most recent call last):
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/bin/streamlink", line 11, in <module>
    load_entry_point('streamlink==1.5.0+31.g1913115', 'console_scripts', 'streamlink')()
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/lib/python3.8/site-packages/streamlink_cli/main.py", line 1027, in main
    handle_url()
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/lib/python3.8/site-packages/streamlink_cli/main.py", line 602, in handle_url
    handle_stream(plugin, streams, stream_name)
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/lib/python3.8/site-packages/streamlink_cli/main.py", line 455, in handle_stream
    success = output_stream(plugin, stream)
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/lib/python3.8/site-packages/streamlink_cli/main.py", line 316, in output_stream
    output = create_output(plugin)
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/lib/python3.8/site-packages/streamlink_cli/main.py", line 114, in create_output
    title = create_title(plugin)
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/lib/python3.8/site-packages/streamlink_cli/main.py", line 148, in create_title
    title = LazyFormatter.format(
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/lib/python3.8/site-packages/streamlink/utils/lazy_formatter.py", line 22, in format
    return string.Formatter().vformat(fmt, (), cls(**lazy_props))
  File "/usr/lib/python3.8/string.py", line 167, in vformat
    result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
  File "/usr/lib/python3.8/string.py", line 207, in _vformat
    obj, arg_used = self.get_field(field_name, args, kwargs)
  File "/usr/lib/python3.8/string.py", line 272, in get_field
    obj = self.get_value(first, args, kwargs)
  File "/usr/lib/python3.8/string.py", line 229, in get_value
    return kwargs[key]
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/lib/python3.8/site-packages/streamlink/utils/lazy_formatter.py", line 11, in __getitem__
    return value()
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/lib/python3.8/site-packages/streamlink_cli/main.py", line 151, in <lambda>
    author=lambda: plugin.get_author() or DEFAULT_STREAM_METADATA["author"],
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/lib/python3.8/site-packages/streamlink/plugins/twitch.py", line 422, in get_author
    self._get_metadata()
  File "/home/azizLIGHT/Documents/Scripts/streamlink-pip/lib/python3.8/site-packages/streamlink/plugins/twitch.py", line 410, in _get_metadata
    api_res = self.api.streams(self.channel_id)["stream"]["channel"]
TypeError: 'NoneType' object is not subscriptable
[azizLIGHT@fractal ~]$ 

Additional comments, screenshots, etc.

Normally I use --title "{author} - {category} - {title} - (${{video-bitrate}})" in my command, but any of those will cause streamlink to fail when trying to watch reckful stream. It does not seem to do it for regular live twitch channels, maybe it only does it to rerun channels. I am not sure. This was streamlink installed to a venv using these instructions

Love Streamlink? Please consider supporting our collective. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions