Scan all image links

This commit is contained in:
M66B 2020-12-10 22:09:36 +01:00
parent ea5f9d7e28
commit 6daad8ed45
1 changed files with 33 additions and 7 deletions

View File

@ -477,16 +477,42 @@ public class ContactInfo {
Document doc = JsoupEx.parse(response); Document doc = JsoupEx.parse(response);
Element link = doc.head().select("link[href~=.*\\.(ico|png|gif|svg)]").first(); List<Future<Bitmap>> futures = new ArrayList<>();
String favicon = (link == null ? null : link.attr("href"));
if (TextUtils.isEmpty(favicon)) { for (Element link : doc.head().select("link[href~=.*\\.(ico|png|gif|svg)]")) {
Element meta = doc.head().select("meta[itemprop=image]").first(); String favicon = link.attr("href");
favicon = (meta == null ? null : meta.attr("content")); if (TextUtils.isEmpty(favicon))
continue;
final URL url = new URL(base, favicon);
futures.add(executorFavicon.submit(new Callable<Bitmap>() {
@Override
public Bitmap call() throws Exception {
return getFavicon(url, scaleToPixels);
}
}));
} }
if (!TextUtils.isEmpty(favicon)) for (Element meta : doc.head().select("meta[itemprop=image]")) {
return getFavicon(new URL(base, favicon), scaleToPixels); String favicon = meta.attr("content");
if (TextUtils.isEmpty(favicon))
continue;
final URL url = new URL(base, favicon);
futures.add(executorFavicon.submit(new Callable<Bitmap>() {
@Override
public Bitmap call() throws Exception {
return getFavicon(url, scaleToPixels);
}
}));
}
for (Future<Bitmap> future : futures)
try {
return future.get();
} catch (Throwable ex) {
Log.e(ex);
}
return null; return null;
} }