diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-11-10 03:28:18 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-11-10 03:28:18 +0000 |
commit | 58cc762e160436534314f90bbd575e8ff19aa868 (patch) | |
tree | cde9aedbadcd136a2522a1ca1ae26af156197a00 | |
parent | 40978425da7321b2763381584543516ef5030cb1 (diff) | |
download | mpd-58cc762e160436534314f90bbd575e8ff19aa868.tar.gz mpd-58cc762e160436534314f90bbd575e8ff19aa868.tar.xz mpd-58cc762e160436534314f90bbd575e8ff19aa868.zip |
add "metadata_to_use" config option to make metadata configurable
git-svn-id: https://svn.musicpd.org/mpd/branches/r2562-metadata-handling-rewrite@2570 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r-- | doc/mpdconf.example | 4 | ||||
-rw-r--r-- | src/conf.c | 1 | ||||
-rw-r--r-- | src/conf.h | 1 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/tag.c | 60 |
5 files changed, 62 insertions, 6 deletions
diff --git a/doc/mpdconf.example b/doc/mpdconf.example index 7c9cdab86..4f6600bd8 100644 --- a/doc/mpdconf.example +++ b/doc/mpdconf.example @@ -199,6 +199,10 @@ audio_output { ################ MISCELLANEOUS OPTIONS ################### # +# This sets the metadata mpd will use, to disable all metadata, set to "none" +# +#metadata_to_use "artist,album,title,genre,date,track" +# # This setting exists as precaution against attacks. # #max_playlist_length "16384" diff --git a/src/conf.c b/src/conf.c index 874c5ca5d..856740038 100644 --- a/src/conf.c +++ b/src/conf.c @@ -151,6 +151,7 @@ void initConf() { registerConfigParam(CONF_HTTP_PREBUFFER_SIZE, 0, 0); registerConfigParam(CONF_REPLAYGAIN_PREAMP, 0, 0); registerConfigParam(CONF_ID3V1_ENCODING, 0, 0); + registerConfigParam(CONF_METADATA_TO_USE, 0, 0); } static void addBlockParam(ConfigParam * param, char * name, char * value, diff --git a/src/conf.h b/src/conf.h index 0a95335fb..ca9da3acf 100644 --- a/src/conf.h +++ b/src/conf.h @@ -57,6 +57,7 @@ #define CONF_HTTP_BUFFER_SIZE "http_buffer_size" #define CONF_HTTP_PREBUFFER_SIZE "http_prebuffer_size" #define CONF_ID3V1_ENCODING "id3v1_encoding" +#define CONF_METADATA_TO_USE "metadata_to_use" typedef struct _BlockParam { char * name; diff --git a/src/main.c b/src/main.c index 63fd5380f..7cbfaf23f 100644 --- a/src/main.c +++ b/src/main.c @@ -34,6 +34,7 @@ #include "replayGain.h" #include "inputPlugin.h" #include "inputStream.h" +#include "tag.h" #include "../config.h" #include <stdio.h> @@ -402,6 +403,7 @@ int main(int argc, char * argv[]) { parseOptions(argc, argv, &options); initStats(); + initTagConfig(); initLog(); establishListen(&options); @@ -26,6 +26,7 @@ #include "conf.h" #include "charConv.h" #include "tagTracker.h" +#include "mpd_types.h" #include <sys/stat.h> #include <stdlib.h> @@ -52,6 +53,51 @@ char * mpdTagItemKeys[TAG_NUM_OF_ITEM_TYPES] = "Date" }; +static mpd_sint8 ignoreTagItems[TAG_NUM_OF_ITEM_TYPES]; + +void initTagConfig() { + int quit = 0; + char * temp; + char * s; + char * c; + ConfigParam * param; + int i; + + memset(ignoreTagItems, 0, TAG_NUM_OF_ITEM_TYPES); + + param = getConfigParam(CONF_METADATA_TO_USE); + + if(!param) return; + + memset(ignoreTagItems, 1, TAG_NUM_OF_ITEM_TYPES); + + if(0 == strcasecmp(param->value, "none")) return; + + temp = c = s = strdup(param->value); + while(!quit) { + if(*s == ',' || *s == '\0') { + if(*s == '\0') quit = 1; + *s = '\0'; + for(i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++) { + if(strcasecmp(c, mpdTagItemKeys[i]) == 0) { + ignoreTagItems[i] = 0; + break; + } + } + if(strlen(c) && i == TAG_NUM_OF_ITEM_TYPES) { + ERROR("error parsing metadata item \"%s\" at " + "line %i\n", c, param->line); + exit(EXIT_FAILURE); + } + s++; + c = s; + } + s++; + } + + free(temp); +} + void printMpdTag(FILE * fp, MpdTag * tag) { int i; @@ -254,12 +300,12 @@ inline static void appendToTagItems(MpdTag * tag, int type, char * value, { int i = tag->numOfItems; - char * temp; - temp = malloc(len+1); - strncpy(temp, value, len); - temp[len] = '\0'; + char * t; + t = malloc(len+1); + strncpy(t, value, len); + t[len] = '\0'; - fixUtf8(temp); + fixUtf8(t); tag->numOfItems++; tag->items = realloc(tag->items, tag->numOfItems*sizeof(MpdTagItem)); @@ -267,10 +313,12 @@ inline static void appendToTagItems(MpdTag * tag, int type, char * value, tag->items[i].type = type; tag->items[i].value = getTagItemString(type, value); - free(temp); + free(t); } void addItemToMpdTagWithLen(MpdTag * tag, int itemType, char * value, int len) { + if(ignoreTagItems[itemType]) return; + appendToTagItems(tag, itemType, value, len); } |