@@ -21,6 +21,8 @@ import com.mugames.vidsnapkit.*
2121import com.mugames.vidsnapkit.Util.Companion.decodeHTML
2222import com.mugames.vidsnapkit.dataholders.*
2323import com.mugames.vidsnapkit.network.HttpRequest
24+ import io.ktor.client.statement.*
25+ import io.ktor.http.*
2426import org.json.JSONArray
2527import org.json.JSONException
2628import org.json.JSONObject
@@ -46,14 +48,22 @@ class Facebook internal constructor(url: String) : Extractor(url) {
4648
4749 private suspend fun isCookieValid (): Boolean {
4850 if (cookies.isNullOrEmpty()) return false
49- val res = HttpRequest (" https://www.facebook.com/" , headers).getResponse(false ) ? : return false
50- val restrictedKeywords = listOf (" Create new account" , " log in or sign up" , " Forgotten password" )
51- val containsRestrictedKeyword = restrictedKeywords.any { keyword ->
52- res.contains(keyword, ignoreCase = true )
51+ val res = HttpRequest (" https://www.facebook.com/" , headers).getRawResponse(false ) ? : return false
52+ if (res.status == HttpStatusCode .OK ) {
53+ val restrictedKeywords = listOf (" Create new account" , " log in or sign up" , " Forgotten password" )
54+ val containsRestrictedKeyword = restrictedKeywords.any { keyword ->
55+ res.bodyAsText().contains(keyword, ignoreCase = true )
56+ }
57+ logger.info(" Check cookie containsRestrictedKeyword=${containsRestrictedKeyword} " )
58+ return ! containsRestrictedKeyword
5359 }
54-
55- logger.info(" Check cookie containsRestrictedKeyword=${containsRestrictedKeyword} " )
56- return ! containsRestrictedKeyword
60+ if (res.status == HttpStatusCode .Found ){
61+ logger.info(" Oops! redirection found for ${res.headers[" location" ]} " )
62+ if (res.call.request.url.toString().contains(" checkpoint" )){
63+ return false
64+ }
65+ }
66+ return true
5767 }
5868
5969 override suspend fun analyze (payload : Any? ) {
0 commit comments