image.getWiki(),
Collections.singletonList(imagePage), false, false);
// Use image description on the wiki
if (Boolean.TRUE.equals(imagePage.isExisting())) {
PageAnalysis pageAnalysis = imagePage.getAnalysis(imagePage.getContents(), true);
for (PageElementTemplate template : pageAnalysis.getTemplates()) {
if (Page.areSameTitle("Information", template.getTemplateName())) {
String description = template.getParameterValue("Description");
if ((description != null) && (description.trim().length() > 0)) {
result.add(description.trim());
}
}
}
}
// Retrieve image description on Commons
Page commonsPage = DataManager.getPage(
EnumWikipedia.COMMONS,
"File:" + image.getImage(),
null, null, null);
api.retrieveContents(
EnumWikipedia.COMMONS,
Collections.singletonList(commonsPage), false, false);
if (Boolean.TRUE.equals(commonsPage.isExisting())) {
PageAnalysis pageAnalysis = commonsPage.getAnalysis(commonsPage.getContents(), true);
for (PageElementTemplate template : pageAnalysis.getTemplates()) {
if (Page.areSameTitle("Information", template.getTemplateName())) {
String global = template.getParameterValue("Description");
if ((global != null) && (global.trim().length() > 0)) {
PageAnalysis descAnalysis = commonsPage.getAnalysis(global, true);
for (PageElementTemplate template2 : descAnalysis.getTemplates()) {
if (Page.areSameTitle(image.getWiki().getSettings().getCode(), template2.getTemplateName())) {
String description = template2.getParameterValue("1");
if ((description != null) && (description.trim().length() > 0)) {
result.add(description.trim());
}