diff --git a/src/main/java/org/jabref/logic/importer/fetcher/DoiResolution.java b/src/main/java/org/jabref/logic/importer/fetcher/DoiResolution.java index 84cca0e4b5a..beb1370586e 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/DoiResolution.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/DoiResolution.java @@ -27,6 +27,7 @@ * FulltextFetcher implementation that follows the DOI resolution redirects and scans for a full-text PDF URL. */ public class DoiResolution implements FulltextFetcher { + private static final Logger LOGGER = LoggerFactory.getLogger(DoiResolution.class); @Override @@ -63,7 +64,11 @@ public Optional findFullText(BibEntry entry) throws IOException { // Only check if pdf is included in the link or inside the text // ACM uses tokens without PDF inside the link // See https://github.com/lehner/LocalCopy for more scrape ideas - if ((href.contains("pdf") || hrefText.contains("pdf")) && new URLDownload(href).isPdf()) { + if (element.attr("title").toLowerCase(Locale.ENGLISH).contains("pdf") && new URLDownload(href).isPdf()) { + return Optional.of(new URL(href)); + } + + if (href.contains("pdf") || hrefText.contains("pdf") && new URLDownload(href).isPdf()) { links.add(Optional.of(new URL(href))); } } diff --git a/src/test/java/org/jabref/logic/importer/FulltextFetchersTest.java b/src/test/java/org/jabref/logic/importer/FulltextFetchersTest.java index 986165ad0ee..3db92d048c1 100644 --- a/src/test/java/org/jabref/logic/importer/FulltextFetchersTest.java +++ b/src/test/java/org/jabref/logic/importer/FulltextFetchersTest.java @@ -8,6 +8,7 @@ import org.jabref.logic.importer.fetcher.TrustLevel; import org.jabref.model.entry.BibEntry; +import org.jabref.testutils.category.FetcherTest; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -17,6 +18,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +@FetcherTest public class FulltextFetchersTest { private BibEntry entry; diff --git a/src/test/java/org/jabref/logic/importer/fetcher/DBLPFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/DBLPFetcherTest.java index d48c46f3f7e..8aa622253aa 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/DBLPFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/DBLPFetcherTest.java @@ -44,7 +44,7 @@ public void setUp() { entry.setField(StandardField.YEAR, "2016"); entry.setField(StandardField.URL, "http://pi.informatik.uni-siegen.de/stt/36_2/./03_Technische_Beitraege/ZEUS2016/beitrag_2.pdf"); - entry.setField(new UnknownField("biburl"), "https://dblp.org/rec/bib/journals/stt/GeigerHL16"); + entry.setField(new UnknownField("biburl"), "{https://dblp.org/rec/journals/stt/GeigerHL16.bib"); entry.setField(new UnknownField("bibsource"), "dblp computer science bibliography, https://dblp.org"); } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/GoogleScholarTest.java b/src/test/java/org/jabref/logic/importer/fetcher/GoogleScholarTest.java index 1eec09aab49..5d86db68a47 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/GoogleScholarTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/GoogleScholarTest.java @@ -77,6 +77,6 @@ void findSingleEntry() throws FetcherException { void findManyEntries() throws FetcherException { List foundEntries = finder.performSearch("random test string"); - assertEquals(10, foundEntries.size()); + assertEquals(20, foundEntries.size()); } }