animepahe: add setting for alternative links
This commit is contained in:
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'AnimePahe'
|
extName = 'AnimePahe'
|
||||||
pkgNameSuffix = 'en.animepahe'
|
pkgNameSuffix = 'en.animepahe'
|
||||||
extClass = '.AnimePahe'
|
extClass = '.AnimePahe'
|
||||||
extVersionCode = 8
|
extVersionCode = 9
|
||||||
libVersion = '12'
|
libVersion = '12'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import android.app.Application
|
|||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
import com.google.gson.JsonElement
|
import com.google.gson.JsonElement
|
||||||
import com.google.gson.JsonNull
|
import com.google.gson.JsonNull
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
@ -217,16 +218,26 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
val quality = item.asJsonObject.keySet().first()
|
val quality = item.asJsonObject.keySet().first()
|
||||||
val adflyLink = item.asJsonObject.get(quality)
|
val adflyLink = item.asJsonObject.get(quality)
|
||||||
.asJsonObject.get("kwik_adfly").asString
|
.asJsonObject.get("kwik_adfly").asString
|
||||||
|
val kwikLink = item.asJsonObject.get(quality)
|
||||||
|
.asJsonObject.get("kwik").asString
|
||||||
val audio = item.asJsonObject.get(quality).asJsonObject.get("audio")
|
val audio = item.asJsonObject.get(quality).asJsonObject.get("audio")
|
||||||
val qualityString = if (audio is JsonNull) "${quality}p" else "${quality}p (" + audio.asString + " audio)"
|
val qualityString = if (audio is JsonNull) "${quality}p" else "${quality}p (" + audio.asString + " audio)"
|
||||||
videos.add(getVideo(adflyLink, qualityString))
|
videos.add(getVideo(adflyLink, kwikLink, qualityString))
|
||||||
}
|
}
|
||||||
return videos
|
return videos
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getVideo(adflyUrl: String, quality: String): Video {
|
private fun getVideo(adflyUrl: String, kwikUrl: String, quality: String): Video {
|
||||||
val videoUrl = KwikExtractor(client).getStreamUrlFromKwik(adflyUrl)
|
return if (preferences.getBoolean("preferred_link_type", false)) {
|
||||||
return Video(videoUrl, quality, videoUrl, null)
|
val videoUrl = KwikExtractor(client).getHlsStreamUrl(kwikUrl, referer = baseUrl)
|
||||||
|
Video(
|
||||||
|
videoUrl, quality, videoUrl, null,
|
||||||
|
Headers.headersOf("referer", "https://kwik.cx")
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
val videoUrl = KwikExtractor(client).getStreamUrlFromKwik(adflyUrl)
|
||||||
|
Video(videoUrl, quality, videoUrl, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun List<Video>.sort(): List<Video> {
|
override fun List<Video>.sort(): List<Video> {
|
||||||
@ -301,8 +312,21 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
|
|||||||
preferences.edit().putString(key, entry).commit()
|
preferences.edit().putString(key, entry).commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val linkPref = SwitchPreferenceCompat(screen.context).apply {
|
||||||
|
key = "preferred_link_type"
|
||||||
|
title = "Use HLS links"
|
||||||
|
summary = """Enable this if you are having Cloudflare issues.
|
||||||
|
|Note that this will break the ability to seek inside of the video unless the episode is downloaded in advance.""".trimMargin()
|
||||||
|
setDefaultValue(false)
|
||||||
|
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
val new = newValue as Boolean
|
||||||
|
preferences.edit().putBoolean(key, new).commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
screen.addPreference(videoQualityPref)
|
screen.addPreference(videoQualityPref)
|
||||||
screen.addPreference(domainPref)
|
screen.addPreference(domainPref)
|
||||||
screen.addPreference(subPref)
|
screen.addPreference(subPref)
|
||||||
|
screen.addPreference(linkPref)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
package eu.kanade.tachiyomi.animeextension.en.animepahe
|
package eu.kanade.tachiyomi.animeextension.en.animepahe
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.POST
|
import eu.kanade.tachiyomi.network.POST
|
||||||
import okhttp3.FormBody
|
import okhttp3.FormBody
|
||||||
@ -113,6 +114,19 @@ class KwikExtractor(private val client: OkHttpClient) {
|
|||||||
return newList
|
return newList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getHlsStreamUrl(kwikUrl: String, referer: String): String {
|
||||||
|
val eContent = client.newCall(GET(kwikUrl, Headers.headersOf("referer", referer)))
|
||||||
|
.execute().body!!.string()
|
||||||
|
val substring = eContent.substringAfterLast("m3u8|uwu|").substringBefore("'")
|
||||||
|
val urlParts = substring.split("|").reversed()
|
||||||
|
assert(urlParts.lastIndex == 8)
|
||||||
|
val url = urlParts[0] + "://" + urlParts[1] + "-" + urlParts[2] + "." + urlParts[3] + "." +
|
||||||
|
urlParts[4] + "." + urlParts[5] + "/" + urlParts[6] + "/" + urlParts[7] + "/" +
|
||||||
|
urlParts[8] + "/uwu.m3u8"
|
||||||
|
Log.i("bruh", url)
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
|
||||||
fun getStreamUrlFromKwik(adflyUri: String): String {
|
fun getStreamUrlFromKwik(adflyUri: String): String {
|
||||||
val fContent =
|
val fContent =
|
||||||
client.newCall(GET(bypassAdfly(adflyUri), Headers.headersOf("referer", "https://kwik.cx/"))).execute()
|
client.newCall(GET(bypassAdfly(adflyUri), Headers.headersOf("referer", "https://kwik.cx/"))).execute()
|
||||||
|
Reference in New Issue
Block a user