cookie fix aka Tenshi fix

This commit is contained in:
LagradOst 2021-10-02 19:53:20 +02:00
parent 99717ef1f1
commit f9e3e5a2bf
4 changed files with 11 additions and 9 deletions

View file

@ -42,12 +42,12 @@ object APIHolder {
WatchCartoonOnlineProvider(), WatchCartoonOnlineProvider(),
AllMoviesForYouProvider(), AllMoviesForYouProvider(),
AsiaFlixProvider(), AsiaFlixProvider(),
TrailersToProvider(), // be aware that this is fuckery
VidEmbedProvider(), VidEmbedProvider(),
VfFilm() VfFilmProvider()
) )
val restrictedApis = arrayListOf( val restrictedApis = arrayListOf(
TrailersToProvider(), // be aware that this is fuckery
//NyaaProvider(), //torrents in cs3 is wack //NyaaProvider(), //torrents in cs3 is wack
ThenosProvider(), ThenosProvider(),
) )

View file

@ -212,6 +212,7 @@ class TenshiProvider : MainAPI() {
val url = "$mainUrl/anime" val url = "$mainUrl/anime"
var response = get(url, params = mapOf("q" to query), cookies = mapOf("loop-view" to "thumb")).text var response = get(url, params = mapOf("q" to query), cookies = mapOf("loop-view" to "thumb")).text
var document = Jsoup.parse(response) var document = Jsoup.parse(response)
val returnValue = parseSearchPage(document) val returnValue = parseSearchPage(document)
while (!document.select("""a.page-link[rel="next"]""").isEmpty()) { while (!document.select("""a.page-link[rel="next"]""").isEmpty()) {

View file

@ -1,18 +1,14 @@
package com.lagradost.cloudstream3.movieproviders package com.lagradost.cloudstream3.movieproviders
import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.network.get import com.lagradost.cloudstream3.network.get
import com.lagradost.cloudstream3.network.post
import com.lagradost.cloudstream3.network.text import com.lagradost.cloudstream3.network.text
import com.lagradost.cloudstream3.network.url
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities import com.lagradost.cloudstream3.utils.Qualities
import okio.Buffer
import org.jsoup.Jsoup import org.jsoup.Jsoup
// referer = https://vf-film.org, USERAGENT ALSO REQUIRED // referer = https://vf-film.org, USERAGENT ALSO REQUIRED
class VfFilm : MainAPI() { class VfFilmProvider : MainAPI() {
override val mainUrl: String override val mainUrl: String
get() = "https://vf-film.org" get() = "https://vf-film.org"
override val name: String override val name: String

View file

@ -3,7 +3,6 @@ package com.lagradost.cloudstream3.network
import com.lagradost.cloudstream3.USER_AGENT import com.lagradost.cloudstream3.USER_AGENT
import okhttp3.* import okhttp3.*
import okhttp3.Headers.Companion.toHeaders import okhttp3.Headers.Companion.toHeaders
import okio.Buffer
import java.net.URI import java.net.URI
import java.util.* import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -73,7 +72,12 @@ fun getCache(cacheTime: Int, cacheUnit: TimeUnit): CacheControl {
*/ */
fun getHeaders(headers: Map<String, String>, referer: String?, cookie: Map<String, String>): Headers { fun getHeaders(headers: Map<String, String>, referer: String?, cookie: Map<String, String>): Headers {
val refererMap = (referer ?: DEFAULT_REFERER)?.let { mapOf("referer" to it) } ?: mapOf() val refererMap = (referer ?: DEFAULT_REFERER)?.let { mapOf("referer" to it) } ?: mapOf()
return (DEFAULT_COOKIES + DEFAULT_HEADERS + cookie + headers + refererMap).toHeaders() val cookieHeaders = (DEFAULT_COOKIES + cookie)
val cookieMap = if(cookieHeaders.isNotEmpty()) mapOf("Cookie" to cookieHeaders.entries.joinToString(separator = "; ") {
"${it.key}=${it.value};"
}) else mapOf()
val tempHeaders = (DEFAULT_HEADERS + cookieMap + headers + refererMap)
return tempHeaders.toHeaders()
} }
fun get( fun get(
@ -92,6 +96,7 @@ fun get(
.followSslRedirects(allowRedirects) .followSslRedirects(allowRedirects)
.callTimeout(timeout, TimeUnit.SECONDS) .callTimeout(timeout, TimeUnit.SECONDS)
.build() .build()
println("cookie2: " + cookies)
val request = getRequestCreator(url, headers, referer, params, cookies, cacheTime, cacheUnit) val request = getRequestCreator(url, headers, referer, params, cookies, cacheTime, cacheUnit)
return client.newCall(request).execute() return client.newCall(request).execute()
} }