From 3ad2a5f201e3a6042e8b692117acf7ab713a1eaf Mon Sep 17 00:00:00 2001 From: Ashik K Date: Mon, 20 Mar 2023 18:34:09 +0100 Subject: [PATCH] Parse unique_id and generate item url link - also add it to csv --- parser.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/parser.cc b/parser.cc index e441b23..da8860f 100644 --- a/parser.cc +++ b/parser.cc @@ -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 <<