Working on #56
This commit is contained in:
@@ -10,6 +10,7 @@ extern "C"
|
||||
{
|
||||
|
||||
void retrieve_metadata(Song*, char*);
|
||||
void update_metadata(Song*, Song*);
|
||||
|
||||
void retrieve_metadata(Song *sng, char* song_path)
|
||||
{
|
||||
@@ -24,5 +25,28 @@ void retrieve_metadata(Song *sng, char* song_path)
|
||||
sng->Duration = file.audioProperties()->lengthInSeconds();
|
||||
strcpy(sng->SongPath, song_path);
|
||||
}
|
||||
void update_metadata(Song *sng_updated, Song *sng_old)
|
||||
{
|
||||
std::cout<<"updating metadata"<<std::endl;
|
||||
TagLib::FileRef file(sng_old->SongPath);
|
||||
|
||||
if (strlen(sng_updated->Title) > 0) {
|
||||
file.tag()->setTitle(sng_updated->Title);
|
||||
}
|
||||
if (strlen(sng_updated->Artist) > 0) {
|
||||
file.tag()->setArtist(sng_updated->Artist);
|
||||
}
|
||||
if (strlen(sng_updated->Album) > 0) {
|
||||
file.tag()->setAlbum(sng_updated->Album);
|
||||
}
|
||||
if (strlen(sng_updated->Genre) > 0) {
|
||||
file.tag()->setGenre(sng_updated->Genre);
|
||||
}
|
||||
if (sng_updated->Year > 0) {
|
||||
file.tag()->setYear(sng_updated->Year);
|
||||
}
|
||||
|
||||
file.save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user