[grilo-plugins] lua-factory: use requested-keys as keys for lua api
- From: Victor Toso de Carvalho <victortoso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] lua-factory: use requested-keys as keys for lua api
- Date: Fri, 11 Mar 2016 11:49:06 +0000 (UTC)
commit 72a4e9d1924de741d66b4b5e4ed45e726db3913a
Author: Victor Toso <me victortoso com>
Date: Thu Mar 3 01:17:43 2016 +0100
lua-factory: use requested-keys as keys for lua api
We always provided the requested-keys to the lua source as an array with
the metadata-keys as values. That's not so interesting as the source
will need to walk in the array to check which keys were requested.
As from commit 2bfcff90d589d43351 we started introducing the
requested-keys as an argument, it would be good to use this moment and
improve it.
A table with the metadata-keys as key could be easily accessed in the
source
e.g
if requested_keys.artist then
media.artist = my_artist
end
https://bugzilla.gnome.org/show_bug.cgi?id=732879
src/lua-factory/grl-lua-library.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/lua-factory/grl-lua-library.c b/src/lua-factory/grl-lua-library.c
index dbcb4cd..a03a995 100644
--- a/src/lua-factory/grl-lua-library.c
+++ b/src/lua-factory/grl-lua-library.c
@@ -1612,16 +1612,22 @@ push_operation_requested_keys (lua_State *L,
lua_newtable (L);
for (it = keys; it != NULL; it = it->next) {
GrlKeyID key_id;
- const gchar *key_name;
+ char *key_name, *ptr;
key_id = GRLPOINTER_TO_KEYID (it->data);
if (key_id == GRL_METADATA_KEY_INVALID)
continue;
- key_name = grl_registry_lookup_metadata_key_name (registry, key_id);
- lua_pushinteger (L, i);
+ key_name = g_strdup (grl_registry_lookup_metadata_key_name (registry, key_id));
+ /* Replace '-' to '_': convenient for the developer */
+ while ((ptr = strstr (key_name, "-")) != NULL) {
+ *ptr = '_';
+ }
+
lua_pushstring (L, key_name);
+ lua_pushboolean (L, 1);
lua_settable (L, -3);
+ g_free (key_name);
i++;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]