Parse unique_id and generate item url link

- also add it to csv
This commit is contained in:
Ashik K 2023-03-20 18:34:09 +01:00
parent 780c8be1e6
commit 3ad2a5f201
1 changed files with 13 additions and 1 deletions

View File

@ -23,7 +23,7 @@ int main(int argc, char **argv)
snprintf(filename, sizeof filename, "out.csv");
std::ofstream out_file1;
out_file1.open(filename);
out_file1<<"id, Caption/title, production start year, end year, Description, Source, image_filename, subjects, date published, collection name, museum name, exif_model, exif_iso, exif_focallength, exif_exposuretime, exif_aperture, exif_datetimeoriginal, liceses\n";
out_file1<<"id, Caption/title, production start year, end year, Description, Item url, Image Source, image_filename, subjects, date published, collection name, museum name, exif_model, exif_iso, exif_focallength, exif_exposuretime, exif_aperture, exif_datetimeoriginal, liceses\n";
for (auto i = 0; i<4; i++) {
char in_file_i[64];
snprintf(in_file_i, sizeof in_file_i, "data_%d.json", i);
@ -85,6 +85,14 @@ int main(int argc, char **argv)
yeare = yeareval.GetInt();
}
std::string unique_id = "";
if (article.HasMember("artifact.uniqueId")) {
const rapidjson::Value& uniqidval = article["artifact.uniqueId"];
if (uniqidval.IsString()) {
unique_id = uniqidval.GetString();
}
}
std::string mediaid = "";
int picid = -1;
std::string picdim = "";
@ -112,6 +120,9 @@ int main(int argc, char **argv)
char imglink[128];
snprintf(imglink, sizeof imglink, "https://mm.dimu.org/image/%s", mediaid.c_str());
char itemlink[128];
snprintf(itemlink, sizeof itemlink, "https://digitaltmuseum.se/%s", unique_id.c_str());
char descfilename[64];
@ -237,6 +248,7 @@ int main(int argc, char **argv)
", "<< yearstr(yearb) <<
", "<< yearstr(yeare) <<
", "<< description <<
", "<< itemlink <<
", "<< imglink <<
", "<< article_id+"-"+ mediaid +".jpeg" <<
", "<< subjects <<