diff options
author | Allan Wang <me@allanwang.ca> | 2017-10-25 12:41:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-25 12:41:05 -0400 |
commit | e04487f5b1a4c6a5999db8d9746a07919ae9a333 (patch) | |
tree | 4a60e9369dbb957c0f47f6052510433bc9d37e01 /app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt | |
parent | 2d6b790643078b9b5ff2869c74dc941212087864 (diff) | |
download | frost-e04487f5b1a4c6a5999db8d9746a07919ae9a333.tar.gz frost-e04487f5b1a4c6a5999db8d9746a07919ae9a333.tar.bz2 frost-e04487f5b1a4c6a5999db8d9746a07919ae9a333.zip |
Update search logic (#444)
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 | 13 |
1 files changed, 7 insertions, 6 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 37c09299..908bb153 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt @@ -2,7 +2,7 @@ package com.pitchedapps.frost.parsers import ca.allanwang.kau.utils.withMaxLength import com.pitchedapps.frost.facebook.FbItem -import com.pitchedapps.frost.facebook.formattedFbUrlCss +import com.pitchedapps.frost.facebook.formattedFbUrl import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.frostJsoup import org.jsoup.Jsoup @@ -14,7 +14,7 @@ import org.jsoup.nodes.Element */ object SearchParser : FrostParser<List<FrostSearch>> by SearchParserImpl() { fun query(input: String): List<FrostSearch>? { - val url = "${FbItem.SEARCH.url}?q=$input" + val url = "${FbItem._SEARCH.url}?q=${if (input.isNotBlank()) input else "a"}" L.i(null, "Search Query $url") return parse(frostJsoup(url)) } @@ -51,10 +51,10 @@ private class SearchParserImpl : FrostParserBase<List<FrostSearch>>() { * * Removed [data-store*=result_id] */ - return container.select("a.touchable.primary[href]").filter(Element::hasText).mapNotNull { - FrostSearch(it.attr("href").formattedFbUrlCss, - it.select(".title").first()?.text() ?: "", - it.select(".subtitle").first()?.ownText()) + return container.select("a.touchable[href]").filter(Element::hasText).map { + FrostSearch(it.attr("href").formattedFbUrl, + it.select("._uoi").first()?.text() ?: "", + it.select("._1tcc").first()?.text()) }.filter { it.title.isNotBlank() } } @@ -62,6 +62,7 @@ private class SearchParserImpl : FrostParserBase<List<FrostSearch>>() { override fun textToDoc(text: String): Document? = Jsoup.parse(text) override fun debugImpl(data: List<FrostSearch>, result: MutableList<String>) { + result.add("Has size ${data.size}") result.addAll(data.map(FrostSearch::toString)) } |