{"id":16557037,"url":"https://github.com/cogentredtester/mpv-user-data-loader","last_synced_at":"2026-04-16T22:32:00.100Z","repository":{"id":213351700,"uuid":"733888894","full_name":"CogentRedTester/mpv-user-data-loader","owner":"CogentRedTester","description":"A script that allows the mpv `user-data` property to be set at launch and runtime using config files.","archived":false,"fork":false,"pushed_at":"2023-12-25T10:05:58.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-10T12:04:12.277Z","etag":null,"topics":["configuration","mpv-player","mpv-script"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CogentRedTester.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-20T11:08:03.000Z","updated_at":"2025-04-03T23:29:51.000Z","dependencies_parsed_at":"2023-12-25T11:24:50.712Z","dependency_job_id":"9ce844cd-d41c-43ef-b32e-39f45bd8ce4a","html_url":"https://github.com/CogentRedTester/mpv-user-data-loader","commit_stats":null,"previous_names":["cogentredtester/mpv-user-data-loader"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CogentRedTester/mpv-user-data-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CogentRedTester%2Fmpv-user-data-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CogentRedTester%2Fmpv-user-data-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CogentRedTester%2Fmpv-user-data-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CogentRedTester%2Fmpv-user-data-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CogentRedTester","download_url":"https://codeload.github.com/CogentRedTester/mpv-user-data-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CogentRedTester%2Fmpv-user-data-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31907495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","mpv-player","mpv-script"],"created_at":"2024-10-11T20:06:22.591Z","updated_at":"2026-04-16T22:32:00.066Z","avatar_url":"https://github.com/CogentRedTester.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mpv-user-data-loader\nA script that allows the mpv `user-data` property to be more easily\nconfigured using config files.\n\nThe script does this in two ways:\n* `user-data` fields can be set on startup using config files.\n* `user-data` fields can be set during runtime using `script-opts`.\n\n## Changing Properties at Startup\nThere are a few different ways of setting\n`user-data` fields at startup.\n\n### Config File\n`~~/script-opts/user-data.conf`\n\nThis is a config file that uses the standard\n[script config syntax](https://mpv.io/manual/master/#lua-scripting-on-update]]%29)\nof `\u003ckey\u003e=\u003cvalue\u003e`.\n\n`key` is the path to the `user-data` field that will be modified, e.g.\n`script_name/visibility`.\n`value` is the JSON formatted value that will be set to that field.\nThe key cannot contain any `=` characters, however you can\nuse [escaped character sequences](#escaped-character-sequences)\nto substitute them.\n\n`user-data.conf` example:\n\n```properties\n# comment\nscript_name/visibility=true\nscript2/number-of-items=21\nscript2/text/header=\"header text\"\n```\n\n`user-data` output:\n```json\n{\n    \"script_name\": {\n        \"visibility\":true\n    },\n    \"script2\": {\n        \"number-of-items\": 21,\n        \"text\": {\n            \"header\": \"header text\"\n        }\n    }\n}\n```\n\n#### Escaped Character Sequences\nThese are character sequences that can be included in the\nkey to handle characters that cannot be typed directly.\nThe `~0` sequence is only necessary to escape the other\nsequences, e.g., if you want the output to be `param~1` you\nwould use `param~01`.\n\nThe `~1` sequence is currently useless as `/` characters can\nbe used directly. However, it is reserved for the future in case\nit becomes possible to include `/` characters in the name\nof a `user-data` field. This is technically allowed by `user-data`\nalready, but is not supported when trying to access the property\ndirectly (`set`/`del` commands, property expansion, property observation, etc).\n\nsequence | output\n---------|-----------------------\n~0       | `~`\n~1       | `/`\n~2       | `\\n` - newline\n~3       | `\\r` - carriage return\n~4       | `=`\n\nThese sequences are based and extended from RFC 6901.\nIt is possible additional character sequences are added in the future\n\n### JSON Config File\n`~~/script-opts/user-data.json`\n\nThis config file uses JSON syntax, which should make it\neasier to define highly nested `user-data` values.\n\nThe file represents the full `user-data` property,\nso to replicate the previous example\nthe json file could simply contain:\n\n```json\n{\n    \"script_name\": { \"visibility\":true },\n    \"script2\": {\n        \"number-of-items\": 21,\n        \"text\": { \"header\": \"header text\" }\n    }\n}\n```\n\nNote that all of the top-level fields (e.g. `script_name` and `script2`)\ndirectly overwrite the existing value in `user-data`.\nThis means that if `script_name/other_field` exists in `user-data`,\nit will be removed after `\"script_name\": { \"visibility\":true }` is applied.\nThis will likely change in the future.\n\nThe JSON file can be used in conjunction with `user-data.conf`.\nThe JSON file will be applied first, so will not overwrite\nthe values set in `user-data.conf`.\n\n### `script-opts`\nThe [`script-opts`](https://mpv.io/manual/master/#options-script-opts)\nproperty can also be set at startup using `mpv.conf` or with\ncommandline arguments. See\n[changing properties at runtime](#changing-properties-at-runtime) for\nthe correct syntax.\n\nValues set with script-opts always overwrite the config files.\n\n## Changing Properties at Runtime\n`user-data` fields can be modified at runtime using\n[`script-opts`](https://mpv.io/manual/master/#options-script-opts).\nThis allows the fields to be set from the commandline, from\n`mpv.conf`, and from profiles, including\n[conditional auto profiles](https://mpv.io/manual/master/#conditional-auto-profiles).\n\nThe script-opt is in the form `user-data/path/to/field=\u003cJSON value\u003e\u003cparameters\u003e`.\nIt is nearly identical to the `user-data.conf` syntax, except that\nthe keys must be prefixed with `user-data/` and a list of parameters can optionally\nbe appended to the end (see [script-opt parameters](#script-opt-parameters)).\nEscaped character sequences are supported for the key.\n\nIf a `script-opt` is removed, then the associated `user-data` field is\nreset to the value it had when the first script-opt was applied.\nThis behaviour can be changed with the [`restore` parameter](#restore).\n\nIf, by some unfortunate coincidence, you are using a script that uses the\n`user-` prefix (or perhaps you just prefer underscores)\nyou can substitute the `-` for a `_`, e.g. `user_data/path/to/field=\u003cJSON value\u003e`.\n\n### script-opt parameters\nParameters are a list of optional key-value pairs appended after the\nJSON value in the form `\u003ckey\u003e=\u003cvalue\u003e`. Whitespace around the `=` is allowed and\nparameters can be separated from the JSON value (and each other) using any\ncharacter **except** the following: `a-zA-Z0-9_-`.\n\nHere are some examples with valid syntax:\n\n```properties\nscript-opts-append=user-data/script_name/visibility=true|param=val|param2=val\nscript-opts-append=user-data/script2/num=21: param = val param2=val\nscript-opts-append=user-data/script2/text/header=\"header text\" param = val\n```\n\nCurrently there is only one parameter, `restore`, which\nbehaves similarly to the mpv\n[`profile-restore`](https://mpv.io/manual/master/#runtime-profiles)\noption.\n\n#### `restore`\nThis parameter controls what happens when the script-opt is removed.\nThere are three options:\n\noption       | description\n-------------|-------------------------------------------------------------------------------------------------------\n`copy`       | Copy the original value of the field and restore it when the script-opt is removed (default).\n`copy-equal` | Copy the original value, but only restore if the current field value is equal to the value set by the script-opt.\n`no`         | Do not do anything when the script-opt is removed.\n\nCurrently, if a script-opt is changed instead of removed,\nthen only the `restore` value of the original script-opt is\nconsidered (unless that original value was `no`).\nThis may change in the future.\n\n\n### Examples\n\n#### `mpv.conf`\n\n```properties\nscript-opts-append=user-data/script_name/visibility=true\nscript-opts-append=user-data/script2/number-of-items=21\nscript-opts-append=user-data/script2/text/header=\"header text\"\n```\n\nApplying the script-opts with a profile:\n```properties\n[profile1]\nscript-opts-append=user-data/script_name/visibility=true\nscript-opts-append=user-data/script2/number-of-items=21\nscript-opts-append=user-data/script2/text/header=\"header text\"\n```\n\n#### Conditional Auto Profiles\nSets a `primary-monitor` field based on the\nmonitor the mpv window is currently displayed on.\nThe default value would be better placed in `user-data.conf`\nwhere the `restore=no` would not be necessary. It has been\nplaced here to make the example easier to read.\n\n```properties\n# sets the default value (probably better to do this is a config file)\nscript-opts-append=user-data/primary-monitor=false|restore=no\n\n[PrimaryMonitor]\nprofile-cond=display_names[1] == 'DP-1'\nscript-opts-append=user-data/primary-monitor=true|restore=copy-equal\n\n[OtherMonitor]\nprofile-cond=display_names[1] ~= 'DP-1'\nscript-opts-remove=user-data/primary-monitor\n```\n\nUses user-data property expansion to append `PRIMARY MONITOR` to the\ntitle of the mpv window:\n\n```properties\ntitle='${?media-title:${media-title}}${!media-title:No file} - mpv${?user-data/primary-monitor: - PRIMARY MONITOR}'\n\n[PrimaryMonitor]\nprofile-cond=display_names[1] == 'DP-1'\nscript-opts-append=user-data/primary-monitor=true|restore=copy-equal\n\n[OtherMonitor]\nprofile-cond=display_names[1] ~= 'DP-1'\nscript-opts-remove=user-data/primary-monitor\n```\n\n#### Commandline\n\n```bash\nmpv --script-opts-append='user-data/script_name/visibility=true' \\\n    --script-opts-append='user-data/script2/number-of-items=21' \\\n    --script-opts-append='user-data/script2/text/header=\"header text\"'\n```\n\nMake sure that the `\"` characters around strings are not stripped by the shell.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcogentredtester%2Fmpv-user-data-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcogentredtester%2Fmpv-user-data-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcogentredtester%2Fmpv-user-data-loader/lists"}