Skip to content

Player variables in --title #4205

@bastimeyer

Description

@bastimeyer

Checklist

Streamlink version

Latest build from the master branch

Description

I've noticed this issue while rewriting the --title docs (mentioned in #4203 that this needs to be done).

MPV

It looks like MPV does only support its own format variables in its --title argument but not in --force-media-title. --force-media-title has replaced --title in #3405 last year, because --title does only change the window title and not the title of the stream inside MPV's pseudo GUI. --force-media-title does both.

Since we want to be able to change both the stream title and window title and therefore can't switch back, the MPV custom format variables are all unsupported. This means that the rather wonky logic for escaping the MPV title string should be removed and the docs also need to be fixed.

Btw, users still can set MPV's --title parameter with any property expansion they want, but not via Streamlink's --title parameter. MPV's {media-title} variable gets the value of what Streamlink passes via --force-media-title. I don't think though that this should be added to the docs, as it's kinda ridiculous. Example:

$ streamlink \
  --title '{author} - {category} - {title}' \
  -p mpv \
  -a '"--title=${{media-title}} // ${{mpv-version}}" {playerinput}' \
  twitch.tv/gorgc best

$ xdotool search --class mpv getwindowname
Gorgc - Dota 2 - a little cold // mpv 0.34.0

VLC

VLC is the only supported player now with player variables / property expansion, but there's an issue with how escaped variables are handled.

The formatted title is currently passed as a string to PlayerOutput, which means any metadata variables have already been substituted by the Formatter in streamlink_cli.main. Then the PlayerOutput._create_arguments() method tries to escape characters on that whole string which would otherwise be interpreted by the player as its own formatting variables ($ -> $$). This prevents metadata from changing the intended output format. However, there is a workaround added here by replacing \$$ again with $, which doesn't make much sense because metadata can still change the output format if there's a \$ somewhere in the string instead of a simple $.

This either needs to be fixed by escaping all VLC player-variables (and disabling property expansion), or by escaping only the contents of the metadata variables themselves so that the backslash workaround is not needed. But as said, the title is already formatted and passed as a string to PlayerOutput, so adding player-specific escape logic to the title formatter would require additional changes.

It's not too big of a problem though and can be done later.

Debug log

-

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