diff --git a/examples/ncmpcpprc b/examples/ncmpcpprc index f639ad38..f8cadee2 100644 --- a/examples/ncmpcpprc +++ b/examples/ncmpcpprc @@ -36,7 +36,10 @@ ## %y - year ## %n - track number ## %g - genre -## %c - comment +## %c - composer +## %p - performer +## %d - disc +## %C - comment ## ## you can also put them in { } and then it will be displayed ## only if all requested values are available and/or define alternate diff --git a/src/helpers.cpp b/src/helpers.cpp index 2e60f74a..ce6ba46a 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -301,6 +301,54 @@ string DisplaySong(const Song &s, const string &song_template) break; } case 'c': + { + if (link_tags) + { + if (s.GetComposer() != EMPTY_TAG) + { + result += s.GetComposer(); + i += s.GetComposer().length(); + } + else + tags_present = 0; + } + else + result += s.GetComposer(); + break; + } + case 'p': + { + if (link_tags) + { + if (s.GetPerformer() != EMPTY_TAG) + { + result += s.GetPerformer(); + i += s.GetPerformer().length(); + } + else + tags_present = 0; + } + else + result += s.GetPerformer(); + break; + } + case 'd': + { + if (link_tags) + { + if (s.GetDisc() != EMPTY_TAG) + { + result += s.GetDisc(); + i += s.GetDisc().length(); + } + else + tags_present = 0; + } + else + result += s.GetDisc(); + break; + } + case 'C': { if (link_tags) { diff --git a/src/song.cpp b/src/song.cpp index 262e2bb3..5541b84a 100644 --- a/src/song.cpp +++ b/src/song.cpp @@ -51,9 +51,9 @@ Song::Song(mpd_Song *s) : itsHash(0), //s->name ? itsName = s->name : itsName = ""; s->date ? itsYear = s->date : itsYear = ""; s->genre ? itsGenre = s->genre : itsGenre = ""; - //s->composer ? itsComposer = s->composer : itsComposer = ""; - //s->performer ? itsPerformer = s->performer : itsPerformer = ""; - //s->disc ? itsDisc = s->disc : itsDisc = ""; + s->composer ? itsComposer = s->composer : itsComposer = ""; + s->performer ? itsPerformer = s->performer : itsPerformer = ""; + s->disc ? itsDisc = s->disc : itsDisc = ""; s->comment ? itsComment = s->comment : itsComment = ""; int i = itsFile.size(); @@ -107,9 +107,9 @@ void Song::Clear() //itsName.clear(); itsYear.clear(); itsGenre.clear(); - //itsComposer.clear(); - //itsPerformer.clear(); - //itsDisc.clear(); + itsComposer.clear(); + itsPerformer.clear(); + itsDisc.clear(); itsComment.clear(); itsMinutesLength = 0; itsSecondsLength = 0; @@ -124,52 +124,67 @@ bool Song::Empty() const string Song::GetFile() const { - return itsGetEmptyFields ? (itsFile.empty() ? "" : itsFile) : (itsFile.empty() ? EMPTY_TAG : itsFile); + return itsFile.empty() ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsFile; } string Song::GetShortFilename() const { - return itsGetEmptyFields ? (itsShortName.empty() ? "" : itsShortName) : (itsShortName.empty() ? EMPTY_TAG : itsShortName); + return itsShortName.empty() ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsShortName; } string Song::GetDirectory() const { - return itsGetEmptyFields ? (itsDirectory.empty() ? "" : itsDirectory) : (itsDirectory.empty() ? EMPTY_TAG : itsDirectory); + return itsDirectory.empty() ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsDirectory; } string Song::GetArtist() const { - return itsGetEmptyFields ? (itsArtist.empty() ? "" : itsArtist) : (itsArtist.empty() ? UNKNOWN_ARTIST : itsArtist); + return itsArtist.empty() ? (itsGetEmptyFields ? "" : UNKNOWN_ARTIST) : itsArtist; } string Song::GetTitle() const { - return itsGetEmptyFields ? (itsTitle.empty() ? "" : itsTitle) : (itsTitle.empty() ? UNKNOWN_TITLE : itsTitle); + return itsTitle.empty() ? (itsGetEmptyFields ? "" : UNKNOWN_TITLE) : itsTitle; } string Song::GetAlbum() const { - return itsGetEmptyFields ? (itsAlbum.empty() ? "" : itsAlbum) : (itsAlbum.empty() ? UNKNOWN_ALBUM : itsAlbum); + return itsAlbum.empty() ? (itsGetEmptyFields ? "" : UNKNOWN_ALBUM) : itsAlbum; } string Song::GetTrack() const { - return itsGetEmptyFields ? (itsTrack.empty() ? "" : (StrToInt(itsTrack) < 10 && itsTrack[0] != '0' ? "0"+itsTrack : itsTrack)) : (itsTrack.empty() ? EMPTY_TAG : (StrToInt(itsTrack) < 10 && itsTrack[0] != '0' ? "0"+itsTrack : itsTrack)); + return itsTrack.empty() ? (itsGetEmptyFields ? "" : EMPTY_TAG) : (StrToInt(itsTrack) < 10 && itsTrack[0] != '0' ? "0"+itsTrack : itsTrack); } string Song::GetYear() const { - return itsGetEmptyFields ? (itsYear.empty() ? "" : itsYear) : (itsYear.empty() ? EMPTY_TAG : itsYear); + return itsYear.empty() ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsYear; } string Song::GetGenre() const { - return itsGetEmptyFields ? (itsGenre.empty() ? "" : itsGenre) : (itsGenre.empty() ? EMPTY_TAG : itsGenre); + return itsGenre.empty() ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsGenre; +} + +string Song::GetComposer() const +{ + return itsComposer.empty() ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsComposer; +} + +string Song::GetPerformer() const +{ + return itsPerformer.empty() ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsPerformer; +} + +string Song::GetDisc() const +{ + return itsDisc.empty() ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsDisc; } string Song::GetComment() const { - return itsGetEmptyFields ? (itsComment.empty() ? "" : itsComment) : (itsComment.empty() ? EMPTY_TAG : itsComment); + return itsComment.empty() ? (itsGetEmptyFields ? "" : EMPTY_TAG) : itsComment; } Song & Song::operator=(const Song &s) diff --git a/src/song.h b/src/song.h index 0f293e90..c08dce2c 100644 --- a/src/song.h +++ b/src/song.h @@ -50,9 +50,9 @@ class Song string GetYear() const; string GetGenre() const; //string GetName() const { return itsName; } - //string GetComposer() const { return itsComposer; } - //string GetPerformer() const { return itsPerformer; } - //string GetDisc() const { return itsDisc; } + string GetComposer() const; + string GetPerformer() const; + string GetDisc() const; string GetComment() const; string GetLength() const; long long GetHash() const { return itsHash; } @@ -92,9 +92,9 @@ class Song //string itsName; string itsYear; string itsGenre; - //string itsComposer; - //string itsPerformer; - //string itsDisc; + string itsComposer; + string itsPerformer; + string itsDisc; string itsComment; long long itsHash; int itsMinutesLength; @@ -104,7 +104,5 @@ class Song bool itsGetEmptyFields; }; -//void GetCurrentPlaylist(vector &); - #endif