Skip to content

Commit

Permalink
Merge branch 'aniyomiorg:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Dark25 authored Jan 21, 2024
2 parents 1487977 + ed55a9a commit b33a98a
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 37 deletions.
1 change: 1 addition & 0 deletions lib/sendvid-extractor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ android {

dependencies {
compileOnly(libs.bundles.common)
implementation(project(":lib-playlist-utils"))
}
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))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AnimeStreamGenerator : ThemeSourceGenerator {
SingleLang("AnimeKhor", "https://animekhor.xyz", "en", isNsfw = false, overrideVersionCode = 3),
SingleLang("Animenosub", "https://animenosub.com", "en", isNsfw = true, overrideVersionCode = 4),
SingleLang("AnimeXin", "https://animexin.vip", "all", isNsfw = false, overrideVersionCode = 8),
SingleLang("AnimeYT.es", "https://animeyt.es", "es", isNsfw = false, className = "AnimeYTES", pkgName = "animeytes", overrideVersionCode = 1),
SingleLang("AnimeYT.es", "https://animeyt.es", "es", isNsfw = false, className = "AnimeYTES", pkgName = "animeytes", overrideVersionCode = 2),
SingleLang("Tiodonghua.com", "https://anime.tiodonghua.com", "es", isNsfw = false, className = "Tiodonghua", pkgName = "tiodonghua", overrideVersionCode = 1),
SingleLang("AsyaAnimeleri", "https://asyaanimeleri.com", "tr", isNsfw = false, overrideVersionCode = 3),
SingleLang("ChineseAnime", "https://chineseanime.top", "all", isNsfw = false, overrideVersionCode = 4),
Expand Down
2 changes: 1 addition & 1 deletion src/fr/animesama/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'Anime-Sama'
extClass = '.AnimeSama'
extVersionCode = 7
extVersionCode = 8
containsNsfw = false
}

Expand Down
2 changes: 1 addition & 1 deletion src/fr/franime/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'FrAnime'
extClass = '.FrAnime'
extVersionCode = 10
extVersionCode = 11
containsNsfw = true
}
apply from: "$rootDir/common.gradle"
Expand Down
2 changes: 1 addition & 1 deletion src/fr/otakufr/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'OtakuFR'
extClass = '.OtakuFR'
extVersionCode = 6
extVersionCode = 7
}

apply from: "$rootDir/common.gradle"
Expand Down
2 changes: 1 addition & 1 deletion src/tr/anizm/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'Anizm'
extClass = '.Anizm'
extVersionCode = 12
extVersionCode = 13
}

apply from: "$rootDir/common.gradle"
Expand Down
2 changes: 1 addition & 1 deletion src/tr/tranimeizle/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'TR Anime Izle'
extClass = '.TRAnimeIzle'
extVersionCode = 12
extVersionCode = 13
}

apply from: "$rootDir/common.gradle"
Expand Down
2 changes: 1 addition & 1 deletion src/tr/turkanime/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'Türk Anime TV'
extClass = '.TurkAnime'
extVersionCode = 19
extVersionCode = 20
}

apply from: "$rootDir/common.gradle"
Expand Down

0 comments on commit b33a98a

Please sign in to comment.