Anflix Streamlare Update (#639)

This commit is contained in:
LuftVerbot
2022-07-09 11:53:20 +02:00
committed by GitHub
parent 08b337ae04
commit 763b27ffb0
3 changed files with 14 additions and 66 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Aniflix'
pkgNameSuffix = 'de.aniflix'
extClass = '.Aniflix'
extVersionCode = 13
extVersionCode = 14
libVersion = '12'
}

View File

@ -216,11 +216,7 @@ class Aniflix : ConfigurableAnimeSource, AnimeHttpSource() {
}
}
link.contains("https://streamlare") && hosterSelection?.contains("slare") == true -> {
val resPreference = preferences.getString("preferred_res", "1080")
val video = StreamlareExtractor(client).videoFromUrl(link, stream, resPreference)
if (video != null) {
videoList.add(video)
}
videoList.addAll(StreamlareExtractor(client).videosFromUrl(link, stream))
}
}
}
@ -303,24 +299,8 @@ class Aniflix : ConfigurableAnimeSource, AnimeHttpSource() {
preferences.edit().putStringSet(key, newValue as Set<String>).commit()
}
}
val resPref = ListPreference(screen.context).apply {
key = "preferred_res"
title = "Streamlare Standard-Auflösung"
entries = arrayOf("1080p", "720p", "480p", "360p")
entryValues = arrayOf("1080", "720", "480", "360")
setDefaultValue("1080")
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String
val index = findIndexOfValue(selected)
val entry = entryValues[index] as String
preferences.edit().putString(key, entry).commit()
}
}
screen.addPreference(subPref)
screen.addPreference(hosterPref)
screen.addPreference(subSelection)
screen.addPreference(resPref)
}
}

View File

@ -3,63 +3,31 @@ package eu.kanade.tachiyomi.animeextension.de.aniflix.extractors
import eu.kanade.tachiyomi.animeextension.de.aniflix.dto.Stream
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.RequestBody.Companion.toRequestBody
class StreamlareExtractor(private val client: OkHttpClient) {
fun videoFromUrl(url: String, stream: Stream, resPreference: String?): Video? {
fun videosFromUrl(url: String, stream: Stream): List<Video> {
val id = url.split("/").last()
val referer = client.newCall(
val videoList = mutableListOf<Video>()
val playlist = client.newCall(
POST(
"https://slwatch.co/api/video/stream/get",
body = "{\"id\":\"$id\"}"
.toRequestBody("application/json".toMediaType())
)
)
.execute().asJsoup().toString()
.execute().body!!.string()
val token =
when {
referer.contains("1080p") && resPreference?.contains("1080") == true ->
referer.substringAfter("\"label\":\"1080p\",\"file\":\"https:\\/\\/larecontent.com\\/video?token=")
.substringBefore("\",")
referer.contains("720p") && resPreference?.contains("720") == true ->
referer.substringAfter("\"label\":\"720p\",\"file\":\"https:\\/\\/larecontent.com\\/video?token=")
.substringBefore("\",")
referer.contains("480p") && resPreference?.contains("480") == true ->
referer.substringAfter("\"label\":\"480p\",\"file\":\"https:\\/\\/larecontent.com\\/video?token=")
.substringBefore("\",")
referer.contains("360p") && resPreference?.contains("360") == true ->
referer.substringAfter("\"label\":\"360p\",\"file\":\"https:\\/\\/larecontent.com\\/video?token=")
.substringBefore("\",")
else ->
referer.substringAfter("https:\\/\\/larecontent.com\\/video?token=")
.substringBefore("\",")
}
val quality =
when {
referer.contains("1080p") && resPreference?.contains("1080") == true -> {
"${stream.hoster?.name}, 1080p, ${stream.lang}"
}
referer.contains("720p") && resPreference?.contains("720") == true -> {
"${stream.hoster?.name}, 720p, ${stream.lang}"
}
referer.contains("480p") && resPreference?.contains("480") == true -> {
"${stream.hoster?.name}, 480p, ${stream.lang}"
}
referer.contains("360p") && resPreference?.contains("360") == true -> {
"${stream.hoster?.name}, 360p, ${stream.lang}"
}
else ->
"${stream.hoster?.name}, Unknown, ${stream.lang}"
}
val videoUrl = "https://larecontent.com/video?token=$token"
return Video(url, quality, videoUrl, null)
playlist.substringAfter("\"label\":\"").split("\"label\":\"").forEach {
val quality = it.substringAfter("\"label\":\"").substringBefore("\",") + ", ${stream.lang}"
val videoUrl =
"https://larecontent.com/video?token=" + it.substringAfter("\"file\":\"https:\\/\\/larecontent.com\\/video?token=")
.substringBefore("\",")
videoList.addAll((listOf(Video(videoUrl, quality, videoUrl, null))))
}
return videoList
}
}