Added cover resizing
This commit is contained in:
parent
21058e5ac4
commit
42ab8dbcb1
14
common.cpp
14
common.cpp
@ -3,6 +3,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@ -187,3 +188,16 @@ string clean_filename(const string& s)
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool exec_cmd(const string& cmd)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = system(cmd.c_str());
|
||||||
|
if (0 != error)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
1
common.h
1
common.h
@ -19,5 +19,6 @@ void json_extract(const nlohmann::json& j, const std::string& key, bool& out);
|
|||||||
bool ensure_folder(const std::string& main_path, const std::string& folder);
|
bool ensure_folder(const std::string& main_path, const std::string& folder);
|
||||||
std::string trim_whitespace(const std::string& s);
|
std::string trim_whitespace(const std::string& s);
|
||||||
std::string clean_filename(const std::string& s);
|
std::string clean_filename(const std::string& s);
|
||||||
|
bool exec_cmd(const std::string& cmd);
|
||||||
|
|
||||||
#endif // COMMON_H_
|
#endif // COMMON_H_
|
||||||
|
|||||||
23
main.cpp
23
main.cpp
@ -15,6 +15,20 @@ void usage(const char *name)
|
|||||||
cout << "Usage: " << name << " [catalog id] ..." << endl;
|
cout << "Usage: " << name << " [catalog id] ..." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string gen_resize_command(const string& release_folder, const string& convert_exec)
|
||||||
|
{
|
||||||
|
string cmd;
|
||||||
|
|
||||||
|
cmd = convert_exec;
|
||||||
|
cmd += " \"";
|
||||||
|
cmd += build_fname(release_folder, "", "Cover.*");
|
||||||
|
cmd += "\" -resize 750x750 \"";
|
||||||
|
cmd += build_fname(release_folder, "", "Cover_small.jpg");
|
||||||
|
cmd += "\"";
|
||||||
|
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// Config stuff
|
// Config stuff
|
||||||
@ -104,7 +118,14 @@ int main(int argc, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Resize cover
|
// Resize cover
|
||||||
|
ok = exec_cmd(gen_resize_command(release_folder, convert_exec));
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
cout << "Could not resize cover for release - " << release.catalog_id << endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
// Download tracks (1 -- N)
|
// Download tracks (1 -- N)
|
||||||
for (Track& track : release.tracks)
|
for (Track& track : release.tracks)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user