Skip to content

Commit d0df98f

Browse files
myQwilkasper93
authored andcommitted
command: allow metadata to be set manually
1 parent 4377cce commit d0df98f

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
make the `metadata/by-key` property writable

DOCS/man/input.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2477,7 +2477,7 @@ Property list
24772477

24782478
This has a number of sub-properties:
24792479

2480-
``metadata/by-key/<key>``
2480+
``metadata/by-key/<key>`` (RW)
24812481
Value of metadata entry ``<key>``.
24822482

24832483
``metadata/list/count``

player/command.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,18 +1329,22 @@ static int tag_property(int action, void *arg, struct mp_tags *tags)
13291329
// Direct access without this prefix is allowed for compatibility.
13301330
bstr k = bstr0(ka->key);
13311331
bstr_eatstart0(&k, "by-key/");
1332-
char *meta = mp_tags_get_bstr(tags, k);
1333-
if (!meta)
1334-
return M_PROPERTY_UNKNOWN;
13351332
switch (ka->action) {
1336-
case M_PROPERTY_GET:
1333+
case M_PROPERTY_GET: {
1334+
char *meta = mp_tags_get_bstr(tags, k);
1335+
if (!meta)
1336+
return M_PROPERTY_UNKNOWN;
13371337
*(char **)ka->arg = talloc_strdup(NULL, meta);
13381338
return M_PROPERTY_OK;
1339+
}
13391340
case M_PROPERTY_GET_TYPE:
13401341
*(struct m_option *)ka->arg = (struct m_option){
13411342
.type = CONF_TYPE_STRING,
13421343
};
13431344
return M_PROPERTY_OK;
1345+
case M_PROPERTY_SET:
1346+
mp_tags_set_bstr(tags, k, bstr0(*(char **)ka->arg));
1347+
return M_PROPERTY_OK;
13441348
}
13451349
}
13461350
}

0 commit comments

Comments
 (0)