Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixfetcher #5948

Merged
merged 2 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The curly brace should not be there. - Will be fixed in a follow-up-pr

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());
}
}