Added MP3 tagging

This commit is contained in:
Nedko 2024-07-01 15:39:42 +03:00
parent 42ab8dbcb1
commit 7c213fe037
2 changed files with 76 additions and 3 deletions

View File

@ -38,7 +38,22 @@ https://github.com/nlohmann/json
# eyeD3
https://eyed3.readthedocs.io/en/latest/
* For MP3 tagging
* TODO: Add info here
```
// Common
--encoding utf8
--preserve-file-times
// First Step - Remove Images
--remove-all-images
// Second Step - Change what is needed
--add-image "...":FRONT_COVER
--artist "..."
--album "..."
--title "..."
--track ...
```
# metaflac
https://xiph.org/flac/download.html

View File

@ -29,6 +29,42 @@ string gen_resize_command(const string& release_folder, const string& convert_ex
return cmd;
}
string gen_mp3_clear(const string& filepath, const string& eyed3_exec)
{
string cmd;
cmd = eyed3_exec;
cmd += " --preserve-file-times --remove-all-images \"";
cmd += filepath;
cmd += "\" > /dev/null 2>&1";
return cmd;
}
string gen_mp3_set_tags(const string& filepath, const string& artist,
const string& title, const string& album, int track_num,
const string& cover_filepath, string eyed3_exec)
{
string cmd;
cmd = eyed3_exec;
cmd += " --encoding utf8 --preserve-file-times --add-image \"";
cmd += cover_filepath;
cmd += "\":FRONT_COVER --artist \"";
cmd += artist;
// cmd += "\" --album \"";
// cmd += album;
cmd += "\" --title \"";
cmd += title;
cmd += "\" --track ";
cmd += to_string(track_num);
cmd += " \"";
cmd += filepath;
cmd += "\" > /dev/null 2>&1";
return cmd;
}
int main(int argc, char **argv)
{
// Config stuff
@ -125,7 +161,6 @@ int main(int argc, char **argv)
cout << "Could not resize cover for release - " << release.catalog_id << endl;
continue;
}
break;
// Download tracks (1 -- N)
for (Track& track : release.tracks)
@ -143,7 +178,30 @@ int main(int argc, char **argv)
continue;
}
// TODO: Tag MP3
// Clean MP3 Images
ok = exec_cmd(gen_mp3_clear(filepath, eyed3_exec));
if (!ok)
{
cout << "Could not clear images for MP3 track " << track.number <<
" from release " << release.catalog_id << endl;
continue;
}
// Tag MP3
ok = exec_cmd(
gen_mp3_set_tags(filepath,
track.artist,
track.title,
release.title,
track.number,
build_fname(release_folder, "", "Cover_small.jpg"),
eyed3_exec));
if (!ok)
{
cout << "Could not tag MP3 track " << track.number <<
" from release " << release.catalog_id << endl;
continue;
}
// Download FLAC
filepath = build_fname(flac_folder, "", filename);