forked from aniyomiorg/aniyomi-extensions
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'aniyomiorg:master' into master
- Loading branch information
Showing
9 changed files
with
22 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ android { | |
|
||
dependencies { | ||
compileOnly(libs.bundles.common) | ||
implementation(project(":lib-playlist-utils")) | ||
} |
44 changes: 14 additions & 30 deletions
44
...dvid-extractor/src/main/java/eu/kanade/tachiyomi/lib/sendvidextractor/SendvidExtractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,29 @@ | ||
package eu.kanade.tachiyomi.lib.sendvidextractor | ||
|
||
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.Headers | ||
import okhttp3.HttpUrl.Companion.toHttpUrl | ||
import okhttp3.OkHttpClient | ||
|
||
class SendvidExtractor(private val client: OkHttpClient, private val headers: Headers) { | ||
private val playlistUtils by lazy { PlaylistUtils(client, headers) } | ||
|
||
fun videosFromUrl(url: String, prefix: String = ""): List<Video> { | ||
val videoList = mutableListOf<Video>() | ||
val document = client.newCall(GET(url)).execute().asJsoup() | ||
val document = client.newCall(GET(url, headers)).execute().use { it.asJsoup() } | ||
val masterUrl = document.selectFirst("source#video_source")?.attr("src") ?: return emptyList() | ||
|
||
val masterHeaders = headers.newBuilder() | ||
.add("Accept", "*/*") | ||
.add("Host", masterUrl.toHttpUrl().host) | ||
.add("Origin", "https://${url.toHttpUrl().host}") | ||
.add("Referer", "https://${url.toHttpUrl().host}/") | ||
.build() | ||
val masterPlaylist = client.newCall( | ||
GET(masterUrl, headers = masterHeaders), | ||
).execute().body.string() | ||
|
||
val masterBase = "https://${masterUrl.toHttpUrl().host}${masterUrl.toHttpUrl().encodedPath}" | ||
.substringBeforeLast("/") + "/" | ||
|
||
masterPlaylist.substringAfter("#EXT-X-STREAM-INF:").split("#EXT-X-STREAM-INF:") | ||
.forEach { | ||
val quality = "Sendvid:" + it.substringAfter("RESOLUTION=").substringAfter("x").substringBefore(",") + "p " | ||
val videoUrl = masterBase + it.substringAfter("\n").substringBefore("\n") | ||
|
||
val videoHeaders = headers.newBuilder() | ||
.add("Accept", "*/*") | ||
.add("Host", videoUrl.toHttpUrl().host) | ||
.add("Origin", "https://${url.toHttpUrl().host}") | ||
.add("Referer", "https://${url.toHttpUrl().host}/") | ||
.build() | ||
|
||
videoList.add(Video(videoUrl, prefix + quality, videoUrl, headers = videoHeaders)) | ||
} | ||
return videoList | ||
return if (masterUrl.contains(".m3u8")) { | ||
playlistUtils.extractFromHls(masterUrl, url, videoNameGen = { prefix + "Sendvid:$it" }) | ||
} else { | ||
val httpUrl = "https://${url.toHttpUrl()}" | ||
val newHeaders = headers.newBuilder() | ||
.set("Origin", httpUrl) | ||
.set("Referer", "$httpUrl/") | ||
.build() | ||
listOf(Video(masterUrl, prefix + "Sendvid:default", masterUrl, newHeaders)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters