Skip to content

Commit

Permalink
fix(src/es): Some fixes for Spanish extensions (#3065)
Browse files Browse the repository at this point in the history
  • Loading branch information
imper1aldev authored Mar 21, 2024
1 parent 156d06d commit 7449da5
Show file tree
Hide file tree
Showing 9 changed files with 494 additions and 385 deletions.
2 changes: 1 addition & 1 deletion src/es/animeflv/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'AnimeFLV'
extClass = '.AnimeFlv'
extVersionCode = 54
extVersionCode = 55
}

apply from: "$rootDir/common.gradle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import eu.kanade.tachiyomi.lib.streamwishextractor.StreamWishExtractor
import eu.kanade.tachiyomi.lib.youruploadextractor.YourUploadExtractor
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup
import eu.kanade.tachiyomi.util.parallelCatchingFlatMapBlocking
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
Expand Down Expand Up @@ -49,7 +48,7 @@ class AnimeFlv : ConfigurableAnimeSource, ParsedAnimeHttpSource() {

companion object {
private const val PREF_QUALITY_KEY = "preferred_quality"
private const val PREF_QUALITY_DEFAULT = "480"
private const val PREF_QUALITY_DEFAULT = "720"
private val QUALITY_LIST = arrayOf("1080", "720", "480", "360")

private const val PREF_SERVER_KEY = "preferred_server"
Expand Down Expand Up @@ -105,39 +104,25 @@ class AnimeFlv : ConfigurableAnimeSource, ParsedAnimeHttpSource() {

override fun episodeFromElement(element: Element) = throw UnsupportedOperationException()

/*--------------------------------Video extractors------------------------------------*/
private val streamTapeExtractor by lazy { StreamTapeExtractor(client) }
private val okruExtractor by lazy { OkruExtractor(client) }
private val yourUploadExtractor by lazy { YourUploadExtractor(client) }
private val streamWishExtractor by lazy { StreamWishExtractor(client, headers.newBuilder().add("Referer", "$baseUrl/").build()) }

override fun videoListParse(response: Response): List<Video> {
val document = response.asJsoup()
val videoList = mutableListOf<Video>()
document.select("script").forEach { script ->
if (script.data().contains("var videos = {")) {
val responseString = script.data().substringAfter("var videos =").substringBefore(";").trim()
val jObject = json.decodeFromString<JsonObject>(responseString)
jObject["SUB"]!!.jsonArray!!.forEach { servers ->
val json = servers!!.jsonObject
val quality = json!!["title"]!!.jsonPrimitive!!.content
val url = json!!["code"]!!.jsonPrimitive!!.content
val extractedVideos = runCatching {
when (quality) {
"Stape" -> {
val stapeUrl = json!!["url"]!!.jsonPrimitive!!.content
StreamTapeExtractor(client).videoFromUrl(stapeUrl)?.let(::listOf)
}
"Okru" -> OkruExtractor(client).videosFromUrl(url)
"YourUpload" -> YourUploadExtractor(client).videoFromUrl(url, headers = headers)
"SW" -> {
val docHeaders = headers.newBuilder()
.add("Referer", "$baseUrl/")
.build()
StreamWishExtractor(client, docHeaders).videosFromUrl(url, videoNameGen = { "StreamWish: $it" })
}
else -> null
}
}.getOrNull() ?: emptyList<Video>()
videoList.addAll(extractedVideos)
}
val jsonString = document.selectFirst("script:containsData(var videos = {)")?.data() ?: return emptyList()
val responseString = jsonString.substringAfter("var videos =").substringBefore(";").trim()
return json.decodeFromString<ServerModel>(responseString).sub.parallelCatchingFlatMapBlocking {
when (it.title) {
"Stape" -> listOf(streamTapeExtractor.videoFromUrl(it.url ?: it.code)!!)
"Okru" -> okruExtractor.videosFromUrl(it.url ?: it.code)
"YourUpload" -> yourUploadExtractor.videoFromUrl(it.url ?: it.code, headers = headers)
"SW" -> streamWishExtractor.videosFromUrl(it.url ?: it.code, videoNameGen = { "StreamWish:$it" })
else -> emptyList()
}
}
return videoList
}

override fun videoListSelector() = throw UnsupportedOperationException()
Expand Down Expand Up @@ -335,4 +320,21 @@ class AnimeFlv : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
}
}.also(screen::addPreference)
}

@Serializable
data class ServerModel(
@SerialName("SUB")
val sub: List<Sub> = emptyList(),
)

@Serializable
data class Sub(
val server: String? = "",
val title: String? = "",
val ads: Long? = null,
val url: String? = null,
val code: String = "",
@SerialName("allow_mobile")
val allowMobile: Boolean? = false,
)
}
2 changes: 1 addition & 1 deletion src/es/gnula/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'Gnula'
extClass = '.Gnula'
extVersionCode = 14
extVersionCode = 15
}

apply from: "$rootDir/common.gradle"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
package eu.kanade.tachiyomi.animeextension.es.gnula

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

// ---------------------Popular Model-------------------------
@Serializable
data class PopularModel(
val props: Props = Props(),
val page: String? = null,
val query: Query? = null,
)

@Serializable
data class Props(
val pageProps: PageProps = PageProps(),
@SerialName("__N_SSG")
val nSsg: Boolean = false,
)

@Serializable
data class PageProps(
val currentPage: String? = null,
val results: Results = Results(),
)

@Serializable
data class Results(
@SerialName("__typename")
val typename: String? = null,
val pages: Long? = null,
val data: List<Daum> = emptyList(),
)

@Serializable
data class Daum(
val titles: Titles = Titles(),
@SerialName("TMDbId")
val tmdbId: String? = null,
val images: Images = Images(),
val releaseDate: String? = null,
val slug: Slug = Slug(),
val url: Url = Url(),
)

@Serializable
data class Titles(
val name: String? = null,
)

@Serializable
data class Images(
val poster: String? = null,
)

@Serializable
data class Slug(
val name: String? = null,
)

@Serializable
data class Url(
val slug: String? = null,
)

@Serializable
data class Query(
val slug: List<String> = emptyList(),
)

// ---------------------Season Model-------------------------

@Serializable
data class SeasonModel(
val props: SeasonProps = SeasonProps(),
val page: String,
val query: SeasonQuery = SeasonQuery(),
)

@Serializable
data class SeasonProps(
val pageProps: SeasonPageProps = SeasonPageProps(),
@SerialName("__N_SSG")
val nSsg: Boolean = false,
)

@Serializable
data class SeasonPageProps(
val post: SeasonPost = SeasonPost(),
)

@Serializable
data class SeasonPost(
@SerialName("TMDbId")
val tmdbId: String? = null,
val titles: SeasonTitles = SeasonTitles(),
val images: SeasonImages = SeasonImages(),
val overview: String? = null,
val genres: List<SeasonGenre> = emptyList(),
val cast: SeasonCast = SeasonCast(),
val slug: SeasonSlug = SeasonSlug(),
val players: Players = Players(),
val releaseDate: String? = null,
val seasons: List<Season> = emptyList(),
)

@Serializable
data class Players(
val latino: List<Region> = emptyList(),
val spanish: List<Region> = emptyList(),
val english: List<Region> = emptyList(),
)

@Serializable
data class Region(
val cyberlocker: String = "",
val result: String = "",
val quality: String = "",
)

@Serializable
data class SeasonTitles(
val name: String? = null,
val original: Original? = null,
)

@Serializable
data class Original(
val name: String? = null,
)

@Serializable
data class SeasonImages(
val poster: String? = null,
val backdrop: String? = null,
)

@Serializable
data class SeasonGenre(
val name: String? = null,
)

@Serializable
data class SeasonCast(
val acting: List<Acting> = emptyList(),
val directing: List<Directing> = emptyList(),
val production: List<Production> = emptyList(),
)

@Serializable
data class Acting(
val name: String? = null,
)

@Serializable
data class Directing(
val name: String? = null,
)

@Serializable
data class Production(
val name: String? = null,
)

@Serializable
data class SeasonSlug(
val name: String? = null,
)

@Serializable
data class Season(
val number: Long? = null,
val episodes: List<SeasonEpisode> = emptyList(),
)

@Serializable
data class SeasonEpisode(
val title: String? = null,
@SerialName("TMDbId")
val tmdbId: String? = null,
val number: Long? = null,
val releaseDate: String? = null,
val image: String? = null,
val slug: Slug2 = Slug2(),
)

@Serializable
data class Slug2(
val name: String? = null,
val season: String? = null,
val episode: String? = null,
)

@Serializable
data class SeasonQuery(
val slug: String? = null,
)

// -----------------------Episode Model----------------------

@Serializable
data class EpisodeModel(
val props: EpisodeProps = EpisodeProps(),
val page: String,
)

@Serializable
data class EpisodeProps(
val pageProps: EpisodePageProps = EpisodePageProps(),
@SerialName("__N_SSG")
val nSsg: Boolean = false,
)

@Serializable
data class EpisodePageProps(
val episode: Episode = Episode(),
)

@Serializable
data class Episode(
@SerialName("TMDbId")
val tmdbId: String? = null,
val title: String? = null,
val number: Long? = null,
val image: String? = null,
val slug: EpisodeSlug = EpisodeSlug(),
val players: Players = Players(),
)

@Serializable
data class EpisodeSlug(
val name: String? = null,
val season: String? = null,
val episode: String? = null,
)
Loading

0 comments on commit 7449da5

Please sign in to comment.