Initial commit
This commit is contained in:
commit
98ed7e8839
2263 changed files with 108711 additions and 0 deletions
29
src/pt/animesroll/AndroidManifest.xml
Normal file
29
src/pt/animesroll/AndroidManifest.xml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".pt.animesroll.AnimesROLLUrlActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:theme="@android:style/Theme.NoDisplay">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data
|
||||
android:host="www.anroll.net"
|
||||
android:pathPattern="/a/..*"
|
||||
android:scheme="https" />
|
||||
|
||||
<data
|
||||
android:host="www.anroll.net"
|
||||
android:pathPattern="/f/..*"
|
||||
android:scheme="https" />
|
||||
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
7
src/pt/animesroll/build.gradle
Normal file
7
src/pt/animesroll/build.gradle
Normal file
|
@ -0,0 +1,7 @@
|
|||
ext {
|
||||
extName = 'AnimesROLL'
|
||||
extClass = '.AnimesROLL'
|
||||
extVersionCode = 3
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
BIN
src/pt/animesroll/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
src/pt/animesroll/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5 KiB |
BIN
src/pt/animesroll/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
src/pt/animesroll/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
BIN
src/pt/animesroll/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
src/pt/animesroll/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
BIN
src/pt/animesroll/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
src/pt/animesroll/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
src/pt/animesroll/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
src/pt/animesroll/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
|
@ -0,0 +1,192 @@
|
|||
package eu.kanade.tachiyomi.animeextension.pt.animesroll
|
||||
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animesroll.dto.AnimeDataDto
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animesroll.dto.EpisodeDto
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animesroll.dto.EpisodeListDto
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animesroll.dto.LatestAnimeDto
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animesroll.dto.MovieInfoDto
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animesroll.dto.PagePropDto
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animesroll.dto.SearchResultsDto
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimesPage
|
||||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.awaitSuccess
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import eu.kanade.tachiyomi.util.parseAs
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
|
||||
class AnimesROLL : AnimeHttpSource() {
|
||||
|
||||
override val name = "AnimesROLL"
|
||||
|
||||
override val baseUrl = "https://www.anroll.net"
|
||||
|
||||
override val lang = "pt-BR"
|
||||
|
||||
override val supportsLatest = true
|
||||
|
||||
override fun headersBuilder() = super.headersBuilder().add("Referer", baseUrl)
|
||||
|
||||
private val json = Json {
|
||||
ignoreUnknownKeys = true
|
||||
isLenient = true
|
||||
}
|
||||
|
||||
// ============================== Popular ===============================
|
||||
// The site doesn't have a popular anime tab, so we use the home page instead (latest anime).
|
||||
override fun popularAnimeRequest(page: Int) = GET(baseUrl)
|
||||
override fun popularAnimeParse(response: Response) = latestUpdatesParse(response)
|
||||
|
||||
// =============================== Latest ===============================
|
||||
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/lancamentos")
|
||||
|
||||
override fun latestUpdatesParse(response: Response): AnimesPage {
|
||||
val parsed = response.asJsoup().parseAs<LatestAnimeDto>()
|
||||
val animes = parsed.episodes.map { it.episode.anime!!.toSAnime() }
|
||||
return AnimesPage(animes, false)
|
||||
}
|
||||
|
||||
// =============================== Search ===============================
|
||||
private fun searchAnimeByPathParse(response: Response): AnimesPage {
|
||||
val details = animeDetailsParse(response)
|
||||
return AnimesPage(listOf(details), false)
|
||||
}
|
||||
|
||||
override suspend fun getSearchAnime(page: Int, query: String, filters: AnimeFilterList): AnimesPage {
|
||||
return if (query.startsWith(PREFIX_SEARCH)) {
|
||||
val path = query.removePrefix(PREFIX_SEARCH)
|
||||
client.newCall(GET("$baseUrl/$path"))
|
||||
.awaitSuccess()
|
||||
.use(::searchAnimeByPathParse)
|
||||
} else {
|
||||
super.getSearchAnime(page, query, filters)
|
||||
}
|
||||
}
|
||||
override fun searchAnimeParse(response: Response): AnimesPage {
|
||||
val results = response.parseAs<SearchResultsDto>()
|
||||
val animes = (results.animes + results.movies).map { it.toSAnime() }
|
||||
return AnimesPage(animes, false)
|
||||
}
|
||||
|
||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
|
||||
return GET("$OLD_API_URL/search?q=$query")
|
||||
}
|
||||
|
||||
// =========================== Anime Details ============================
|
||||
override fun animeDetailsParse(response: Response): SAnime {
|
||||
val doc = response.asJsoup()
|
||||
val anime = when {
|
||||
doc.location().contains("/f/") -> doc.parseAs<MovieInfoDto>().movieData
|
||||
else -> doc.parseAs<AnimeDataDto>()
|
||||
}
|
||||
return anime.toSAnime().apply {
|
||||
setUrlWithoutDomain(doc.location())
|
||||
author = anime.director.takeIf { it != "0" }
|
||||
|
||||
description = buildString {
|
||||
append(anime.description.ifNotEmpty { it + "\n" })
|
||||
append(anime.duration.ifNotEmpty { "\nDuração: $it" })
|
||||
append(anime.animeCalendar?.ifNotEmpty { "\nLança toda(o) $it" }.orEmpty())
|
||||
}
|
||||
genre = doc.select("div#generos > a").eachText().joinToString()
|
||||
status = if (anime.animeCalendar == null) SAnime.COMPLETED else SAnime.ONGOING
|
||||
}
|
||||
}
|
||||
|
||||
// ============================== Episodes ==============================
|
||||
override fun episodeListParse(response: Response): List<SEpisode> {
|
||||
val doc = response.asJsoup()
|
||||
val originalUrl = doc.location()
|
||||
return if ("/f/" in originalUrl) {
|
||||
val od = doc.parseAs<MovieInfoDto>().movieData.od
|
||||
SEpisode.create().apply {
|
||||
url = "$OLD_API_URL/od/$od/filme.mp4"
|
||||
name = "Filme"
|
||||
episode_number = 0F
|
||||
}.let(::listOf)
|
||||
} else {
|
||||
val anime = doc.parseAs<AnimeDataDto>()
|
||||
val urlStart = "https://cdn-01.gamabunta.xyz/hls/animes/${anime.slug}"
|
||||
|
||||
return fetchEpisodesRecursively(anime.id).map { episode ->
|
||||
SEpisode.create().apply {
|
||||
val epNum = episode.episodeNumber
|
||||
name = "Episódio #$epNum"
|
||||
episode_number = epNum.toFloat()
|
||||
url = "$urlStart/$epNum.mp4/media-1/stream.m3u8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchEpisodesRecursively(animeId: String, page: Int = 1): List<EpisodeDto> {
|
||||
val response = client.newCall(episodeListRequest(animeId, page))
|
||||
.execute()
|
||||
.parseAs<EpisodeListDto>()
|
||||
|
||||
return response.episodes.let { episodes ->
|
||||
when {
|
||||
response.meta.totalOfPages > page ->
|
||||
episodes + fetchEpisodesRecursively(animeId, page + 1)
|
||||
else -> episodes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun episodeListRequest(animeId: String, page: Int) =
|
||||
GET("$NEW_API_URL/animes/$animeId/episodes?page=$page%order=desc")
|
||||
|
||||
// ============================ Video Links =============================
|
||||
override suspend fun getVideoList(episode: SEpisode): List<Video> {
|
||||
val epUrl = episode.url
|
||||
return listOf(Video(epUrl, "default", epUrl))
|
||||
}
|
||||
|
||||
override fun videoListRequest(episode: SEpisode): Request {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun videoListParse(response: Response): List<Video> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
// ============================= Utilities ==============================
|
||||
private inline fun <reified T> Document.parseAs(): T {
|
||||
val nextData = this.selectFirst("script#__NEXT_DATA__")!!
|
||||
.data()
|
||||
.substringAfter(":")
|
||||
.substringBeforeLast(",\"page\"")
|
||||
return json.decodeFromString<PagePropDto<T>>(nextData).data
|
||||
}
|
||||
|
||||
private fun String.ifNotEmpty(block: (String) -> String): String {
|
||||
return if (isNotEmpty() && this != "0") block(this) else ""
|
||||
}
|
||||
|
||||
fun AnimeDataDto.toSAnime() = SAnime.create().apply {
|
||||
val ismovie = slug == ""
|
||||
url = if (ismovie) "/f/$id" else "/anime/$slug"
|
||||
thumbnail_url = "https://static.anroll.net/images/".let {
|
||||
if (ismovie) {
|
||||
it + "filmes/capas/$slug_movie.jpg"
|
||||
} else {
|
||||
it + "animes/capas/$slug.jpg"
|
||||
}
|
||||
}
|
||||
title = anititle
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val OLD_API_URL = "https://apiv2-prd.anroll.net"
|
||||
private const val NEW_API_URL = "https://apiv3-prd.anroll.net"
|
||||
|
||||
const val PREFIX_SEARCH = "path:"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package eu.kanade.tachiyomi.animeextension.pt.animesroll
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
/**
|
||||
* Springboard that accepts https://www.anroll.net/<type>/<item> intents
|
||||
* and redirects them to the main Aniyomi process.
|
||||
*/
|
||||
class AnimesROLLUrlActivity : Activity() {
|
||||
|
||||
private val tag = javaClass.simpleName
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val pathSegments = intent?.data?.pathSegments
|
||||
if (pathSegments != null && pathSegments.size > 1) {
|
||||
val path = "${pathSegments[0]}/${pathSegments[1]}"
|
||||
val mainIntent = Intent().apply {
|
||||
action = "eu.kanade.tachiyomi.ANIMESEARCH"
|
||||
putExtra("query", "${AnimesROLL.PREFIX_SEARCH}$path")
|
||||
putExtra("filter", packageName)
|
||||
}
|
||||
|
||||
try {
|
||||
startActivity(mainIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Log.e(tag, e.toString())
|
||||
}
|
||||
} else {
|
||||
Log.e(tag, "could not parse uri from intent $intent")
|
||||
}
|
||||
|
||||
finish()
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package eu.kanade.tachiyomi.animeextension.pt.animesroll.dto
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonNames
|
||||
|
||||
@Serializable
|
||||
data class PagePropDto<T>(val pageProps: DataPropDto<T>) {
|
||||
val data by lazy { pageProps.data }
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class DataPropDto<T>(val data: T)
|
||||
|
||||
@Serializable
|
||||
data class LatestAnimeDto(
|
||||
@SerialName("data_releases")
|
||||
val episodes: List<EpisodeAnimeDto>,
|
||||
) {
|
||||
@Serializable
|
||||
data class EpisodeAnimeDto(val episode: EpisodeDto)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class MovieInfoDto(
|
||||
@SerialName("data_movie")
|
||||
val movieData: AnimeDataDto,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class AnimeDataDto(
|
||||
@SerialName("diretor")
|
||||
val director: String = "",
|
||||
@JsonNames("nome_filme", "titulo")
|
||||
val anititle: String,
|
||||
@JsonNames("sinopse", "sinopse_filme")
|
||||
val description: String = "",
|
||||
@SerialName("slug_serie")
|
||||
val slug: String = "",
|
||||
@SerialName("slug_filme")
|
||||
val slug_movie: String = "",
|
||||
@SerialName("duracao")
|
||||
val duration: String = "",
|
||||
@SerialName("generate_id")
|
||||
val id: String = "",
|
||||
val animeCalendar: String? = null,
|
||||
val od: String = "",
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class EpisodeListDto(
|
||||
@SerialName("data")
|
||||
val episodes: List<EpisodeDto>,
|
||||
val meta: MetadataDto,
|
||||
) {
|
||||
@Serializable
|
||||
data class MetadataDto(val totalOfPages: Int)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class EpisodeDto(
|
||||
@SerialName("n_episodio")
|
||||
val episodeNumber: String,
|
||||
val anime: AnimeDataDto? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SearchResultsDto(
|
||||
@SerialName("data_anime")
|
||||
val animes: List<AnimeDataDto>,
|
||||
@SerialName("data_filme")
|
||||
val movies: List<AnimeDataDto>,
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue