From 9363d4bc987cb7b4886ffb6a863b5d14c602e402 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 7 Sep 2019 18:15:53 -0700 Subject: Remove desktop and mobile user agent def --- app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt | 6 +++--- app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt index b0012b0d..5e909b03 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt @@ -31,7 +31,7 @@ import ca.allanwang.kau.utils.string import ca.allanwang.kau.utils.toast import com.pitchedapps.frost.R import com.pitchedapps.frost.db.CookieEntity -import com.pitchedapps.frost.facebook.USER_AGENT_DESKTOP +import com.pitchedapps.frost.facebook.USER_AGENT /** * Created by Allan Wang on 2017-08-04. @@ -41,7 +41,7 @@ import com.pitchedapps.frost.facebook.USER_AGENT_DESKTOP fun Context.frostDownload( cookie: CookieEntity, url: String?, - userAgent: String = USER_AGENT_DESKTOP, + userAgent: String = USER_AGENT, contentDisposition: String? = null, mimeType: String? = null, contentLength: Long = 0L @@ -53,7 +53,7 @@ fun Context.frostDownload( fun Context.frostDownload( cookie: CookieEntity, uri: Uri?, - userAgent: String = USER_AGENT_DESKTOP, + userAgent: String = USER_AGENT, contentDisposition: String? = null, mimeType: String? = null, contentLength: Long = 0L diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 9022d51f..c2f28a4b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -63,7 +63,7 @@ import com.pitchedapps.frost.facebook.FBCDN_NET import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.FbUrlFormatter.Companion.VIDEO_REDIRECT -import com.pitchedapps.frost.facebook.USER_AGENT_DESKTOP +import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.facebook.formattedFbUri import com.pitchedapps.frost.facebook.formattedFbUrl import com.pitchedapps.frost.injectors.CssAssets @@ -74,6 +74,7 @@ import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import org.apache.commons.text.StringEscapeUtils import org.jsoup.Jsoup +import org.jsoup.nodes.Document import org.jsoup.nodes.Element import java.io.File import java.io.IOException @@ -388,13 +389,13 @@ fun EmailBuilder.addFrostDetails() { addItem("Locale", Locale.getDefault().displayName) } -fun frostJsoup(url: String) = frostJsoup(FbCookie.webCookie, url) +fun frostJsoup(url: String): Document = frostJsoup(FbCookie.webCookie, url) -fun frostJsoup(cookie: String?, url: String) = +fun frostJsoup(cookie: String?, url: String): Document = Jsoup.connect(url).run { if (cookie.isNullOrBlank()) this else cookie(FACEBOOK_COM, cookie) - }.userAgent(USER_AGENT_DESKTOP).get()!! + }.userAgent(USER_AGENT).get() fun Element.first(vararg select: String): Element? { select.forEach { -- cgit v1.2.3