Merge branch 'Kohi-den:main' into Arkai1-patch-1
7
lib/amazon-extractor/build.gradle.kts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
plugins {
|
||||||
|
id("lib-android")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(project(":lib:playlist-utils"))
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package eu.kanade.tachiyomi.lib.amazonextractor
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
|
import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils
|
||||||
|
import eu.kanade.tachiyomi.network.GET
|
||||||
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
|
||||||
|
class AmazonExtractor(private val client: OkHttpClient) {
|
||||||
|
|
||||||
|
private val playlistUtils by lazy { PlaylistUtils(client) }
|
||||||
|
|
||||||
|
fun videosFromUrl(url: String, prefix: String = ""): List<Video> {
|
||||||
|
if (url.contains("disable", true)) return emptyList()
|
||||||
|
|
||||||
|
val document = client.newCall(GET(url)).execute().asJsoup()
|
||||||
|
|
||||||
|
val shareIdScript = document.select("script:containsData(var shareId)").firstOrNull()?.data()
|
||||||
|
if (shareIdScript.isNullOrBlank()) return emptyList()
|
||||||
|
|
||||||
|
val shareId = shareIdScript.substringAfter("shareId = \"").substringBefore("\"")
|
||||||
|
val amazonApiJsonUrl = "https://www.amazon.com/drive/v1/shares/$shareId?resourceVersion=V2&ContentType=JSON&asset=ALL"
|
||||||
|
|
||||||
|
val amazonApiJson = client.newCall(GET(amazonApiJsonUrl)).execute().asJsoup()
|
||||||
|
|
||||||
|
val epId = amazonApiJson.toString().substringAfter("\"id\":\"").substringBefore("\"")
|
||||||
|
val amazonApiUrl = "https://www.amazon.com/drive/v1/nodes/$epId/children?resourceVersion=V2&ContentType=JSON&limit=200&sort=%5B%22kind+DESC%22%2C+%22modifiedDate+DESC%22%5D&asset=ALL&tempLink=true&shareId=$shareId"
|
||||||
|
|
||||||
|
val amazonApi = client.newCall(GET(amazonApiUrl)).execute().asJsoup()
|
||||||
|
|
||||||
|
val videoUrl = amazonApi.toString().substringAfter("\"FOLDER\":").substringAfter("tempLink\":\"").substringBefore("\"")
|
||||||
|
|
||||||
|
val serverName = if (videoUrl.contains("&ext=es")) "AmazonES" else "Amazon"
|
||||||
|
|
||||||
|
return if (videoUrl.contains(".m3u8")) {
|
||||||
|
playlistUtils.extractFromHls(videoUrl, videoNameGen = { "${prefix}$serverName:$it" })
|
||||||
|
} else {
|
||||||
|
listOf(Video(videoUrl, "${prefix}$serverName", videoUrl))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Before Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 207 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 8.2 KiB |
Before Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 842 B |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 448 B |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 5 KiB |
Before Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 842 B |
Before Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 448 B |
Before Width: | Height: | Size: 5 KiB |
Before Width: | Height: | Size: 5 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 4.1 KiB |