fix(en/Wcofun): Fix video extractor AGAIN (#2068)

This commit is contained in:
Claudemirovsky
2023-08-23 05:59:25 -03:00
committed by GitHub
parent 4057f5b4e5
commit 76b8127730
2 changed files with 12 additions and 7 deletions

View File

@ -8,7 +8,7 @@ ext {
extName = 'Wcofun' extName = 'Wcofun'
pkgNameSuffix = 'en.wcofun' pkgNameSuffix = 'en.wcofun'
extClass = '.Wcofun' extClass = '.Wcofun'
extVersionCode = 10 extVersionCode = 11
libVersion = '13' libVersion = '13'
} }

View File

@ -40,6 +40,10 @@ class Wcofun : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
override val client: OkHttpClient = network.cloudflareClient override val client: OkHttpClient = network.cloudflareClient
override fun headersBuilder() = super.headersBuilder()
.add("Referer", "$baseUrl/")
.add("Origin", baseUrl)
private val json: Json by injectLazy() private val json: Json by injectLazy()
private val preferences by lazy { private val preferences by lazy {
@ -113,15 +117,15 @@ class Wcofun : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
data class VideoResponseDto( data class VideoResponseDto(
val server: String, val server: String,
@SerialName("enc") @SerialName("enc")
val sd: String, val sd: String?,
val hd: String, val hd: String?,
val fhd: String, val fhd: String?,
) { ) {
val videos by lazy { val videos by lazy {
listOfNotNull( listOfNotNull(
sd.takeIf(String::isNotBlank)?.let { Pair("SD", it) }, sd?.takeIf(String::isNotBlank)?.let { Pair("SD", it) },
hd.takeIf(String::isNotBlank)?.let { Pair("HD", it) }, hd?.takeIf(String::isNotBlank)?.let { Pair("HD", it) },
fhd.takeIf(String::isNotBlank)?.let { Pair("FHD", it) }, fhd?.takeIf(String::isNotBlank)?.let { Pair("FHD", it) },
).map { ).map {
val videoUrl = "$server/getvid?evid=" + it.second val videoUrl = "$server/getvid?evid=" + it.second
Video(videoUrl, it.first, videoUrl) Video(videoUrl, it.first, videoUrl)
@ -143,6 +147,7 @@ class Wcofun : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val requestHeaders = headersBuilder() val requestHeaders = headersBuilder()
.add("x-requested-with", "XMLHttpRequest") .add("x-requested-with", "XMLHttpRequest")
.set("Referer", requestUrl) .set("Referer", requestUrl)
.set("Origin", iframeDomain)
.build() .build()
val videoData = client.newCall(GET(requestUrl, requestHeaders)).execute() val videoData = client.newCall(GET(requestUrl, requestHeaders)).execute()