Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(src/es): Some fixes for Spanish extensions #3065

Merged
merged 18 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -107,37 +106,20 @@ class AnimeFlv : ConfigurableAnimeSource, ParsedAnimeHttpSource() {

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(client).videoFromUrl(it.url ?: it.code)!!)
imper1aldev marked this conversation as resolved.
Show resolved Hide resolved
"Okru" -> OkruExtractor(client).videosFromUrl(it.url ?: it.code)
"YourUpload" -> YourUploadExtractor(client).videoFromUrl(it.url ?: it.code, headers = headers)
"SW" -> {
val docHeaders = headers.newBuilder().add("Referer", "$baseUrl/").build()
StreamWishExtractor(client, docHeaders).videosFromUrl(it.url ?: it.code, videoNameGen = { "StreamWish:$it" })
}
else -> emptyList()
}
}
return videoList
}

override fun videoListSelector() = throw UnsupportedOperationException()
Expand Down Expand Up @@ -335,4 +317,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,229 @@
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(),
)

@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 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