diff --git a/src/main/java/moe/nekojimi/musicsearcher/providers/MetaSearcher.java b/src/main/java/moe/nekojimi/musicsearcher/providers/MetaSearcher.java index e5b0297..5d3e0a3 100644 --- a/src/main/java/moe/nekojimi/musicsearcher/providers/MetaSearcher.java +++ b/src/main/java/moe/nekojimi/musicsearcher/providers/MetaSearcher.java @@ -10,6 +10,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.CompletableFuture; +import moe.nekojimi.musicsearcher.Query; import moe.nekojimi.musicsearcher.Result; /** @@ -29,7 +30,7 @@ public class MetaSearcher extends Searcher } @Override - protected List doSearch(String query) + protected List doSearch(Query query) { List results = new ArrayList<>(); List>> searches = new ArrayList<>(); diff --git a/src/main/java/moe/nekojimi/musicsearcher/providers/SearchHackSearcher.java b/src/main/java/moe/nekojimi/musicsearcher/providers/SearchHackSearcher.java new file mode 100644 index 0000000..6ebc757 --- /dev/null +++ b/src/main/java/moe/nekojimi/musicsearcher/providers/SearchHackSearcher.java @@ -0,0 +1,44 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package moe.nekojimi.musicsearcher.providers; + +import com.amihaiemil.eoyaml.YamlMapping; +import java.net.MalformedURLException; +import java.net.URL; +import moe.nekojimi.musicsearcher.parsers.HTMLParser; + +/** + * + * @author jim + */ +public class SearchHackSearcher extends WebScraperSearcher +{ + + private final String site; + + public SearchHackSearcher(YamlMapping yaml) throws MalformedURLException + { + super(yaml.string("name")); + searchUrl = "https://html.duckduckgo.com/html/"; + rootURL = new URL(searchUrl); + parser = new HTMLParser(); + site = yaml.string("site"); + + resultSelector = "div.result"; + resultTitleSelector = ".result__title"; + resultLinkSelector = ".result__url"; + + } + + @Override + protected String transformSearchString(String search) + { + return "site:"+site + " " + search; + } + + + +}