animeflv: fix getting links
This commit is contained in:
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'AnimeFLV'
|
extName = 'AnimeFLV'
|
||||||
pkgNameSuffix = 'es.animeflv'
|
pkgNameSuffix = 'es.animeflv'
|
||||||
extClass = '.AnimeFlv'
|
extClass = '.AnimeFlv'
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
libVersion = '12'
|
libVersion = '12'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
package eu.kanade.tachiyomi.animeextension.es.animeflv
|
package eu.kanade.tachiyomi.animeextension.es.animeflv
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.preference.ListPreference
|
||||||
|
import androidx.preference.PreferenceScreen
|
||||||
import com.google.gson.JsonParser
|
import com.google.gson.JsonParser
|
||||||
|
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||||
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
||||||
@ -13,9 +19,11 @@ import okhttp3.Request
|
|||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
|
||||||
class AnimeFlv : ParsedAnimeHttpSource() {
|
class AnimeFlv : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
override val name = "AnimeFLV"
|
override val name = "AnimeFLV"
|
||||||
|
|
||||||
@ -27,6 +35,10 @@ class AnimeFlv : ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
override val client: OkHttpClient = network.cloudflareClient
|
override val client: OkHttpClient = network.cloudflareClient
|
||||||
|
|
||||||
|
private val preferences: SharedPreferences by lazy {
|
||||||
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
|
}
|
||||||
|
|
||||||
override fun popularAnimeSelector(): String = "div.Container ul.ListAnimes li article"
|
override fun popularAnimeSelector(): String = "div.Container ul.ListAnimes li article"
|
||||||
|
|
||||||
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/browse?page=$page")
|
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/browse?page=$page")
|
||||||
@ -88,8 +100,10 @@ class AnimeFlv : ParsedAnimeHttpSource() {
|
|||||||
for (server in sub.asJsonArray) {
|
for (server in sub.asJsonArray) {
|
||||||
val url = server.asJsonObject.get("code").asString.replace("\\/", "/")
|
val url = server.asJsonObject.get("code").asString.replace("\\/", "/")
|
||||||
val quality = server.asJsonObject.get("title").asString
|
val quality = server.asJsonObject.get("title").asString
|
||||||
val video = Video(url, quality, null, null)
|
if (quality == "Okru") {
|
||||||
if (quality == "GoCDN") videoList.add(video)
|
val videos = getOkruVideos(url)
|
||||||
|
videoList += videos
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,21 +113,43 @@ class AnimeFlv : ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
override fun videoListSelector() = throw Exception("not used")
|
override fun videoListSelector() = throw Exception("not used")
|
||||||
|
|
||||||
|
override fun videoUrlParse(document: Document) = throw Exception("not used")
|
||||||
|
|
||||||
override fun videoFromElement(element: Element) = throw Exception("not used")
|
override fun videoFromElement(element: Element) = throw Exception("not used")
|
||||||
|
|
||||||
override fun videoUrlRequest(video: Video): Request {
|
private fun getOkruVideos(url: String): List<Video> {
|
||||||
if (video.url.contains("https://streamium.xyz/gocdn.html")) {
|
val document = client.newCall(GET(url)).execute().asJsoup()
|
||||||
val newUrl = video.url.replace("gocdn.html#", "gocdn.php?v=")
|
Log.i("bruuh", document.select("div[data-options]").attr("data-options"))
|
||||||
return GET(newUrl)
|
val videoList = mutableListOf<Video>()
|
||||||
|
val videosString = document.select("div[data-options]").attr("data-options")
|
||||||
|
.substringAfter("\\\"videos\\\":[{\\\"name\\\":\\\"")
|
||||||
|
.substringBefore("]")
|
||||||
|
videosString.split("{\\\"name\\\":\\\"").reversed().forEach {
|
||||||
|
val videoUrl = it.substringAfter("url\\\":\\\"")
|
||||||
|
.substringBefore("\\\"")
|
||||||
|
.replace("\\\\u0026", "&")
|
||||||
|
val quality = it.substringBefore("\\\"")
|
||||||
|
videoList.add(Video(videoUrl, quality, videoUrl, null))
|
||||||
}
|
}
|
||||||
return super.videoUrlRequest(video)
|
return videoList
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun videoUrlParse(document: Document): String {
|
override fun List<Video>.sort(): List<Video> {
|
||||||
return document.text()
|
val quality = preferences.getString("preferred_quality", "hd")
|
||||||
.substringAfter("{\"file\":\"")
|
if (quality != null) {
|
||||||
.substringBeforeLast("\"}")
|
val newList = mutableListOf<Video>()
|
||||||
.replace("\\/", "/")
|
var preferred = 0
|
||||||
|
for (video in this) {
|
||||||
|
if (video.quality == quality) {
|
||||||
|
newList.add(preferred, video)
|
||||||
|
preferred++
|
||||||
|
} else {
|
||||||
|
newList.add(video)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newList
|
||||||
|
}
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request = GET("$baseUrl/browse?q=$query&page=$page")
|
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request = GET("$baseUrl/browse?q=$query&page=$page")
|
||||||
@ -151,4 +187,23 @@ class AnimeFlv : ParsedAnimeHttpSource() {
|
|||||||
override fun latestUpdatesRequest(page: Int) = throw Exception("not used")
|
override fun latestUpdatesRequest(page: Int) = throw Exception("not used")
|
||||||
|
|
||||||
override fun latestUpdatesSelector() = throw Exception("not used")
|
override fun latestUpdatesSelector() = throw Exception("not used")
|
||||||
|
|
||||||
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
|
val videoQualityPref = ListPreference(screen.context).apply {
|
||||||
|
key = "preferred_quality"
|
||||||
|
title = "Preferred quality"
|
||||||
|
entries = arrayOf("hd", "sd", "low", "lowest", "mobile")
|
||||||
|
entryValues = arrayOf("hd", "sd", "low", "lowest", "mobile")
|
||||||
|
setDefaultValue("hd")
|
||||||
|
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(videoQualityPref)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user