Skip to content
This repository has been archived by the owner on Jan 12, 2025. It is now read-only.

Commit

Permalink
Add AniWave Source
Browse files Browse the repository at this point in the history
  • Loading branch information
fakeyatogod committed Oct 29, 2023
1 parent 1e5b39a commit d6901d0
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ class SourceSelector(context: Context) {
val sourceMap: Map<String, AnimeSource> = mapOf(
"yugen" to YugenSource(),
"allanime" to AllAnimeSource(),
"enime" to EnimeSource(),
"kiss_kh" to KissKhSource(),
"animepahe" to AnimePaheSource(context),
"kawaiifu" to KawaiifuSource(context),
"marin_moe" to MarinMoeSource(),
"aniwave" to AniWaveSource(),
"kiss_kh" to KissKhSource(),
"asian_load" to AsianLoad(),
"my_asian_tv" to MyAsianTvSource(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import java.nio.charset.StandardCharsets
class AllAnimeSource : AnimeSource {

private val mainAPIUrl = "https://api.allanime.day/api"
private val referer = "https://allanime.to/"
private val referer = "https://allanime2.com/"
override suspend fun animeDetails(contentLink: String): AnimeDetails =
withContext(Dispatchers.IO) {
val hash = "9d7439c90f203e534ca778c4901f9aa2d3ad42c06243ab2c5e6b79612af32028"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package com.talent.animescrapsources.animesources

import com.talent.animescrap_common.model.AnimeDetails
import com.talent.animescrap_common.model.AnimeStreamLink
import com.talent.animescrap_common.model.SimpleAnime
import com.talent.animescrap_common.source.AnimeSource
import com.talent.animescrap_common.utils.Utils.get
import com.talent.animescrap_common.utils.Utils.getJson
import com.talent.animescrap_common.utils.Utils.getJsoup
import com.talent.animescrap_common.utils.Utils.postJson
import org.jsoup.Jsoup

class AniWaveSource : AnimeSource {
private val mainUrl = "https://aniwave.to"
private val url = "https://vidplay.site/"
private val apiUrl = "https://9anime.eltik.net/"

override suspend fun animeDetails(contentLink: String): AnimeDetails {
val doc = getJsoup("$mainUrl$contentLink")
val cover = doc.select("#w-info").first()!!.getElementsByTag("img").attr("src")
val desc = doc.select("#w-info .info .content").text()
val title = doc.select("#w-info .info .title").attr("data-jp")

val dataId = doc.getElementsByAttribute("data-id").first()!!.attr("data-id")
val vrf = getVrf(dataId)
val eps =
Jsoup.parseBodyFragment(getJson("$mainUrl/ajax/episode/list/$dataId?vrf=$vrf")!!.asJsonObject["result"].asString)
.select("li a")
val subMap = mutableMapOf<String, String>()
val dubMap = mutableMapOf<String, String>()
eps.forEach {
val epNum = it.attr("data-num")
val epIds = it.attr("data-ids")
val isSub = it.attr("data-sub").toInt() == 1
val isDub = it.attr("data-dub").toInt() == 1
if (isSub) subMap[epNum] = epIds
if (isDub) dubMap[epNum] = epIds
}

return AnimeDetails(title, desc, cover, mapOf("Sub" to subMap, "Dub" to dubMap))
}

private fun getVrf(dataId: String): String {
val json = getJson("$apiUrl/vrf?query=${dataId}&apikey=chayce")
return json!!.asJsonObject["url"].asString
}
private fun decodeVrf(dataId: String): String {
val json = getJson("$apiUrl/decrypt?query=${dataId}&apikey=chayce")
return json!!.asJsonObject["url"].asString
}


override suspend fun searchAnime(searchedText: String): ArrayList<SimpleAnime> {

val animeList = arrayListOf<SimpleAnime>()
val doc = getJsoup("$mainUrl/filter?keyword=$searchedText")
doc.select("#list-items .item").forEach { item ->
animeList.add(
SimpleAnime(
item.select(".info a").attr("data-jp"),
item.getElementsByTag("img").attr("src"),
item.getElementsByTag("a").attr("href")
)
)
}
return animeList
}

override suspend fun latestAnime(): ArrayList<SimpleAnime> {
val animeList = arrayListOf<SimpleAnime>()
val url = "$mainUrl/ajax/home/widget/updated-sub?page=1"
val latestHtml = getJson(url)!!.asJsonObject["result"].asString
val doc = Jsoup.parseBodyFragment(latestHtml)
doc.getElementsByClass("item").forEach { item ->
animeList.add(
SimpleAnime(
item.select(".info a").attr("data-jp"),
item.getElementsByTag("img").attr("src"),
item.getElementsByTag("a").attr("href")
)
)
}
return animeList
}

override suspend fun trendingAnime(): ArrayList<SimpleAnime> {
val animeList = arrayListOf<SimpleAnime>()
val url = "$mainUrl/home/"
val doc = getJsoup(url)
doc.select("#top-anime .tab-content").first()!!.select(".item").forEach { item ->
animeList.add(
SimpleAnime(
item.select(".name").attr("data-jp"),
item.getElementsByTag("img").attr("src"),
item.attr("href")
)
)
}
return animeList
}

override suspend fun streamLink(
animeUrl: String,
animeEpCode: String,
extras: List<String>?
): AnimeStreamLink {
// 0=sub , 1=softsub, 3=dub
val dataId = animeEpCode.split(",").first()
val vrf = getVrf(dataId)
val servers =
Jsoup.parseBodyFragment(getJson("$mainUrl/ajax/server/list/$dataId?vrf=$vrf")!!.asJsonObject["result"].asString)
val dataLinkId = servers.select(".servers .type ul li")[0]!!.attr("data-link-id")
val vrf2 = getVrf(dataLinkId)
val linkEncoded = getJson("$mainUrl/ajax/server/$dataLinkId?vrf=$vrf2")!!.asJsonObject["result"].asJsonObject["url"].asString
val embedLink = decodeVrf(linkEncoded)
// println(embedLink)
val fileURL = getFileUrl(embedLink)
// println(fileURL)
val link = getJson(fileURL, mapOf("referer" to embedLink))!!.asJsonObject["result"].asJsonObject["sources"].asJsonArray.first().asJsonObject["file"].asString
// println(link)
return AnimeStreamLink(link, "", true)
}

private fun getFuToken(referer: String): String {
val response = get("$url/futoken", mapOf("referer" to referer))
return response.replace(Regex("""/\*[\s\S]*?\*/|//.*"""), "").replace("\n", "")
}

private fun getFileUrl(sourceUrl: String): String {
val fuToken = getFuToken(sourceUrl)
val id = sourceUrl.split("/e/")[1].split('?')[0]

val response = postJson(url = "$apiUrl/rawVizcloud?query=$id&apikey=lagrapps",
payload = mapOf("query" to id,"futoken" to fuToken)
)
val rawURL = response!!.asJsonObject["rawURL"].asString
return "$rawURL?${sourceUrl.split('?')[1]}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
val sourceList = SourceSelector(requireContext()).sourceMap.keys
sourcePreference.entryValues = sourceList.toTypedArray()
sourcePreference.entries = sourceList.map {
it.replaceFirstChar { str -> if (str.isLowerCase()) str.titlecase(Locale.ROOT) else str.toString() }
.replace("_", " ")
it.uppercase().replace("_", " ")
}.toTypedArray()
sourcePreference.setDefaultValue("yugen")
sourcePreference.summaryProvider = Preference.SummaryProvider<ListPreference> { preference ->
val newValue = preference.value
"Source set to ${newValue?.uppercase()?.replace("_", " ")}"
preference.value?.uppercase()?.replace("_", " ")
}
// preferenceScreen.addPreference(sourceCategory)
sourceCategory?.addPreference(sourcePreference)


Expand Down

0 comments on commit d6901d0

Please sign in to comment.