Skip to content

Commit ef8eef8

Browse files
committed
command: allow metadata to be set manually
1 parent 5f9e1bc commit ef8eef8

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
@@ -2471,7 +2471,7 @@ Property list
24712471

24722472
This has a number of sub-properties:
24732473

2474-
``metadata/by-key/<key>``
2474+
``metadata/by-key/<key>`` (RW)
24752475
Value of metadata entry ``<key>``.
24762476

24772477
``metadata/list/count``

player/command.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,18 +1293,22 @@ static int tag_property(int action, void *arg, struct mp_tags *tags)
12931293
// Direct access without this prefix is allowed for compatibility.
12941294
bstr k = bstr0(ka->key);
12951295
bstr_eatstart0(&k, "by-key/");
1296-
char *meta = mp_tags_get_bstr(tags, k);
1297-
if (!meta)
1298-
return M_PROPERTY_UNKNOWN;
12991296
switch (ka->action) {
1300-
case M_PROPERTY_GET:
1297+
case M_PROPERTY_GET: {
1298+
char *meta = mp_tags_get_bstr(tags, k);
1299+
if (!meta)
1300+
return M_PROPERTY_UNKNOWN;
13011301
*(char **)ka->arg = talloc_strdup(NULL, meta);
13021302
return M_PROPERTY_OK;
1303+
}
13031304
case M_PROPERTY_GET_TYPE:
13041305
*(struct m_option *)ka->arg = (struct m_option){
13051306
.type = CONF_TYPE_STRING,
13061307
};
13071308
return M_PROPERTY_OK;
1309+
case M_PROPERTY_SET:
1310+
mp_tags_set_bstr(tags, k, bstr0(*(char **)ka->arg));
1311+
return M_PROPERTY_OK;
13081312
}
13091313
}
13101314
}

0 commit comments

Comments
 (0)