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,
|
quality: String? = null,
|
||||||
redirect: Boolean = true,
|
redirect: Boolean = true,
|
||||||
): Video? {
|
): Video? {
|
||||||
val newQuality = quality ?: "Doodstream" + if (redirect) " mirror" else ""
|
val newQuality = quality ?: ("Doodstream" + if (redirect) " mirror" else "")
|
||||||
|
|
||||||
return runCatching {
|
return runCatching {
|
||||||
val response = client.newCall(GET(url)).execute()
|
val response = client.newCall(GET(url)).execute()
|
||||||
val newUrl = if (redirect) response.request.url.toString() else url
|
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()
|
val content = response.body.string()
|
||||||
if (!content.contains("'/pass_md5/")) return null
|
if (!content.contains("'/pass_md5/")) return null
|
||||||
val md5 = content.substringAfter("'/pass_md5/").substringBefore("',")
|
val md5 = content.substringAfter("'/pass_md5/").substringBefore("',")
|
||||||
@ -27,12 +27,12 @@ class DoodExtractor(private val client: OkHttpClient) {
|
|||||||
val expiry = System.currentTimeMillis()
|
val expiry = System.currentTimeMillis()
|
||||||
val videoUrlStart = client.newCall(
|
val videoUrlStart = client.newCall(
|
||||||
GET(
|
GET(
|
||||||
"https://dood.$doodTld/pass_md5/$md5",
|
"https://$doodHost/pass_md5/$md5",
|
||||||
Headers.headersOf("referer", newUrl),
|
Headers.headersOf("referer", newUrl),
|
||||||
),
|
),
|
||||||
).execute().body.string()
|
).execute().body.string()
|
||||||
val videoUrl = "$videoUrlStart$randomString?token=$token&expiry=$expiry"
|
val videoUrl = "$videoUrlStart$randomString?token=$token&expiry=$expiry"
|
||||||
Video(newUrl, newQuality, videoUrl, headers = doodHeaders(doodTld))
|
Video(newUrl, newQuality, videoUrl, headers = doodHeaders(doodHost))
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,8 +52,8 @@ class DoodExtractor(private val client: OkHttpClient) {
|
|||||||
.joinToString("")
|
.joinToString("")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doodHeaders(tld: String) = Headers.Builder().apply {
|
private fun doodHeaders(host: String) = Headers.Builder().apply {
|
||||||
add("User-Agent", "Aniyomi")
|
add("User-Agent", "Aniyomi")
|
||||||
add("Referer", "https://dood.$tld/")
|
add("Referer", "https://$host/")
|
||||||
}.build()
|
}.build()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user