Update google drive extractor (#1556)

* Update google drive extractor

* teehee
This commit is contained in:
Secozzi
2023-05-01 09:24:38 +02:00
committed by GitHub
parent 42ed33eec6
commit f25ae53fa2
9 changed files with 36 additions and 21 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Google Drive' extName = 'Google Drive'
pkgNameSuffix = 'all.googledrive' pkgNameSuffix = 'all.googledrive'
extClass = '.GoogleDrive' extClass = '.GoogleDrive'
extVersionCode = 2 extVersionCode = 3
libVersion = '13' libVersion = '13'
} }

View File

@ -38,7 +38,9 @@ import java.text.StringCharacterIterator
class GoogleDrive : ConfigurableAnimeSource, AnimeHttpSource() { class GoogleDrive : ConfigurableAnimeSource, AnimeHttpSource() {
override val name = "Google Drive (Experimental)" override val name = "Google Drive"
override val id = 4222017068256633289
override var baseUrl = "" override var baseUrl = ""

View File

@ -28,6 +28,9 @@ class GoogleDriveExtractor(private val client: OkHttpClient, private val headers
val noRedirectClient = OkHttpClient().newBuilder().followRedirects(false).build() val noRedirectClient = OkHttpClient().newBuilder().followRedirects(false).build()
val document = itemResponse.asJsoup() 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 url = document.selectFirst("form#download-form")?.attr("action") ?: return emptyList()
val redirectHeaders = headers.newBuilder() val redirectHeaders = headers.newBuilder()
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") .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( val response = noRedirectClient.newCall(
POST(url, headers = redirectHeaders, body = "".toRequestBody("application/x-www-form-urlencoded".toMediaType())), POST(url, headers = redirectHeaders, body = "".toRequestBody("application/x-www-form-urlencoded".toMediaType())),
).execute() ).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() val redirectedHeaders = headers.newBuilder()
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") .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( val redirectedResponseHeaders = noRedirectClient.newCall(
GET(redirected, headers = redirectedHeaders), GET(redirected, headers = redirectedHeaders),
).execute().headers ).execute().headers
val authCookie = redirectedResponseHeaders.first { val authCookie = redirectedResponseHeaders.firstOrNull {
it.first == "set-cookie" && it.second.startsWith("AUTH_") it.first == "set-cookie" && it.second.startsWith("AUTH_")
}.second.substringBefore(";") }?.second?.substringBefore(";") ?: return listOf(Video(url, videoName + itemSize, url))
val newRedirected = redirectedResponseHeaders["location"] ?: return listOf(Video(redirected, videoName, redirected)) val newRedirected = redirectedResponseHeaders["location"] ?: return listOf(Video(redirected, videoName + itemSize, redirected))
val googleDriveRedirectHeaders = headers.newBuilder() val googleDriveRedirectHeaders = headers.newBuilder()
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") .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() .build()
return listOf( return listOf(
Video(googleDriveRedirectUrl, videoName, googleDriveRedirectUrl, headers = videoHeaders), Video(googleDriveRedirectUrl, videoName + itemSize, googleDriveRedirectUrl, headers = videoHeaders),
) )
} }

View File

@ -6,7 +6,7 @@ ext {
extName = 'Kayoanime' extName = 'Kayoanime'
pkgNameSuffix = 'en.kayoanime' pkgNameSuffix = 'en.kayoanime'
extClass = '.Kayoanime' extClass = '.Kayoanime'
extVersionCode = 3 extVersionCode = 4
libVersion = '13' libVersion = '13'
} }

View File

@ -42,7 +42,9 @@ import java.util.Locale
class Kayoanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() { class Kayoanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
override val name = "Kayoanime (Experimental)" override val name = "Kayoanime"
override val id = 203922289858257167
override val baseUrl = "https://kayoanime.com" override val baseUrl = "https://kayoanime.com"

View File

@ -28,6 +28,9 @@ class GoogleDriveExtractor(private val client: OkHttpClient, private val headers
val noRedirectClient = OkHttpClient().newBuilder().followRedirects(false).build() val noRedirectClient = OkHttpClient().newBuilder().followRedirects(false).build()
val document = itemResponse.asJsoup() 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 url = document.selectFirst("form#download-form")?.attr("action") ?: return emptyList()
val redirectHeaders = headers.newBuilder() val redirectHeaders = headers.newBuilder()
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") .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( val response = noRedirectClient.newCall(
POST(url, headers = redirectHeaders, body = "".toRequestBody("application/x-www-form-urlencoded".toMediaType())), POST(url, headers = redirectHeaders, body = "".toRequestBody("application/x-www-form-urlencoded".toMediaType())),
).execute() ).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() val redirectedHeaders = headers.newBuilder()
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") .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( val redirectedResponseHeaders = noRedirectClient.newCall(
GET(redirected, headers = redirectedHeaders), GET(redirected, headers = redirectedHeaders),
).execute().headers ).execute().headers
val authCookie = redirectedResponseHeaders.first { val authCookie = redirectedResponseHeaders.firstOrNull {
it.first == "set-cookie" && it.second.startsWith("AUTH_") it.first == "set-cookie" && it.second.startsWith("AUTH_")
}.second.substringBefore(";") }?.second?.substringBefore(";") ?: return listOf(Video(url, videoName + itemSize, url))
val newRedirected = redirectedResponseHeaders["location"] ?: return listOf(Video(redirected, videoName, redirected)) val newRedirected = redirectedResponseHeaders["location"] ?: return listOf(Video(redirected, videoName + itemSize, redirected))
val googleDriveRedirectHeaders = headers.newBuilder() val googleDriveRedirectHeaders = headers.newBuilder()
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") .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() .build()
return listOf( return listOf(
Video(googleDriveRedirectUrl, videoName, googleDriveRedirectUrl, headers = videoHeaders), Video(googleDriveRedirectUrl, videoName + itemSize, googleDriveRedirectUrl, headers = videoHeaders),
) )
} }

View File

@ -6,7 +6,7 @@ ext {
extName = 'Ripcrabbyanime' extName = 'Ripcrabbyanime'
pkgNameSuffix = 'en.ripcrabbyanime' pkgNameSuffix = 'en.ripcrabbyanime'
extClass = '.Ripcrabbyanime' extClass = '.Ripcrabbyanime'
extVersionCode = 1 extVersionCode = 2
libVersion = '13' libVersion = '13'
} }

View File

@ -38,7 +38,9 @@ import java.text.StringCharacterIterator
class Ripcrabbyanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() { class Ripcrabbyanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
override val name = "Ripcrabbyanime (Experimental)" override val name = "Ripcrabbyanime"
override val id = 623659475482363776
override val baseUrl = "https://ripcrabbyanime.in" override val baseUrl = "https://ripcrabbyanime.in"

View File

@ -28,6 +28,9 @@ class GoogleDriveExtractor(private val client: OkHttpClient, private val headers
val noRedirectClient = OkHttpClient().newBuilder().followRedirects(false).build() val noRedirectClient = OkHttpClient().newBuilder().followRedirects(false).build()
val document = itemResponse.asJsoup() 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 url = document.selectFirst("form#download-form")?.attr("action") ?: return emptyList()
val redirectHeaders = headers.newBuilder() val redirectHeaders = headers.newBuilder()
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") .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( val response = noRedirectClient.newCall(
POST(url, headers = redirectHeaders, body = "".toRequestBody("application/x-www-form-urlencoded".toMediaType())), POST(url, headers = redirectHeaders, body = "".toRequestBody("application/x-www-form-urlencoded".toMediaType())),
).execute() ).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() val redirectedHeaders = headers.newBuilder()
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") .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( val redirectedResponseHeaders = noRedirectClient.newCall(
GET(redirected, headers = redirectedHeaders), GET(redirected, headers = redirectedHeaders),
).execute().headers ).execute().headers
val authCookie = redirectedResponseHeaders.first { val authCookie = redirectedResponseHeaders.firstOrNull {
it.first == "set-cookie" && it.second.startsWith("AUTH_") it.first == "set-cookie" && it.second.startsWith("AUTH_")
}.second.substringBefore(";") }?.second?.substringBefore(";") ?: return listOf(Video(url, videoName + itemSize, url))
val newRedirected = redirectedResponseHeaders["location"] ?: return listOf(Video(redirected, videoName, redirected)) val newRedirected = redirectedResponseHeaders["location"] ?: return listOf(Video(redirected, videoName + itemSize, redirected))
val googleDriveRedirectHeaders = headers.newBuilder() val googleDriveRedirectHeaders = headers.newBuilder()
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") .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() .build()
return listOf( return listOf(
Video(googleDriveRedirectUrl, videoName, googleDriveRedirectUrl, headers = videoHeaders), Video(googleDriveRedirectUrl, videoName + itemSize, googleDriveRedirectUrl, headers = videoHeaders),
) )
} }