Convert between JSON and yt-dlp flags using FlagConfig
masterThe FlagConfig type allows for bidirectional conversion between JSON and yt-dlp command-line flags. This is ideal for HTTP APIs, web UIs, or persisting configurations in a database.
Key Features
- Bidirectional Conversion: Use
Command.SetFlagConfigto apply a JSON configuration to a command, andCommand.GetFlagConfigto extract the current flags into JSON. - Compatible Decoding: When loading older or client-supplied configurations, use
FlagConfig.UnmarshalJSONWithWarnings. This allows you to retain valid flags even if some members are unknown or incompatible. Always review the returned warnings. - Validation: Use the provided validation functions and the JSON schema (available via
optiondata.JSONSchema) to ensure correctness. The JSON body allows duplicate flags unless validated against the schema. - Persistence Warning:
yt-dlpflags can change or be removed during updates. When loading from storage, use compatibility decoding and handle warnings before validating. If validation fails, clear invalid values using the error typesErrMultipleJSONParsingFlagsorErrJSONParsingFlag(which provide the JSON path to the error).