Animeflix: Add support for multiple seasons (#1697)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'AnimeFlix'
|
extName = 'AnimeFlix'
|
||||||
pkgNameSuffix = 'en.animeflix'
|
pkgNameSuffix = 'en.animeflix'
|
||||||
extClass = '.AnimeFlix'
|
extClass = '.AnimeFlix'
|
||||||
extVersionCode = 2
|
extVersionCode = 3
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,35 +205,68 @@ class AnimeFlix : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
val document = client.newCall(GET(baseUrl + anime.url)).execute().asJsoup()
|
val document = client.newCall(GET(baseUrl + anime.url)).execute().asJsoup()
|
||||||
val episodeList = mutableListOf<SEpisode>()
|
val episodeList = mutableListOf<SEpisode>()
|
||||||
val serversList = mutableListOf<List<EpUrl>>()
|
val serversList = mutableListOf<List<EpUrl>>()
|
||||||
|
val seasonRegex = Regex("""season (\d+)""", RegexOption.IGNORE_CASE)
|
||||||
|
val qualityRegex = """(\d+)p""".toRegex()
|
||||||
|
val episodeRegex = Regex("""episode (\d+)""", RegexOption.IGNORE_CASE)
|
||||||
val driveList = mutableListOf<Pair<String, String>>()
|
val driveList = mutableListOf<Pair<String, String>>()
|
||||||
|
|
||||||
document.select("div.thecontent p:has(span:contains(Gdrive))").forEach {
|
val seasonList = document.select("div.inline > h3:contains(Season)")
|
||||||
val qualityRegex = """(\d+)p""".toRegex()
|
|
||||||
val quality = qualityRegex.find(it.previousElementSibling()!!.text())!!.groupValues[1]
|
|
||||||
driveList.add(Pair(it.selectFirst("a")!!.attr("href"), quality))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load episodes
|
if (seasonList.distinctBy { seasonRegex.find(it.text())!!.groupValues[1] }.size > 1) {
|
||||||
driveList.forEach { drive ->
|
document.select("div.thecontent p:has(span:contains(Gdrive))").forEach {
|
||||||
val episodesDocument = client.newCall(GET(drive.first)).execute().asJsoup()
|
val titleText = it.previousElementSibling()!!.text()
|
||||||
serversList.add(
|
|
||||||
episodesDocument.select("div.entry-content > h3 > a").map {
|
|
||||||
EpUrl(drive.second, it.attr("href"), it.text())
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
transpose(serversList).forEachIndexed { index, serverList ->
|
val quality = qualityRegex.find(titleText)!!.groupValues[1]
|
||||||
episodeList.add(
|
val seasonName = seasonRegex.find(titleText)!!.groupValues[1]
|
||||||
SEpisode.create().apply {
|
|
||||||
name = serverList.first().name
|
val episodesDocument = client.newCall(GET(it.selectFirst("a")!!.attr("href"))).execute().asJsoup()
|
||||||
episode_number = (index + 1).toFloat()
|
episodesDocument.select("div.entry-content > h3 > a").forEach {
|
||||||
setUrlWithoutDomain(
|
episodeList.add(
|
||||||
json.encodeToString(serverList),
|
SEpisode.create().apply {
|
||||||
|
name = "Season $seasonName ${it.text()}"
|
||||||
|
episode_number = episodeRegex.find(it.text())?.groupValues?.get(1)?.toFloatOrNull() ?: 1F
|
||||||
|
setUrlWithoutDomain(
|
||||||
|
json.encodeToString(
|
||||||
|
listOf(
|
||||||
|
EpUrl(
|
||||||
|
quality = quality,
|
||||||
|
url = it.attr("href"),
|
||||||
|
name = "Season $seasonName ${it.text()}",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
)
|
}
|
||||||
|
} else {
|
||||||
|
document.select("div.thecontent p:has(span:contains(Gdrive))").forEach {
|
||||||
|
val quality = qualityRegex.find(it.previousElementSibling()!!.text())!!.groupValues[1]
|
||||||
|
driveList.add(Pair(it.selectFirst("a")!!.attr("href"), quality))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load episodes
|
||||||
|
driveList.forEach { drive ->
|
||||||
|
val episodesDocument = client.newCall(GET(drive.first)).execute().asJsoup()
|
||||||
|
serversList.add(
|
||||||
|
episodesDocument.select("div.entry-content > h3 > a").map {
|
||||||
|
EpUrl(drive.second, it.attr("href"), it.text())
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
transpose(serversList).forEachIndexed { index, serverList ->
|
||||||
|
episodeList.add(
|
||||||
|
SEpisode.create().apply {
|
||||||
|
name = serverList.first().name
|
||||||
|
episode_number = (index + 1).toFloat()
|
||||||
|
setUrlWithoutDomain(
|
||||||
|
json.encodeToString(serverList),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Observable.just(episodeList.reversed())
|
return Observable.just(episodeList.reversed())
|
||||||
|
Reference in New Issue
Block a user