Skip to content

Commit

Permalink
animeon: Added headers for bypass api requests
Browse files Browse the repository at this point in the history
  • Loading branch information
CakesTwix committed Oct 18, 2024
1 parent 642a8cb commit 1b1af88
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion AnimeONProvider/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// use an integer for version numbers
version = 6
version = 7

dependencies{
implementation("com.google.code.gson:gson:2.9.0")
Expand Down
43 changes: 35 additions & 8 deletions AnimeONProvider/src/main/kotlin/com/lagradost/AnimeONProvider.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lagradost

import android.util.Log
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.lagradost.cloudstream3.DubStatus
Expand Down Expand Up @@ -67,7 +68,12 @@ class AnimeONProvider : MainAPI() {
// Done
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
if(!request.data.contains("pageIndex") && page !=1) return HomePageResponse(emptyList())
val document = app.get(request.data.format(page)).text
val document = app.get(request.data.format(page),
headers = mapOf(
"Referer" to "https://animeon.club/",
)).text
Log.d("CakesTwix-Debug", request.data.format(page))
Log.d("CakesTwix-Debug", document)

// Нове
if(request.data.contains("pageIndex")) {
Expand Down Expand Up @@ -111,7 +117,10 @@ class AnimeONProvider : MainAPI() {
val animeJSON =
Gson()
.fromJson(
app.get(url.replace("/anime/", "/api/anime/")).text,
app.get(url.replace("/anime/", "/api/anime/"),
headers = mapOf(
"Referer" to "https://animeon.club/",
)).text,
AnimeInfoModel::class.java
)

Expand Down Expand Up @@ -140,9 +149,15 @@ class AnimeONProvider : MainAPI() {
val episodes = mutableListOf<Episode>()

// Get all fundub for title and parse only first fundub/player
val fundubs = Gson().fromJson<List<FundubModel>>(app.get("${apiUrl}/player/fundubs/${animeJSON.id}").text, listFundub)
val fundubs = Gson().fromJson<List<FundubModel>>(app.get("${apiUrl}/player/fundubs/${animeJSON.id}",
headers = mapOf(
"Referer" to "https://animeon.club/",
)).text, listFundub)

Gson().fromJson<List<FundubEpisode>>(app.get("${apiUrl}/player/episodes/${fundubs?.get(0)?.player?.get(0)?.id}/${fundubs?.get(0)?.fundub?.id}").text, listFundubEpisodes)?.map { epd -> // Episode
Gson().fromJson<List<FundubEpisode>>(app.get("${apiUrl}/player/episodes/${fundubs?.get(0)?.player?.get(0)?.id}/${fundubs?.get(0)?.fundub?.id}",
headers = mapOf(
"Referer" to "https://animeon.club/",
)).text, listFundubEpisodes)?.map { epd -> // Episode
episodes.add(
Episode(
"${animeJSON.id}, ${epd.episode}",
Expand Down Expand Up @@ -200,14 +215,23 @@ class AnimeONProvider : MainAPI() {
callback: (ExtractorLink) -> Unit
): Boolean {
val dataList = data.split(", ")
val fundubs = Gson().fromJson<List<FundubModel>>(app.get("${apiUrl}/player/fundubs/${dataList[0]}").text, listFundub)
val fundubs = Gson().fromJson<List<FundubModel>>(app.get("${apiUrl}/player/fundubs/${dataList[0]}",
headers = mapOf(
"Referer" to "https://animeon.club/",
)).text, listFundub)

if(dataList.size == 2){
fundubs.map { dub ->
Gson().fromJson<List<FundubEpisode>>(app.get("${apiUrl}/player/episodes/${dub.player[0].id}/${dub.fundub.id}").text, listFundubEpisodes).filter{ it.episode == dataList[1].toIntOrNull() }.map { epd -> // Episode
Gson().fromJson<List<FundubEpisode>>(app.get("${apiUrl}/player/episodes/${dub.player[0].id}/${dub.fundub.id}",
headers = mapOf(
"Referer" to "https://animeon.club/",
)).text, listFundubEpisodes).filter{ it.episode == dataList[1].toIntOrNull() }.map { epd -> // Episode
M3u8Helper.generateM3u8(
source = "${dub.fundub.name} (${dub.player[0].name})",
streamUrl = getM3U(app.get("${apiUrl}/player/episode/${epd.id}").parsedSafe<FundubVideoUrl>()!!.videoUrl),
streamUrl = getM3U(app.get("${apiUrl}/player/episode/${epd.id}",
headers = mapOf(
"Referer" to "https://animeon.club/",
)).parsedSafe<FundubVideoUrl>()!!.videoUrl),
referer = "https://animeon.club"
).last().let(callback)
}
Expand All @@ -218,7 +242,10 @@ class AnimeONProvider : MainAPI() {
fundubs.map { dub ->
M3u8Helper.generateM3u8(
source = "${dub.fundub.name} (${dub.player[0].name})",
streamUrl = getM3U(app.get("${apiUrl}/player/${dub.player[0].id}/${dub.fundub.id}").parsedSafe<FundubVideoUrl>()!!.videoUrl),
streamUrl = getM3U(app.get("${apiUrl}/player/${dub.player[0].id}/${dub.fundub.id}",
headers = mapOf(
"Referer" to "https://animeon.club/",
)).parsedSafe<FundubVideoUrl>()!!.videoUrl),
referer = "https://animeon.club"
).last().let(callback)
}
Expand Down

0 comments on commit 1b1af88

Please sign in to comment.