add support for composer, performer and disc tags
This commit is contained in:
@@ -36,7 +36,10 @@
|
|||||||
## %y - year
|
## %y - year
|
||||||
## %n - track number
|
## %n - track number
|
||||||
## %g - genre
|
## %g - genre
|
||||||
## %c - comment
|
## %c - composer
|
||||||
|
## %p - performer
|
||||||
|
## %d - disc
|
||||||
|
## %C - comment
|
||||||
##
|
##
|
||||||
## you can also put them in { } and then it will be displayed
|
## you can also put them in { } and then it will be displayed
|
||||||
## only if all requested values are available and/or define alternate
|
## only if all requested values are available and/or define alternate
|
||||||
|
|||||||
@@ -301,6 +301,54 @@ string DisplaySong(const Song &s, const string &song_template)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'c':
|
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)
|
if (link_tags)
|
||||||
{
|
{
|
||||||
|
|||||||
47
src/song.cpp
47
src/song.cpp
@@ -51,9 +51,9 @@ Song::Song(mpd_Song *s) : itsHash(0),
|
|||||||
//s->name ? itsName = s->name : itsName = "";
|
//s->name ? itsName = s->name : itsName = "";
|
||||||
s->date ? itsYear = s->date : itsYear = "";
|
s->date ? itsYear = s->date : itsYear = "";
|
||||||
s->genre ? itsGenre = s->genre : itsGenre = "";
|
s->genre ? itsGenre = s->genre : itsGenre = "";
|
||||||
//s->composer ? itsComposer = s->composer : itsComposer = "";
|
s->composer ? itsComposer = s->composer : itsComposer = "";
|
||||||
//s->performer ? itsPerformer = s->performer : itsPerformer = "";
|
s->performer ? itsPerformer = s->performer : itsPerformer = "";
|
||||||
//s->disc ? itsDisc = s->disc : itsDisc = "";
|
s->disc ? itsDisc = s->disc : itsDisc = "";
|
||||||
s->comment ? itsComment = s->comment : itsComment = "";
|
s->comment ? itsComment = s->comment : itsComment = "";
|
||||||
|
|
||||||
int i = itsFile.size();
|
int i = itsFile.size();
|
||||||
@@ -107,9 +107,9 @@ void Song::Clear()
|
|||||||
//itsName.clear();
|
//itsName.clear();
|
||||||
itsYear.clear();
|
itsYear.clear();
|
||||||
itsGenre.clear();
|
itsGenre.clear();
|
||||||
//itsComposer.clear();
|
itsComposer.clear();
|
||||||
//itsPerformer.clear();
|
itsPerformer.clear();
|
||||||
//itsDisc.clear();
|
itsDisc.clear();
|
||||||
itsComment.clear();
|
itsComment.clear();
|
||||||
itsMinutesLength = 0;
|
itsMinutesLength = 0;
|
||||||
itsSecondsLength = 0;
|
itsSecondsLength = 0;
|
||||||
@@ -124,52 +124,67 @@ bool Song::Empty() const
|
|||||||
|
|
||||||
string Song::GetFile() 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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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)
|
Song & Song::operator=(const Song &s)
|
||||||
|
|||||||
14
src/song.h
14
src/song.h
@@ -50,9 +50,9 @@ class Song
|
|||||||
string GetYear() const;
|
string GetYear() const;
|
||||||
string GetGenre() const;
|
string GetGenre() const;
|
||||||
//string GetName() const { return itsName; }
|
//string GetName() const { return itsName; }
|
||||||
//string GetComposer() const { return itsComposer; }
|
string GetComposer() const;
|
||||||
//string GetPerformer() const { return itsPerformer; }
|
string GetPerformer() const;
|
||||||
//string GetDisc() const { return itsDisc; }
|
string GetDisc() const;
|
||||||
string GetComment() const;
|
string GetComment() const;
|
||||||
string GetLength() const;
|
string GetLength() const;
|
||||||
long long GetHash() const { return itsHash; }
|
long long GetHash() const { return itsHash; }
|
||||||
@@ -92,9 +92,9 @@ class Song
|
|||||||
//string itsName;
|
//string itsName;
|
||||||
string itsYear;
|
string itsYear;
|
||||||
string itsGenre;
|
string itsGenre;
|
||||||
//string itsComposer;
|
string itsComposer;
|
||||||
//string itsPerformer;
|
string itsPerformer;
|
||||||
//string itsDisc;
|
string itsDisc;
|
||||||
string itsComment;
|
string itsComment;
|
||||||
long long itsHash;
|
long long itsHash;
|
||||||
int itsMinutesLength;
|
int itsMinutesLength;
|
||||||
@@ -104,7 +104,5 @@ class Song
|
|||||||
bool itsGetEmptyFields;
|
bool itsGetEmptyFields;
|
||||||
};
|
};
|
||||||
|
|
||||||
//void GetCurrentPlaylist(vector<Song> &);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user