/*****************************************************************************
* Preamble
*****************************************************************************/
-#define _GNU_SOURCE
-#include <stdlib.h> /* malloc(), free() */
-#include <vlc/vlc.h>
-#include <vlc/intf.h>
-#include <vlc_meta.h>
-#include <vlc_meta.h>
-#include <charset.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_playlist.h>
+#include <vlc_charset.h>
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
* Module descriptor
*****************************************************************************/
-vlc_module_begin();
-/* set_category( CAT_INTERFACE );
- set_subcategory( SUBCAT_INTERFACE_CONTROL );*/
- set_shortname( N_( "Folder" ) );
- set_description( _("Folder meta data") );
+vlc_module_begin ()
+ set_shortname( N_( "Folder" ) )
+ set_description( N_("Folder meta data") )
- set_capability( "art finder", 10 );
- set_callbacks( FindMeta, NULL );
-vlc_module_end();
+ set_capability( "art finder", 90 )
+ 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;
- uint32_t i_meta;
+ input_item_t *p_item = (input_item_t *)p_this->p_private;
+ bool b_have_art = false;
- if( !p_item->p_meta ) return VLC_EGENERIC;
+ int i = 0;
+ struct stat a;
+ char psz_filename[MAX_PATH];
+ if( !p_item )
+ return VLC_EGENERIC;
+ char *psz_dir = input_item_GetURI( p_item );
+ if( !psz_dir )
+ return VLC_EGENERIC;
- if( p_me->i_mandatory & VLC_META_ENGINE_ART_URL
- || p_me->i_optional & VLC_META_ENGINE_ART_URL )
+ char *psz_buf = strrchr( psz_dir, '/' );
+ if( psz_buf )
{
- 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, '/' );
+ psz_buf++;
+ *psz_buf = '\0';
+ }
+ else
+ {
+ *psz_dir = '\0';
+ }
- if( psz_buf )
- {
- psz_buf++;
- *psz_buf = '\0';
- }
- else
+ char *psz_path = psz_dir;
+ if( !strncmp( psz_path, "file://", 7 ) )
+ psz_path += 7;
+
+ for( i = 0; b_have_art == false && i < 3; i++ )
+ {
+ switch( i )
{
- *psz_dir = '\0';
+ case 0:
+ /* Windows Folder.jpg */
+ snprintf( psz_filename, MAX_PATH,
+ "file://%sFolder.jpg", psz_path );
+ break;
+
+ case 1:
+ /* Windows AlbumArtSmall.jpg == small version of Folder.jpg */
+ snprintf( psz_filename, MAX_PATH,
+ "file://%sAlbumArtSmall.jpg", psz_path );
+ break;
+
+ case 2:
+ /* KDE (?) .folder.png */
+ snprintf( psz_filename, MAX_PATH,
+ "file://%s.folder.png", psz_path );
+ break;
}
- for( i = 0; b_have_art == VLC_FALSE && i < 3; i++ )
+ if( utf8_stat( psz_filename+7, &a ) != -1 )
{
- 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;
- }
+ input_item_SetArtURL( p_item, psz_filename );
+ b_have_art = true;
}
-
- free( psz_dir );
}
- i_meta = input_GetMetaEngineFlags( p_item->p_meta );
- p_me->i_mandatory &= ~i_meta;
- p_me->i_optional &= ~i_meta;
- if( p_me->i_mandatory )
- return VLC_EGENERIC;
- else
- return VLC_SUCCESS;
+ free( psz_dir );
+
+ return b_have_art ? VLC_SUCCESS : VLC_EGENERIC;
}