1 /*****************************************************************************
2 * meta.c : Metadata handling
3 *****************************************************************************
4 * Copyright (C) 1998-2004 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea@videolan.org>
8 * Clément Stenac <zorglub@videolan.org
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 #include <vlc_common.h>
30 #include <vlc_playlist.h>
31 #include "input_internal.h"
32 #include "../playlist/art.h"
34 /* FIXME bad name convention */
35 const char * input_MetaTypeToLocalizedString( vlc_meta_type_t meta_type )
39 case vlc_meta_Title: return _("Title");
40 case vlc_meta_Artist: return _("Artist");
41 case vlc_meta_Genre: return _("Genre");
42 case vlc_meta_Copyright: return _("Copyright");
43 case vlc_meta_Album: return _("Album");
44 case vlc_meta_TrackNumber: return _("Track number");
45 case vlc_meta_Description: return _("Description");
46 case vlc_meta_Rating: return _("Rating");
47 case vlc_meta_Date: return _("Date");
48 case vlc_meta_Setting: return _("Setting");
49 case vlc_meta_URL: return _("URL");
50 case vlc_meta_Language: return _("Language");
51 case vlc_meta_NowPlaying: return _("Now Playing");
52 case vlc_meta_Publisher: return _("Publisher");
53 case vlc_meta_EncodedBy: return _("Encoded by");
54 case vlc_meta_ArtworkURL: return _("Artwork URL");
55 case vlc_meta_TrackID: return _("Track ID");
61 void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
63 input_item_t *p_item = p_input->p->p_item;
66 const char *psz_arturl = vlc_meta_Get( p_item->p_meta, vlc_meta_ArtworkURL );
67 if( !psz_arturl || strncmp( psz_arturl, "attachment://", strlen("attachment://") ) )
69 msg_Err( p_input, "internal input error with input_ExtractAttachmentAndCacheArt" );
73 playlist_t *p_playlist = pl_Hold( p_input );
78 if( input_item_IsArtFetched( p_item ) )
80 /* XXX Weird, we should not have end up with attachment:// art url unless there is a race
82 msg_Warn( p_input, "internal input error with input_ExtractAttachmentAndCacheArt" );
83 playlist_FindArtInCache( p_item );
84 pl_Release( p_playlist );
89 input_attachment_t *p_attachment = NULL;
90 for( int i_idx = 0; i_idx < p_input->p->i_attachment; i_idx++ )
92 if( !strcmp( p_input->p->attachment[i_idx]->psz_name,
93 &psz_arturl[strlen("attachment://")] ) )
95 p_attachment = p_input->p->attachment[i_idx];
99 if( !p_attachment || p_attachment->i_data <= 0 )
101 msg_Warn( p_input, "internal input error with input_ExtractAttachmentAndCacheArt" );
102 pl_Release( p_playlist );
107 const char *psz_type = NULL;
108 if( !strcmp( p_attachment->psz_mime, "image/jpeg" ) )
110 else if( !strcmp( p_attachment->psz_mime, "image/png" ) )
114 playlist_SaveArt( p_playlist, p_item,
115 p_attachment->p_data, p_attachment->i_data, psz_type );
117 pl_Release( p_playlist );