]> git.sesse.net Git - vlc/commitdiff
Add low priority "folder" meta_engine. Will look for files named "Folder.jpg" (Window...
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 23 Sep 2006 22:45:52 +0000 (22:45 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 23 Sep 2006 22:45:52 +0000 (22:45 +0000)
configure.ac
modules/meta_engine/Modules.am
modules/meta_engine/folder.c [new file with mode: 0644]

index fbea6f29a67f448096ae744efdb0ae4b3b21387c..6fbf3fa9bc518958ba52e29abdab983007e4b95a 100644 (file)
@@ -1166,7 +1166,7 @@ VLC_ADD_PLUGINS([packetizer_mpeg4video packetizer_mpeg4audio])
 if test "${SYS}" != "mingwce"; then
 dnl  VLC_ADD_PLUGINS([externrun])
   VLC_ADD_PLUGINS([access_fake access_filter_timeshift access_filter_record])
-  VLC_ADD_PLUGINS([gestures rc telnet hotkeys netsync showintf time marq podcast shout sap fake])
+  VLC_ADD_PLUGINS([gestures rc telnet hotkeys netsync showintf time marq podcast shout sap fake folder])
   VLC_ADD_PLUGINS([rss mosaic wall motiondetect clone crop])
   VLC_ADD_PLUGINS([i420_yuy2 i422_yuy2 i420_ymga])
   VLC_ADD_PLUGINS([aout_file linear_resampler bandlimited_resampler])
index 4dbbd9995c98111cb9177e1d6a281996501383ef..24002f927cf0a099459bad950dc0722d355e24f4 100644 (file)
@@ -1,2 +1,3 @@
 SOURCES_musicbrainz = musicbrainz.c
 SOURCES_dummy = dummy.c
+SOURCES_folder = folder.c
diff --git a/modules/meta_engine/folder.c b/modules/meta_engine/folder.c
new file mode 100644 (file)
index 0000000..8aecfd2
--- /dev/null
@@ -0,0 +1,127 @@
+/*****************************************************************************
+ * folder.c
+ *****************************************************************************
+ * Copyright (C) 2006 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#define _GNU_SOURCE
+#include <stdlib.h>                                      /* malloc(), free() */
+
+#include <vlc/vlc.h>
+#include <vlc/intf.h>
+#include <vlc_meta.h>
+#include <vlc_meta_engine.h>
+#include <charset.h>
+
+#ifdef HAVE_SYS_STAT_H
+#   include <sys/stat.h>
+#endif
+
+#ifndef MAX_PATH
+#   define MAX_PATH 250
+#endif
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static int FindMeta( vlc_object_t * );
+
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+
+vlc_module_begin();
+/*    set_category( CAT_INTERFACE );
+    set_subcategory( SUBCAT_INTERFACE_CONTROL );*/
+    set_shortname( N_( "Folder" ) );
+    set_description( _("Folder meta data") );
+
+    set_capability( "meta engine", 10 );
+    set_callbacks( FindMeta, NULL );
+vlc_module_end();
+
+/*****************************************************************************
+ *****************************************************************************/
+static int FindMeta( vlc_object_t *p_this )
+{
+    meta_engine_t *p_me = (meta_engine_t *)p_this;
+    input_item_t *p_item = p_me->p_item;
+    vlc_bool_t b_have_art = VLC_FALSE;
+
+    if( !p_item->p_meta ) return VLC_EGENERIC;
+
+
+    if( p_me->i_mandatory & VLC_META_ENGINE_ART_URL
+        || p_me->i_optional & VLC_META_ENGINE_ART_URL )
+    {
+        int i = 0;
+        struct stat a;
+        char psz_filename[MAX_PATH];
+        char *psz_dir = strdup( p_item->psz_uri );
+        char *psz_buf = strrchr( psz_dir, '/' );
+
+        if( psz_buf )
+        {
+            psz_buf++;
+            *psz_buf = '\0';
+        }
+        else
+        {
+            *psz_dir = '\0';
+        }
+
+        for( i = 0; b_have_art == VLC_FALSE && i < 3; i++ )
+        {
+            switch( i )
+            {
+                case 0:
+                /* Windows Folder.jpg */
+                snprintf( psz_filename, MAX_PATH,
+                          "file://%sFolder.jpg", psz_dir );
+                break;
+
+                case 1:
+                /* Windows AlbumArtSmall.jpg == small version of Folder.jpg */
+                snprintf( psz_filename, MAX_PATH,
+                      "file://%sAlbumArtSmall.jpg", psz_dir );
+                break;
+
+                case 2:
+                /* KDE (?) .folder.png */
+                snprintf( psz_filename, MAX_PATH,
+                      "file://%s.folder.png", psz_dir );
+                break;
+            }
+
+            if( utf8_stat( psz_filename+7, &a ) != -1 )
+            {
+                vlc_meta_SetArtURL( p_item->p_meta, psz_filename );
+                b_have_art = VLC_TRUE;
+            }
+        }
+
+        free( psz_dir );
+    }
+
+    return VLC_SUCCESS;
+}