1
0
mirror of https://github.com/SuperBFG7/ympd synced 2025-02-09 23:50:09 +00:00

Feat: configuration option for used tags in ui #52

This commit is contained in:
jcorporation 2018-09-17 18:06:06 +01:00
parent 7eacab631a
commit 7cffc5ecc6
4 changed files with 56 additions and 21 deletions

View File

@ -31,3 +31,7 @@ mixramp = false
#Enable usage of mpd stickers for play statistics and voting #Enable usage of mpd stickers for play statistics and voting
stickers = true stickers = true
#List of tags in myMPD gui
#Supported tags: Artist,Album,AlbumArtist,Title,Track,Genre,Date,Composer,Performer
taglist = Artist,Album,AlbumArtist,Title,Track,Genre,Date,Composer,Performer

View File

@ -582,6 +582,9 @@ void mympd_parse_idle(struct mg_mgr *s, int idle_bitmask) {
void mympd_mpd_features() { void mympd_mpd_features() {
struct mpd_pair *pair; struct mpd_pair *pair;
char s[2] = ",";
char *str = strdup(config.taglist);
char *token;
mpd.protocol = mpd_connection_get_server_version(mpd.conn); mpd.protocol = mpd_connection_get_server_version(mpd.conn);
@ -635,25 +638,49 @@ void mympd_mpd_features() {
mpd_return_pair(mpd.conn, pair); mpd_return_pair(mpd.conn, pair);
} }
mpd_response_finish(mpd.conn); mpd_response_finish(mpd.conn);
printf("\n"); printf("\nmyMPD enabled tags: ");
if (mpd.tag_artist == false)
printf("WARNING: Artist tag not enabled in mpd\n"); token = strtok(str, s);
if (mpd.tag_album == false) while (token != NULL) {
printf("WARNING: Album tag not enabled in mpd\n"); if (strcmp(token, "Artist") == 0) {
if (mpd.tag_album_artist == false) if (mpd.tag_artist == true) printf("%s ", token);
printf("WARNING: AlbumArtist tag not enabled in mpd\n"); else mpd.tag_artist = false;
if (mpd.tag_title == false) }
printf("WARNING: Title tag not enabled in mpd\n"); else if (strcmp(token, "Album") == 0) {
if (mpd.tag_track == false) if (mpd.tag_album == true) printf("%s ", token);
printf("WARNING: Track tag not enabled in mpd\n"); else mpd.tag_album = false;
if (mpd.tag_genre == false) }
printf("WARNING: Genre tag not enabled in mpd\n"); else if (strcmp(token, "AlbumArtist") == 0) {
if (mpd.tag_date == false) if (mpd.tag_album_artist == true) printf("%s ", token);
printf("WARNING: Date tag not enabled in mpd\n"); else mpd.tag_album_artist = false;
if (mpd.tag_composer == false) }
printf("WARNING: Composer tag not enabled in mpd\n"); else if (strcmp(token, "Title") == 0) {
if (mpd.tag_performer == false) if (mpd.tag_title == true) printf("%s ", token);
printf("WARNING: Performer tag not enabled in mpd\n"); else mpd.tag_title = false;
}
else if (strcmp(token, "Track") == 0) {
if (mpd.tag_track == true) printf("%s ", token);
else mpd.tag_track = false;
}
else if (strcmp(token, "Genre") == 0) {
if (mpd.tag_genre == true) printf("%s ", token);
else mpd.tag_genre = false;
}
else if (strcmp(token, "Date") == 0) {
if (mpd.tag_date == true) printf("%s ", token);
else mpd.tag_date = false;
}
else if (strcmp(token, "Composer") == 0) {
if (mpd.tag_composer == true) printf("%s ", token);
else mpd.tag_composer = false;
}
else if (strcmp(token, "Performer") == 0) {
if (mpd.tag_performer == true) printf("%s ", token);
else mpd.tag_performer = false;
}
token = strtok(NULL, s);
}
printf("\n");
} }
void mympd_idle(struct mg_mgr *s, int timeout) { void mympd_idle(struct mg_mgr *s, int timeout) {

View File

@ -159,6 +159,7 @@ typedef struct {
const char* statefile; const char* statefile;
bool stickers; bool stickers;
bool mixramp; bool mixramp;
const char* taglist;
} t_config; } t_config;
t_config config; t_config config;

View File

@ -154,6 +154,8 @@ static int inihandler(void* user, const char* section, const char* name, const c
p_config->mixramp = true; p_config->mixramp = true;
else else
p_config->mixramp = false; p_config->mixramp = false;
else if (MATCH("taglist"))
p_config->taglist = strdup(value);
else else
return 0; /* unknown section/name, error */ return 0; /* unknown section/name, error */
@ -182,6 +184,7 @@ int main(int argc, char **argv) {
config.statefile = "/var/lib/mympd/mympd.state"; config.statefile = "/var/lib/mympd/mympd.state";
config.stickers = true; config.stickers = true;
config.mixramp = true; config.mixramp = true;
config.taglist = "Artist,Album,AlbumArtist,Title,Track,Genre,Date,Composer,Performer";
mpd.timeout = 3000; mpd.timeout = 3000;
mpd.last_update_sticker_song_id = -1; mpd.last_update_sticker_song_id = -1;