SISIS extends OkHttpBaseApi implements OpacApi { static String parseCoverJs(String coverJs, String opac_url) { String url; Pattern imgSrcPattern = Pattern.compile("var imgSrc = '([^']+)'"); Matcher matcher = imgSrcPattern.matcher(coverJs); if (matcher.find()) { url = matcher.group(1); } else { Pattern bookInfoPattern = Pattern.compile("var bookInfo = JSON\\.parse\\('([^']+)'\\)"); matcher = bookInfoPattern.matcher(coverJs); if (matcher.find()) { try { JSONObject bookInfo = new JSONObject(matcher.group(1)); url = bookInfo.getJSONObject((String) bookInfo.keys().next()) .getString("thumbnail_url"); } catch (JSONException e) { return null; } } else { Pattern srcPattern = Pattern.compile("<img .* src=\"([^\"]+)\">"); matcher = srcPattern.matcher(coverJs); if (matcher.find()) { url = matcher.group(1); } else { return null; } } } try { return new URI(opac_url + "/").resolve(url).toString(); } catch (URISyntaxException e) { return null; } }  List<SearchField> parseSearchFields(); @Override void start(); @Override void init(Library lib, HttpClientFactory httpClientFactory); @Override SearchRequestResult search(List<SearchQuery> query); SearchRequestResult volumeSearch(Map<String, String> query); @Override SearchRequestResult searchGetPage(int page); SearchRequestResult parse_search(String html, int page); @Override DetailedItem getResultById(String id, String homebranch); @Override DetailedItem getResult(int nr); @Override ReservationResult reservation(DetailedItem item, Account acc,
            int useraction, String selection); @Override ProlongResult prolong(String a, Account account, int useraction,
            String Selection); @Override CancelResult cancel(String media, Account account, int useraction,
            String selection); static void parse_medialist(List<LentItem> media, Document doc, int offset,
            JSONObject data); static void parse_reslist6(List<ReservedItem> reservations, Document doc, int offset,
            JSONObject data); static void parse_reslist7(List<ReservedItem> reservations, Document doc, int offset,
            JSONObject data); @Override String getPendingAccountFees(Account account); @Override AccountData account(Account acc); @Override String getShareUrl(String id, String title); @Override int getSupportFlags(); @Override ProlongAllResult prolongAll(Account account, int useraction,
            String selection); @Override SearchRequestResult filterResults(Filter filter, Option option); @Override void checkAccountData(Account account); @Override void setLanguage(String language); @Override Set<String> getSupportedLanguages();  }
@Test public void testParseCoverJs() { String lampertheim = " var bookInfo = JSON.parse" + "('{\"ISBN:9783455010312\":{\"bib_key\":\"ISBN:9783455010312\"," + "\"info_url\":\"https: ".com/books?id=q76xAgAACAAJ\\u0026source=gbs_ViewAPI\"," + "\"preview_url\":\"https: ".com/books?id=q76xAgAACAAJ\\u0026source=gbs_ViewAPI\"," + "\"thumbnail_url\":\"https: ".com/books/content?id=q76xAgAACAAJ\\u0026printsec=frontcover\\u0026img=1" + "\\u0026zoom=5\",\"preview\":\"noview\",\"embeddable\":false," + "\"can_download_pdf\":false,\"can_download_epub\":false," + "\"is_pdf_drm_enabled\":false,\"is_epub_drm_enabled\":false}}');\n" + " var book = bookInfo[Object.keys(bookInfo)[0]]; \n" + " \n" + " \n" + " var imgTag = '<img style=\"margin: 5px; border: 0px solid #666; ' + size +" + " '\" border=0 src=\"' + book.thumbnail_url + '\">';"; String url = SISIS.parseCoverJs(lampertheim, "https: assertEquals("https: "=frontcover&img=1&zoom=5", url); String wuppertal = " var imgSrc = 'showMVBCover" + ".do?token=2aa75c57-40a7-4c99-b501-d49b39ada7a9';\n" + " var imgTag = '<img style=\"margin: 10px; \" border=0 src=\"' + imgSrc + " + "'\"/>';\n" + " var detailUrl = \"http: " var imgLink= '<a href=' + detailUrl + ' target=\"cover\">' + imgTag + " + "'</a>';\n" + " $(\"div#-1_5\").html(imgLink);\n" + " "; url = SISIS.parseCoverJs(wuppertal, "http: assertEquals( "http: url); }