From d96d1d06a7c1581b97c042f2a74e7cd5b1c2546e Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 17 Apr 2021 17:49:18 -0700 Subject: Update theme providers and readd koin modules --- .../frost/facebook/parsers/SearchParser.kt | 52 +++++++++++----------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/SearchParser.kt') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/SearchParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/SearchParser.kt index 68c629a9..0c9a7e92 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/SearchParser.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/SearchParser.kt @@ -90,31 +90,33 @@ private class SearchParserImpl : FrostParserBase(false) { ?: doc.getElementById("root") ?: return null - return FrostSearches(container.select("table[role=presentation]").mapNotNull { el -> - // Our assumption is that search entries start with an image, followed by general info - // There may be other s, but we will not be parsing them - // Furthermore, the entry wraps a link, containing all the necessary info - val a = el.select("td") - .getOrNull(1) - ?.selectFirst("a") - ?: return@mapNotNull null - val url = - a.attr("href").takeIf { it.isNotEmpty() } - ?.formattedFbUrl?.formattedSearchUrl + return FrostSearches( + container.select("table[role=presentation]").mapNotNull { el -> + // Our assumption is that search entries start with an image, followed by general info + // There may be other s, but we will not be parsing them + // Furthermore, the entry wraps a link, containing all the necessary info + val a = el.select("td") + .getOrNull(1) + ?.selectFirst("a") ?: return@mapNotNull null - // Currently, children should all be
elements, where the first entry is the name/title - // And the other entries are additional info. - // There are also cases of nested tables, eg for the "join" button in groups. - // Those elements have texts, so we will filter by div to ignore those - val texts = a.children().filter { it.tagName() == "div" && it.hasText() } - val title = texts.firstOrNull()?.text() ?: return@mapNotNull null - val info = texts.takeIf { it.size > 1 }?.last()?.text() - L.e { a } - create( - href = url, - title = title, - description = info - ).also { L.e { it } } - }) + val url = + a.attr("href").takeIf { it.isNotEmpty() } + ?.formattedFbUrl?.formattedSearchUrl + ?: return@mapNotNull null + // Currently, children should all be
elements, where the first entry is the name/title + // And the other entries are additional info. + // There are also cases of nested tables, eg for the "join" button in groups. + // Those elements have texts, so we will filter by div to ignore those + val texts = a.children().filter { it.tagName() == "div" && it.hasText() } + val title = texts.firstOrNull()?.text() ?: return@mapNotNull null + val info = texts.takeIf { it.size > 1 }?.last()?.text() + L.e { a } + create( + href = url, + title = title, + description = info + ).also { L.e { it } } + } + ) } } -- cgit v1.2.3