]> git.sesse.net Git - vlc/commitdiff
lua: Expose extra meta through vlc.item.metas.
authorPierre d'Herbemont <pdherbemont@free.fr>
Wed, 13 Jan 2010 11:55:43 +0000 (12:55 +0100)
committerPierre d'Herbemont <pdherbemont@free.fr>
Fri, 15 Jan 2010 15:39:48 +0000 (16:39 +0100)
modules/misc/lua/libs/input.c

index 87dd6683ac79e60a880df6a016771c7d0985c714..253035523e65fb804d5302cb7ea8f8cf1caf86bd 100644 (file)
@@ -124,7 +124,7 @@ static int vlclua_input_metas_internal( lua_State *L, input_item_t *p_item )
     lua_pushstring( L, psz_meta );
     lua_setfield( L, -2, "filename" );
     free( psz_meta );
-    
+
 #define PUSH_META( n, m ) \
     psz_meta = input_item_GetMeta( p_item, vlc_meta_ ## n ); \
     lua_pushstring( L, psz_meta ); \
@@ -151,6 +151,21 @@ static int vlclua_input_metas_internal( lua_State *L, input_item_t *p_item )
 
 #undef PUSH_META
 
+    vlc_mutex_lock(&p_item->lock);
+    if (p_item->p_meta) {
+        char ** names = vlc_meta_CopyExtraNames(p_item->p_meta);
+        for(int i = 0; names[i]; i++)
+        {
+            const char *meta = vlc_meta_GetExtra(p_item->p_meta, names[i]);
+            lua_pushstring( L, meta );
+            lua_setfield( L, -2, names[i] );
+            printf("setting %s=%s\n", names[i], meta);
+            free(names[i]);
+        }
+        free(names);
+    }
+    vlc_mutex_unlock(&p_item->lock);
+
     return 1;
 }
 
@@ -261,7 +276,7 @@ static int vlclua_input_item_get( lua_State *L, input_item_t *p_item )
     }
 
     lua_setmetatable(L, -2);
-    
+
     return 1;
 }