Aniflix Streamlare set resolution in options (#634)
* Aniflix Streamlare set resolution in options trying to implement it directly into the stream * Update Aniflix.kt * Update Aniflix.kt * Update StreamlareExtractor.kt * Update StreamlareExtractor.kt
This commit is contained in:
@ -6,7 +6,7 @@ ext {
|
||||
extName = 'Aniflix'
|
||||
pkgNameSuffix = 'de.aniflix'
|
||||
extClass = '.Aniflix'
|
||||
extVersionCode = 11
|
||||
extVersionCode = 12
|
||||
libVersion = '12'
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ class Aniflix : ConfigurableAnimeSource, AnimeHttpSource() {
|
||||
}
|
||||
}
|
||||
link.contains("https://streamlare") && hosterSelection?.contains("slare") == true -> {
|
||||
val video = StreamlareExtractor(client).videoFromUrl(link, quality)
|
||||
val video = StreamlareExtractor(client).videoFromUrl(link, stream, preferences)
|
||||
if (video != null) {
|
||||
videoList.add(video)
|
||||
}
|
||||
@ -302,8 +302,24 @@ 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)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package eu.kanade.tachiyomi.animeextension.de.aniflix.extractors
|
||||
|
||||
import android.content.SharedPreferences
|
||||
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
|
||||
@ -9,7 +11,7 @@ import okhttp3.RequestBody.Companion.toRequestBody
|
||||
|
||||
class StreamlareExtractor(private val client: OkHttpClient) {
|
||||
|
||||
fun videoFromUrl(url: String, quality: String): Video? {
|
||||
fun videoFromUrl(url: String, stream: Stream, preferences: SharedPreferences): Video? {
|
||||
val id = url.split("/").last()
|
||||
val referer = client.newCall(
|
||||
POST(
|
||||
@ -19,8 +21,29 @@ class StreamlareExtractor(private val client: OkHttpClient) {
|
||||
)
|
||||
)
|
||||
.execute().asJsoup().toString()
|
||||
val token = referer.substringAfter("https:\\/\\/larecontent.com\\/video?token=")
|
||||
.substringBefore("\",")
|
||||
|
||||
val resPreference = preferences.getString("preferred_res", "1080")
|
||||
val token =
|
||||
when {
|
||||
referer.contains("$resPreference" + "p") && resPreference?.contains("$resPreference") == true ->
|
||||
referer.substringAfter("\"label\":\"$resPreference" + "p\",\"file\":\"https:\\/\\/larecontent.com\\/video?token=")
|
||||
.substringBefore("\",")
|
||||
|
||||
else ->
|
||||
referer.substringAfter("https:\\/\\/larecontent.com\\/video?token=")
|
||||
.substringBefore("\",")
|
||||
}
|
||||
|
||||
val quality =
|
||||
when {
|
||||
referer.contains("$resPreference" + "p") && resPreference?.contains("$resPreference") == true -> {
|
||||
"${stream.hoster?.name}, $resPreference" + "p, ${stream.lang}"
|
||||
}
|
||||
else -> {
|
||||
"${stream.hoster?.name} Unknown, ${stream.lang}"
|
||||
}
|
||||
}
|
||||
|
||||
val videoUrl = "https://larecontent.com/video?token=$token"
|
||||
return Video(url, quality, videoUrl, null)
|
||||
}
|
||||
|
Reference in New Issue
Block a user