Skip to content

Commit

Permalink
Fixfetcher (JabRef#5948)
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Feb 19, 2020
1 parent 0a8c414 commit c768697
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,7 +64,11 @@ public Optional<URL> 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)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,6 +18,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@FetcherTest
public class FulltextFetchersTest {
private BibEntry entry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ void findSingleEntry() throws FetcherException {
void findManyEntries() throws FetcherException {
List<BibEntry> foundEntries = finder.performSearch("random test string");

assertEquals(10, foundEntries.size());
assertEquals(20, foundEntries.size());
}
}

0 comments on commit c768697

Please sign in to comment.