cli: player title and file output metadata vars#3962
Conversation
4e6fbff to
f545a60
Compare
- support the same plugin metadata variables in `--output`, `--record`
and `--record-and-pipe` like they already exist in `--title`:
`{url}`, `{author}`, `{category}`/`{game}` and `{title}`
- substitute unsupported file name characters on specific OS-types
- add `--fs-safe-rules` CLI argument for overriding substitution logic
- add new Formatter class with caching and parameter translation
- create formatter instance in `handle_stream` and pass it to output
methods where player titles or file names need to be formatted
- rewrite test_cli_main tests
Co-Authored-By: Ian Cameron <[email protected]>
f545a60 to
158cdb4
Compare
|
I've added a new test which checks the formatter's initialization and the correct metadata variable defintions. This still doesn't test every change in the main CLI module, but I don't care, because adding more and more tests with 100s of mocks for this aged module doesn't make sense when the design isn't good to begin with. As said, a complete rewrite is needed. Also just noticed that my test changes fix a mistake which was present since several years where it always created an HTTPServer instance when running file output tests:
|
|
A future PR could add more vars to the formatter, with optional custom format specifiers (if that's possible):
|
Original PR #3962 by bastimeyer Original: streamlink/streamlink#3962
Merged from original PR #3962 Original: streamlink/streamlink#3962
--output,--recordand
--record-and-pipelike they already exist in--title:{url},{author},{category}/{game}and{title}--fs-safe-rulesCLI argument for overriding substitution logichandle_streamand pass it to outputmethods where player titles or file names need to be formatted
Co-Authored-By: Ian Cameron [email protected]
Resolves #3898
Related #3954, #3933, #3913
The critical code path where the formatter gets initialized is currently not tested because there weren't any test prior to these changes. I will try to add some tests tomorrow or so. This requires setting up ton of mocks, which is ugly.