Update google drive extractor (#1556)
* Update google drive extractor * teehee
This commit is contained in:
@ -6,7 +6,7 @@ ext {
|
||||
extName = 'Google Drive'
|
||||
pkgNameSuffix = 'all.googledrive'
|
||||
extClass = '.GoogleDrive'
|
||||
extVersionCode = 2
|
||||
extVersionCode = 3
|
||||
libVersion = '13'
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,9 @@ import java.text.StringCharacterIterator
|
||||
|
||||
class GoogleDrive : ConfigurableAnimeSource, AnimeHttpSource() {
|
||||
|
||||
override val name = "Google Drive (Experimental)"
|
||||
override val name = "Google Drive"
|
||||
|
||||
override val id = 4222017068256633289
|
||||
|
||||
override var baseUrl = ""
|
||||
|
||||
|
@ -28,6 +28,9 @@ class GoogleDriveExtractor(private val client: OkHttpClient, private val headers
|
||||
val noRedirectClient = OkHttpClient().newBuilder().followRedirects(false).build()
|
||||
val document = itemResponse.asJsoup()
|
||||
|
||||
val itemSize = document.selectFirst("span.uc-name-size")?.let {
|
||||
" ${it.ownText().trim()} "
|
||||
} ?: ""
|
||||
val url = document.selectFirst("form#download-form")?.attr("action") ?: return emptyList()
|
||||
val redirectHeaders = headers.newBuilder()
|
||||
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8")
|
||||
@ -43,7 +46,7 @@ class GoogleDriveExtractor(private val client: OkHttpClient, private val headers
|
||||
val response = noRedirectClient.newCall(
|
||||
POST(url, headers = redirectHeaders, body = "".toRequestBody("application/x-www-form-urlencoded".toMediaType())),
|
||||
).execute()
|
||||
val redirected = response.headers["location"] ?: return listOf(Video(url, videoName, url))
|
||||
val redirected = response.headers["location"] ?: return listOf(Video(url, videoName + itemSize, url))
|
||||
|
||||
val redirectedHeaders = headers.newBuilder()
|
||||
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8")
|
||||
@ -55,10 +58,10 @@ class GoogleDriveExtractor(private val client: OkHttpClient, private val headers
|
||||
val redirectedResponseHeaders = noRedirectClient.newCall(
|
||||
GET(redirected, headers = redirectedHeaders),
|
||||
).execute().headers
|
||||
val authCookie = redirectedResponseHeaders.first {
|
||||
val authCookie = redirectedResponseHeaders.firstOrNull {
|
||||
it.first == "set-cookie" && it.second.startsWith("AUTH_")
|
||||
}.second.substringBefore(";")
|
||||
val newRedirected = redirectedResponseHeaders["location"] ?: return listOf(Video(redirected, videoName, redirected))
|
||||
}?.second?.substringBefore(";") ?: return listOf(Video(url, videoName + itemSize, url))
|
||||
val newRedirected = redirectedResponseHeaders["location"] ?: return listOf(Video(redirected, videoName + itemSize, redirected))
|
||||
|
||||
val googleDriveRedirectHeaders = headers.newBuilder()
|
||||
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8")
|
||||
@ -80,7 +83,7 @@ class GoogleDriveExtractor(private val client: OkHttpClient, private val headers
|
||||
.build()
|
||||
|
||||
return listOf(
|
||||
Video(googleDriveRedirectUrl, videoName, googleDriveRedirectUrl, headers = videoHeaders),
|
||||
Video(googleDriveRedirectUrl, videoName + itemSize, googleDriveRedirectUrl, headers = videoHeaders),
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user