fix(lib/dood): Make extractor accept all dood hosts (#1921)
This commit is contained in:
@ -12,13 +12,13 @@ class DoodExtractor(private val client: OkHttpClient) {
|
||||
quality: String? = null,
|
||||
redirect: Boolean = true,
|
||||
): Video? {
|
||||
val newQuality = quality ?: "Doodstream" + if (redirect) " mirror" else ""
|
||||
val newQuality = quality ?: ("Doodstream" + if (redirect) " mirror" else "")
|
||||
|
||||
return runCatching {
|
||||
val response = client.newCall(GET(url)).execute()
|
||||
val newUrl = if (redirect) response.request.url.toString() else url
|
||||
|
||||
val doodTld = newUrl.substringAfter("https://dood.").substringBefore("/")
|
||||
val doodHost = Regex("https://(.*?)/").find(newUrl)!!.groupValues[1]
|
||||
val content = response.body.string()
|
||||
if (!content.contains("'/pass_md5/")) return null
|
||||
val md5 = content.substringAfter("'/pass_md5/").substringBefore("',")
|
||||
@ -27,12 +27,12 @@ class DoodExtractor(private val client: OkHttpClient) {
|
||||
val expiry = System.currentTimeMillis()
|
||||
val videoUrlStart = client.newCall(
|
||||
GET(
|
||||
"https://dood.$doodTld/pass_md5/$md5",
|
||||
"https://$doodHost/pass_md5/$md5",
|
||||
Headers.headersOf("referer", newUrl),
|
||||
),
|
||||
).execute().body.string()
|
||||
val videoUrl = "$videoUrlStart$randomString?token=$token&expiry=$expiry"
|
||||
Video(newUrl, newQuality, videoUrl, headers = doodHeaders(doodTld))
|
||||
Video(newUrl, newQuality, videoUrl, headers = doodHeaders(doodHost))
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
@ -52,8 +52,8 @@ class DoodExtractor(private val client: OkHttpClient) {
|
||||
.joinToString("")
|
||||
}
|
||||
|
||||
private fun doodHeaders(tld: String) = Headers.Builder().apply {
|
||||
private fun doodHeaders(host: String) = Headers.Builder().apply {
|
||||
add("User-Agent", "Aniyomi")
|
||||
add("Referer", "https://dood.$tld/")
|
||||
add("Referer", "https://$host/")
|
||||
}.build()
|
||||
}
|
||||
|
Reference in New Issue
Block a user