diff options
author | Allan Wang <me@allanwang.ca> | 2017-10-13 20:32:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-13 20:32:25 -0400 |
commit | 62b628b2d0fb8d0c76592bcd5347e5bcec6106c4 (patch) | |
tree | eb43713ea751d9302bd7fd1b6a0610c2bb45c7fc /app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt | |
parent | 4ad2d23ceccc23f8b11b0a5e712a1f08722611df (diff) | |
download | frost-62b628b2d0fb8d0c76592bcd5347e5bcec6106c4.tar.gz frost-62b628b2d0fb8d0c76592bcd5347e5bcec6106c4.tar.bz2 frost-62b628b2d0fb8d0c76592bcd5347e5bcec6106c4.zip |
Improve search parse (#401)
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt index 0d542a80..37c09299 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt @@ -47,23 +47,18 @@ private class SearchParserImpl : FrostParserBase<List<FrostSearch>>() { val container: Element = doc.getElementById("BrowseResultsContainer") ?: doc.getElementById("root") ?: return null - val hrefSet = mutableSetOf<String>() /** - * When mapping items, some links are duplicated because they are nested below a main one - * We will filter out search items whose links are already in the list * * Removed [data-store*=result_id] */ return container.select("a.touchable.primary[href]").filter(Element::hasText).mapNotNull { - val item = FrostSearch(it.attr("href").formattedFbUrlCss, - it.select("._uok").first()?.text() ?: it.text(), - it.select("._1tcc").first()?.text()) - if (hrefSet.contains(item.href)) return@mapNotNull null - hrefSet.add(item.href) - item - } + FrostSearch(it.attr("href").formattedFbUrlCss, + it.select(".title").first()?.text() ?: "", + it.select(".subtitle").first()?.ownText()) + }.filter { it.title.isNotBlank() } } + override fun textToDoc(text: String): Document? = Jsoup.parse(text) override fun debugImpl(data: List<FrostSearch>, result: MutableList<String>) { |