Skip to content

Commit

Permalink
SISIS: fix regex for cover URL for Dresden Städtische Bibliotheken
Browse files Browse the repository at this point in the history
The url starts with "/webOPACClient/" here, which is also part of the opac_url,
so we retrieve just the part starting with "jsp/result..."
Eliminate duplicate definition of the regex in parse_search and loadDetail.
  • Loading branch information
StefRe committed Oct 29, 2020
1 parent a1bc27b commit 1e582f9
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ public class SISIS extends OkHttpBaseApi implements OpacApi {
protected long logged_in;
protected Account logged_in_as;
protected static final String ENCODING = "UTF-8";
protected static final Pattern coverPattern = Pattern.compile(
"\\$\\.ajax\\(\\{\\s*url:\\s*'(?:/webOPACClient/)?(jsp/result/cover.jsp\\?[^']+)'");

protected String getDefaultEncoding() {
return ENCODING;
Expand Down Expand Up @@ -472,9 +474,7 @@ public SearchRequestResult parse_search(String html, int page)

// covers loaded with AJAX (seen in Wuppertal)
if (tr.children().size() > 3 && tr.child(3).html().contains("jsp/result/cover.jsp")) {
Pattern pattern = Pattern.compile(
"\\$\\.ajax\\(\\{\\s*url:\\s*'(jsp/result/cover.jsp\\?[^']+)',");
Matcher matcher = pattern.matcher(tr.child(3).html());
Matcher matcher = coverPattern.matcher(tr.child(3).html());
if (matcher.find()) {
String url = opac_url + "/" + matcher.group(1);
futures.add(CompletableFuture.runAsync(() -> {
Expand Down Expand Up @@ -744,8 +744,6 @@ protected DetailedItem loadDetail(String html) throws IOException {
ENCODING);

String coverJs = null;
Pattern coverPattern = Pattern.compile("\\$\\.ajax\\(\\{[\\n\\s]*url: '(jsp/result/cover" +
".jsp\\?[^']+')");
Matcher coverMatcher = coverPattern.matcher(html);
if (coverMatcher.find()) {
coverJs = httpGet(opac_url + "/" + coverMatcher.group(1), ENCODING);
Expand Down

0 comments on commit 1e582f9

Please sign in to comment.