return str;
}
-static int32_t set_metadata_name(uint8_t atom_type, char **name)
-{
- static char *tag_names[] = {
- "unknown", "title", "artist", "writer", "album",
- "date", "tool", "comment", "genre", "track",
- "disc", "compilation", "genre", "tempo", "cover",
- "album_artist", "contentgroup", "lyrics", "description",
- "network", "show", "episodename",
- "sorttitle", "sortalbum", "sortartist", "sortalbumartist",
- "sortwriter", "sortshow",
- "season", "episode", "podcast"
- };
- uint8_t tag_idx = 0;
-
+static const char *get_metadata_name(uint8_t atom_type)
+{
switch (atom_type) {
- case ATOM_TITLE:
- tag_idx = 1;
- break;
- case ATOM_ARTIST:
- tag_idx = 2;
- break;
- case ATOM_WRITER:
- tag_idx = 3;
- break;
- case ATOM_ALBUM:
- tag_idx = 4;
- break;
- case ATOM_DATE:
- tag_idx = 5;
- break;
- case ATOM_TOOL:
- tag_idx = 6;
- break;
- case ATOM_COMMENT:
- tag_idx = 7;
- break;
- case ATOM_GENRE1:
- tag_idx = 8;
- break;
- case ATOM_TRACK:
- tag_idx = 9;
- break;
- case ATOM_DISC:
- tag_idx = 10;
- break;
- case ATOM_COMPILATION:
- tag_idx = 11;
- break;
- case ATOM_GENRE2:
- tag_idx = 12;
- break;
- case ATOM_TEMPO:
- tag_idx = 13;
- break;
- case ATOM_COVER:
- tag_idx = 14;
- break;
- case ATOM_ALBUM_ARTIST:
- tag_idx = 15;
- break;
- case ATOM_CONTENTGROUP:
- tag_idx = 16;
- break;
- case ATOM_LYRICS:
- tag_idx = 17;
- break;
- case ATOM_DESCRIPTION:
- tag_idx = 18;
- break;
- case ATOM_NETWORK:
- tag_idx = 19;
- break;
- case ATOM_SHOW:
- tag_idx = 20;
- break;
- case ATOM_EPISODENAME:
- tag_idx = 21;
- break;
- case ATOM_SORTTITLE:
- tag_idx = 22;
- break;
- case ATOM_SORTALBUM:
- tag_idx = 23;
- break;
- case ATOM_SORTARTIST:
- tag_idx = 24;
- break;
- case ATOM_SORTALBUMARTIST:
- tag_idx = 25;
- break;
- case ATOM_SORTWRITER:
- tag_idx = 26;
- break;
- case ATOM_SORTSHOW:
- tag_idx = 27;
- break;
- case ATOM_SEASON:
- tag_idx = 28;
- break;
- case ATOM_EPISODE:
- tag_idx = 29;
- break;
- case ATOM_PODCAST:
- tag_idx = 30;
- break;
- default:
- tag_idx = 0;
- break;
+ case ATOM_TITLE: return "title";
+ case ATOM_ARTIST: return "artist";
+ case ATOM_WRITER: return "writer";
+ case ATOM_ALBUM: return "album";
+ case ATOM_DATE: return "date";
+ case ATOM_TOOL: return "tool";
+ case ATOM_COMMENT: return "comment";
+ case ATOM_GENRE1: return "genre";
+ case ATOM_TRACK: return "track";
+ case ATOM_DISC: return "disc";
+ case ATOM_COMPILATION: return "compilation";
+ case ATOM_GENRE2: return "genre";
+ case ATOM_TEMPO: return "tempo";
+ case ATOM_COVER: return "cover";
+ case ATOM_ALBUM_ARTIST: return "album_artist";
+ case ATOM_CONTENTGROUP: return "contentgroup";
+ case ATOM_LYRICS: return "lyrics";
+ case ATOM_DESCRIPTION: return "description";
+ case ATOM_NETWORK: return "network";
+ case ATOM_SHOW: return "show";
+ case ATOM_EPISODENAME: return "episodename";
+ case ATOM_SORTTITLE: return "sorttitle";
+ case ATOM_SORTALBUM: return "sortalbum";
+ case ATOM_SORTARTIST: return "sortartist";
+ case ATOM_SORTALBUMARTIST: return "sortalbumartist";
+ case ATOM_SORTWRITER: return "sortwriter";
+ case ATOM_SORTSHOW: return "sortshow";
+ case ATOM_SEASON: return "season";
+ case ATOM_EPISODE: return "episode";
+ case ATOM_PODCAST: return "podcast";
+ default: return "unknown";
}
-
- *name = para_strdup(tag_names[tag_idx]);
- return 0;
}
static uint32_t min_body_size(uint8_t atom_type)
}
if (data) {
if (!done) {
- if (name == NULL)
- set_metadata_name(parent , &name);
- if (name)
- tag_add_field(&(f->tags), name, data, len);
+ if (!name)
+ name = para_strdup(get_metadata_name(parent));
+ tag_add_field(&(f->tags), name, data, len);
}
-
free(data);
}
free(name);