Initial commit
This commit is contained in:
commit
98ed7e8839
2263 changed files with 108711 additions and 0 deletions
23
src/pt/animestc/AndroidManifest.xml
Normal file
23
src/pt/animestc/AndroidManifest.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".pt.animestc.AnimesTCUrlActivity"
|
||||
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.animestc.net"
|
||||
android:pathPattern="/animes/..*"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
11
src/pt/animestc/build.gradle
Normal file
11
src/pt/animestc/build.gradle
Normal file
|
@ -0,0 +1,11 @@
|
|||
ext {
|
||||
extName = 'AnimesTC'
|
||||
extClass = '.AnimesTC'
|
||||
extVersionCode = 6
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
||||
dependencies {
|
||||
implementation(project(":lib:googledrive-extractor"))
|
||||
}
|
BIN
src/pt/animestc/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
src/pt/animestc/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
BIN
src/pt/animestc/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
src/pt/animestc/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
BIN
src/pt/animestc/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
src/pt/animestc/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
BIN
src/pt/animestc/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
src/pt/animestc/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.9 KiB |
BIN
src/pt/animestc/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
src/pt/animestc/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,174 @@
|
|||
package eu.kanade.tachiyomi.animeextension.pt.animestc
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilter
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
|
||||
object ATCFilters {
|
||||
open class QueryPartFilter(
|
||||
displayName: String,
|
||||
val vals: Array<Pair<String, String>>,
|
||||
) : AnimeFilter.Select<String>(
|
||||
displayName,
|
||||
vals.map { it.first }.toTypedArray(),
|
||||
) {
|
||||
fun toQueryPart() = vals[state].second
|
||||
}
|
||||
|
||||
private inline fun <reified R> AnimeFilterList.asQueryPart(): String {
|
||||
return (first { it is R } as QueryPartFilter).toQueryPart()
|
||||
}
|
||||
|
||||
class TypeFilter : QueryPartFilter("Tipo", ATCFiltersData.TYPES)
|
||||
class YearFilter : QueryPartFilter("Ano", ATCFiltersData.YEARS)
|
||||
class GenreFilter : QueryPartFilter("Gênero", ATCFiltersData.GENRES)
|
||||
class StatusFilter : QueryPartFilter("Status", ATCFiltersData.STATUS)
|
||||
|
||||
val FILTER_LIST get() = AnimeFilterList(
|
||||
TypeFilter(),
|
||||
YearFilter(),
|
||||
GenreFilter(),
|
||||
StatusFilter(),
|
||||
)
|
||||
|
||||
data class FilterSearchParams(
|
||||
val type: String = "series",
|
||||
val year: String = "",
|
||||
val genre: String = "",
|
||||
val status: String = "",
|
||||
)
|
||||
|
||||
internal fun getSearchParameters(filters: AnimeFilterList): FilterSearchParams {
|
||||
if (filters.isEmpty()) return FilterSearchParams()
|
||||
|
||||
return FilterSearchParams(
|
||||
filters.asQueryPart<TypeFilter>(),
|
||||
filters.asQueryPart<YearFilter>(),
|
||||
filters.asQueryPart<GenreFilter>(),
|
||||
filters.asQueryPart<StatusFilter>(),
|
||||
)
|
||||
}
|
||||
|
||||
private object ATCFiltersData {
|
||||
val TYPES = arrayOf(
|
||||
Pair("Anime", "series"),
|
||||
Pair("Filme", "movie"),
|
||||
Pair("OVA", "ova"),
|
||||
)
|
||||
|
||||
val SELECT = Pair("Selecione", "")
|
||||
|
||||
val STATUS = arrayOf(
|
||||
SELECT,
|
||||
Pair("Cancelado", "canceled"),
|
||||
Pair("Completo", "complete"),
|
||||
Pair("Em Lançamento", "airing"),
|
||||
Pair("Pausado", "onhold"),
|
||||
)
|
||||
|
||||
val YEARS = arrayOf(SELECT) + (1997..2024).map {
|
||||
Pair(it.toString(), it.toString())
|
||||
}.toTypedArray()
|
||||
|
||||
val GENRES = arrayOf(
|
||||
SELECT,
|
||||
Pair("Ação", "acao"),
|
||||
Pair("Action", "action"),
|
||||
Pair("Adventure", "adventure"),
|
||||
Pair("Artes Marciais", "artes-marciais"),
|
||||
Pair("Artes Marcial", "artes-marcial"),
|
||||
Pair("Aventura", "aventura"),
|
||||
Pair("Beisebol", "beisebol"),
|
||||
Pair("Boys Love", "boys-love"),
|
||||
Pair("Comédia", "comedia"),
|
||||
Pair("Comédia Romântica", "comedia-romantica"),
|
||||
Pair("Comedy", "comedy"),
|
||||
Pair("Crianças", "criancas"),
|
||||
Pair("Culinária", "culinaria"),
|
||||
Pair("Cyberpunk", "cyberpunk"),
|
||||
Pair("Demônios", "demonios"),
|
||||
Pair("Distopia", "distopia"),
|
||||
Pair("Documentário", "documentario"),
|
||||
Pair("Drama", "drama"),
|
||||
Pair("Ecchi", "ecchi"),
|
||||
Pair("Escola", "escola"),
|
||||
Pair("Escolar", "escolar"),
|
||||
Pair("Espaço", "espaco"),
|
||||
Pair("Esporte", "esporte"),
|
||||
Pair("Esportes", "esportes"),
|
||||
Pair("Fantasia", "fantasia"),
|
||||
Pair("Ficção Científica", "ficcao-cientifica"),
|
||||
Pair("Futebol", "futebol"),
|
||||
Pair("Game", "game"),
|
||||
Pair("Girl battleships", "girl-battleships"),
|
||||
Pair("Gourmet", "gourmet"),
|
||||
Pair("Gundam", "gundam"),
|
||||
Pair("Harém", "harem"),
|
||||
Pair("Hentai", "hentai"),
|
||||
Pair("Historia", "historia"),
|
||||
Pair("Historial", "historial"),
|
||||
Pair("Historical", "historical"),
|
||||
Pair("Histórico", "historico"),
|
||||
Pair("Horror", "horror"),
|
||||
Pair("Humor Negro", "humor-negro"),
|
||||
Pair("Ídolo", "idolo"),
|
||||
Pair("Infantis", "infantis"),
|
||||
Pair("Investigação", "investigacao"),
|
||||
Pair("Isekai", "isekai"),
|
||||
Pair("Jogo", "jogo"),
|
||||
Pair("Jogos", "jogos"),
|
||||
Pair("Josei", "josei"),
|
||||
Pair("Kids", "kids"),
|
||||
Pair("Luta", "luta"),
|
||||
Pair("Maduro", "maduro"),
|
||||
Pair("Máfia", "mafia"),
|
||||
Pair("Magia", "magia"),
|
||||
Pair("Mágica", "magica"),
|
||||
Pair("Mecha", "mecha"),
|
||||
Pair("Militar", "militar"),
|
||||
Pair("Militares", "militares"),
|
||||
Pair("Mistério", "misterio"),
|
||||
Pair("Música", "musica"),
|
||||
Pair("Musical", "musical"),
|
||||
Pair("Não Informado!", "nao-informado"),
|
||||
Pair("Paródia", "parodia"),
|
||||
Pair("Piratas", "piratas"),
|
||||
Pair("Polícia", "policia"),
|
||||
Pair("Policial", "policial"),
|
||||
Pair("Político", "politico"),
|
||||
Pair("Pós-Apocalíptico", "pos-apocaliptico"),
|
||||
Pair("Psico", "psico"),
|
||||
Pair("Psicológico", "psicologico"),
|
||||
Pair("Romance", "romance"),
|
||||
Pair("Samurai", "samurai"),
|
||||
Pair("Samurais", "samurais"),
|
||||
Pair("Sátiro", "satiro"),
|
||||
Pair("School Life", "school-life"),
|
||||
Pair("SciFi", "scifi"),
|
||||
Pair("Sci-Fi", "sci-fi"),
|
||||
Pair("Seinen", "seinen"),
|
||||
Pair("Shotacon", "shotacon"),
|
||||
Pair("Shoujo", "shoujo"),
|
||||
Pair("Shoujo Ai", "shoujo-ai"),
|
||||
Pair("Shounem", "shounem"),
|
||||
Pair("Shounen", "shounen"),
|
||||
Pair("Shounen-ai", "shounen-ai"),
|
||||
Pair("Slice of Life", "slice-of-life"),
|
||||
Pair("Sobrenatural", "sobrenatural"),
|
||||
Pair("Space", "space"),
|
||||
Pair("Supernatural", "supernatural"),
|
||||
Pair("Super Poder", "super-poder"),
|
||||
Pair("Super-Poderes", "super-poderes"),
|
||||
Pair("Suspense", "suspense"),
|
||||
Pair("tear-studio", "tear-studio"),
|
||||
Pair("Terror", "terror"),
|
||||
Pair("Thriller", "thriller"),
|
||||
Pair("Tragédia", "tragedia"),
|
||||
Pair("Vampiro", "vampiro"),
|
||||
Pair("Vampiros", "vampiros"),
|
||||
Pair("Vida Escolar", "vida-escolar"),
|
||||
Pair("Yaoi", "yaoi"),
|
||||
Pair("Yuri", "yuri"),
|
||||
Pair("Zombie", "zombie"),
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,290 @@
|
|||
package eu.kanade.tachiyomi.animeextension.pt.animestc
|
||||
|
||||
import android.app.Application
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animestc.dto.AnimeDto
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animestc.dto.EpisodeDto
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animestc.dto.ResponseDto
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animestc.dto.VideoDto
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animestc.extractors.LinkBypasser
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animestc.extractors.SendcmExtractor
|
||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||
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.lib.googledriveextractor.GoogleDriveExtractor
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.awaitSuccess
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import eu.kanade.tachiyomi.util.parallelCatchingFlatMapBlocking
|
||||
import eu.kanade.tachiyomi.util.parseAs
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
class AnimesTC : ConfigurableAnimeSource, AnimeHttpSource() {
|
||||
|
||||
override val name = "AnimesTC"
|
||||
|
||||
override val baseUrl = "https://api2.animestc.com"
|
||||
|
||||
override val lang = "pt-BR"
|
||||
|
||||
override val supportsLatest = true
|
||||
|
||||
override fun headersBuilder() = super.headersBuilder()
|
||||
.add("Referer", "$HOST_URL/")
|
||||
|
||||
private val preferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
// ============================== Popular ===============================
|
||||
override fun popularAnimeRequest(page: Int) = GET("$baseUrl/series?order=id&direction=asc&page=1&top=true", headers)
|
||||
|
||||
override fun popularAnimeParse(response: Response): AnimesPage {
|
||||
val data = response.parseAs<List<AnimeDto>>()
|
||||
val animes = data.map(::searchAnimeFromObject)
|
||||
return AnimesPage(animes, false)
|
||||
}
|
||||
|
||||
// =============================== Latest ===============================
|
||||
override fun latestUpdatesRequest(page: Int) = GET(HOST_URL, headers)
|
||||
|
||||
override fun latestUpdatesParse(response: Response): AnimesPage {
|
||||
val doc = response.asJsoup()
|
||||
val animes = doc.select("div > article.episode").map {
|
||||
SAnime.create().apply {
|
||||
val ahref = it.selectFirst("h3 > a.episode-info-title-orange")!!
|
||||
title = ahref.text()
|
||||
val slug = ahref.attr("href").substringAfterLast("/")
|
||||
setUrlWithoutDomain("/series?slug=$slug")
|
||||
thumbnail_url = it.selectFirst("img.episode-image")?.attr("abs:data-src")
|
||||
}
|
||||
}
|
||||
.filter { it.thumbnail_url?.contains("/_nuxt/img/") == false }
|
||||
.distinctBy { it.url }
|
||||
|
||||
return AnimesPage(animes, false)
|
||||
}
|
||||
|
||||
// =============================== Search ===============================
|
||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
|
||||
val params = ATCFilters.getSearchParameters(filters)
|
||||
val url = "$baseUrl/series?order=title&direction=asc&page=$page".toHttpUrl()
|
||||
.newBuilder()
|
||||
.addQueryParameter("type", params.type)
|
||||
.addQueryParameter("search", query)
|
||||
.addQueryParameter("year", params.year)
|
||||
.addQueryParameter("releaseStatus", params.status)
|
||||
.addQueryParameter("tag", params.genre)
|
||||
.build()
|
||||
|
||||
return GET(url, headers)
|
||||
}
|
||||
|
||||
override fun searchAnimeParse(response: Response): AnimesPage {
|
||||
val data = response.parseAs<ResponseDto<AnimeDto>>()
|
||||
val animes = data.items.map(::searchAnimeFromObject)
|
||||
val hasNextPage = data.lastPage > data.page
|
||||
return AnimesPage(animes, hasNextPage)
|
||||
}
|
||||
|
||||
override suspend fun getSearchAnime(page: Int, query: String, filters: AnimeFilterList): AnimesPage {
|
||||
return if (query.startsWith(PREFIX_SEARCH)) { // URL intent handler
|
||||
val slug = query.removePrefix(PREFIX_SEARCH)
|
||||
client.newCall(GET("$baseUrl/series?slug=$slug"))
|
||||
.awaitSuccess()
|
||||
.use(::searchAnimeBySlugParse)
|
||||
} else {
|
||||
return super.getSearchAnime(page, query, filters)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFilterList(): AnimeFilterList = ATCFilters.FILTER_LIST
|
||||
|
||||
private fun searchAnimeFromObject(anime: AnimeDto) = SAnime.create().apply {
|
||||
thumbnail_url = anime.cover.url
|
||||
title = anime.title
|
||||
setUrlWithoutDomain("/series/${anime.id}")
|
||||
}
|
||||
|
||||
private fun searchAnimeBySlugParse(response: Response): AnimesPage {
|
||||
val details = animeDetailsParse(response)
|
||||
return AnimesPage(listOf(details), false)
|
||||
}
|
||||
|
||||
// =========================== Anime Details ============================
|
||||
override fun animeDetailsParse(response: Response) = SAnime.create().apply {
|
||||
val anime = response.getAnimeDto()
|
||||
setUrlWithoutDomain("/series/${anime.id}")
|
||||
title = anime.title
|
||||
status = anime.status
|
||||
thumbnail_url = anime.cover.url
|
||||
artist = anime.producer
|
||||
genre = anime.genres
|
||||
description = buildString {
|
||||
append(anime.synopsis + "\n")
|
||||
|
||||
anime.classification?.also { append("\nClassificação: ", it, " anos") }
|
||||
anime.year?.also { append("\nAno de lançamento: ", it) }
|
||||
}
|
||||
}
|
||||
|
||||
// ============================== Episodes ==============================
|
||||
override fun episodeListParse(response: Response): List<SEpisode> {
|
||||
val id = response.getAnimeDto().id
|
||||
return getEpisodeList(id)
|
||||
}
|
||||
|
||||
private fun episodeListRequest(animeId: Int, page: Int) =
|
||||
GET("$baseUrl/episodes?order=id&direction=desc&page=$page&seriesId=$animeId&specialOrder=true")
|
||||
|
||||
private fun getEpisodeList(animeId: Int, page: Int = 1): List<SEpisode> {
|
||||
val response = client.newCall(episodeListRequest(animeId, page)).execute()
|
||||
val parsed = response.parseAs<ResponseDto<EpisodeDto>>()
|
||||
val episodes = parsed.items.map(::episodeFromObject)
|
||||
|
||||
if (parsed.page < parsed.lastPage) {
|
||||
return episodes + getEpisodeList(animeId, page + 1)
|
||||
} else {
|
||||
return episodes
|
||||
}
|
||||
}
|
||||
|
||||
private fun episodeFromObject(episode: EpisodeDto) = SEpisode.create().apply {
|
||||
name = episode.title
|
||||
setUrlWithoutDomain("/episodes?slug=${episode.slug}")
|
||||
episode_number = episode.number.toFloat()
|
||||
date_upload = episode.created_at.toDate()
|
||||
}
|
||||
|
||||
// ============================ Video Links =============================
|
||||
private val sendcmExtractor by lazy { SendcmExtractor(client) }
|
||||
private val gdriveExtractor by lazy { GoogleDriveExtractor(client, headers) }
|
||||
private val linkBypasser by lazy { LinkBypasser(client, json) }
|
||||
|
||||
private val supportedPlayers = listOf("send", "drive")
|
||||
|
||||
override fun videoListParse(response: Response): List<Video> {
|
||||
val videoDto = response.parseAs<ResponseDto<VideoDto>>().items.first()
|
||||
val links = videoDto.links
|
||||
|
||||
val allLinks = listOf(links.low, links.medium, links.high).flatten()
|
||||
.filter { it.name in supportedPlayers }
|
||||
|
||||
val online = links.online?.run {
|
||||
filterNot { "mega" in it }.map {
|
||||
Video(it, "Player ATC", it, headers)
|
||||
}
|
||||
}.orEmpty()
|
||||
|
||||
val videoId = videoDto.id
|
||||
|
||||
return online + allLinks.parallelCatchingFlatMapBlocking { extractVideosFromLink(it, videoId) }
|
||||
}
|
||||
|
||||
private fun extractVideosFromLink(video: VideoDto.VideoLink, videoId: Int): List<Video> {
|
||||
val playerUrl = linkBypasser.bypass(video, videoId)
|
||||
?: return emptyList()
|
||||
|
||||
val quality = when (video.quality) {
|
||||
"low" -> "SD"
|
||||
"medium" -> "HD"
|
||||
"high" -> "FULLHD"
|
||||
else -> "SD"
|
||||
}
|
||||
|
||||
return when (video.name) {
|
||||
"send" -> sendcmExtractor.videosFromUrl(playerUrl, quality)
|
||||
"drive" -> {
|
||||
val id = GDRIVE_REGEX.find(playerUrl)?.groupValues?.get(0) ?: return emptyList()
|
||||
gdriveExtractor.videosFromUrl(id, "GDrive - $quality")
|
||||
}
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
// ============================== Settings ==============================
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
ListPreference(screen.context).apply {
|
||||
key = PREF_QUALITY_KEY
|
||||
title = PREF_QUALITY_TITLE
|
||||
entries = PREF_QUALITY_ENTRIES
|
||||
entryValues = PREF_QUALITY_ENTRIES
|
||||
setDefaultValue(PREF_QUALITY_DEFAULT)
|
||||
summary = "%s"
|
||||
}.also(screen::addPreference)
|
||||
|
||||
ListPreference(screen.context).apply {
|
||||
key = PREF_PLAYER_KEY
|
||||
title = PREF_PLAYER_TITLE
|
||||
entries = PREF_PLAYER_VALUES
|
||||
entryValues = PREF_PLAYER_VALUES
|
||||
setDefaultValue(PREF_PLAYER_DEFAULT)
|
||||
summary = "%s"
|
||||
}.also(screen::addPreference)
|
||||
}
|
||||
|
||||
// ============================= Utilities ==============================
|
||||
private fun Response.getAnimeDto(): AnimeDto {
|
||||
val jsonString = body.string()
|
||||
return try {
|
||||
jsonString.parseAs<AnimeDto>()
|
||||
} catch (e: Exception) {
|
||||
// URL intent handler moment
|
||||
jsonString.parseAs<ResponseDto<AnimeDto>>().items.first()
|
||||
}
|
||||
}
|
||||
|
||||
private fun String.toDate(): Long {
|
||||
return try {
|
||||
DATE_FORMATTER.parse(this)?.time
|
||||
} catch (_: Throwable) { null } ?: 0L
|
||||
}
|
||||
|
||||
override fun List<Video>.sort(): List<Video> {
|
||||
val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!!
|
||||
val player = preferences.getString(PREF_PLAYER_KEY, PREF_PLAYER_DEFAULT)!!
|
||||
return sortedWith(
|
||||
compareBy(
|
||||
{ it.quality.contains(player) },
|
||||
{ it.quality.contains("- $quality") },
|
||||
),
|
||||
).reversed()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val DATE_FORMATTER by lazy {
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH)
|
||||
}
|
||||
|
||||
const val PREFIX_SEARCH = "slug:"
|
||||
|
||||
private const val HOST_URL = "https://www.animestc.net"
|
||||
|
||||
private const val PREF_QUALITY_KEY = "pref_quality"
|
||||
private const val PREF_QUALITY_TITLE = "Qualidade preferida"
|
||||
private const val PREF_QUALITY_DEFAULT = "HD"
|
||||
private val PREF_QUALITY_ENTRIES = arrayOf("SD", "HD", "FULLHD")
|
||||
|
||||
private const val PREF_PLAYER_KEY = "pref_player"
|
||||
private const val PREF_PLAYER_TITLE = "Player preferido"
|
||||
private const val PREF_PLAYER_DEFAULT = "Sendcm"
|
||||
private val PREF_PLAYER_VALUES = arrayOf("Sendcm", "GDrive", "Player ATC")
|
||||
|
||||
private val GDRIVE_REGEX = Regex("[\\w-]{28,}")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package eu.kanade.tachiyomi.animeextension.pt.animestc
|
||||
|
||||
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://wwww.animestc.net/animes/<item> intents
|
||||
* and redirects them to the main Aniyomi process.
|
||||
*/
|
||||
class AnimesTCUrlActivity : 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 item = pathSegments[1]
|
||||
val mainIntent = Intent().apply {
|
||||
action = "eu.kanade.tachiyomi.ANIMESEARCH"
|
||||
putExtra("query", "${AnimesTC.PREFIX_SEARCH}$item")
|
||||
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,78 @@
|
|||
package eu.kanade.tachiyomi.animeextension.pt.animestc.dto
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ResponseDto<T>(
|
||||
@SerialName("data")
|
||||
val items: List<T>,
|
||||
val lastPage: Int,
|
||||
val page: Int,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class AnimeDto(
|
||||
val classification: String?,
|
||||
val cover: CoverDto,
|
||||
val id: Int,
|
||||
val producer: String?,
|
||||
val releaseStatus: String,
|
||||
val synopsis: String,
|
||||
val tags: List<TagDto>,
|
||||
val title: String,
|
||||
val year: Int?,
|
||||
) {
|
||||
val status by lazy {
|
||||
when (releaseStatus) {
|
||||
"complete" -> SAnime.COMPLETED
|
||||
"airing" -> SAnime.ONGOING
|
||||
else -> SAnime.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
val genres by lazy { tags.joinToString(", ") { it.name } }
|
||||
|
||||
@Serializable
|
||||
data class TagDto(val name: String)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class EpisodeDto(
|
||||
@SerialName("seriesId")
|
||||
val animeId: Int,
|
||||
val cover: CoverDto?,
|
||||
val created_at: String,
|
||||
val number: String,
|
||||
val slug: String,
|
||||
val title: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class VideoDto(
|
||||
val id: Int,
|
||||
val links: VideoLinksDto,
|
||||
) {
|
||||
@Serializable
|
||||
data class VideoLinksDto(
|
||||
val low: List<VideoLink> = emptyList(),
|
||||
val medium: List<VideoLink> = emptyList(),
|
||||
val high: List<VideoLink> = emptyList(),
|
||||
val online: List<String>? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class VideoLink(
|
||||
val index: Int,
|
||||
val name: String,
|
||||
val quality: String,
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class CoverDto(
|
||||
val originalName: String,
|
||||
) {
|
||||
val url by lazy { "https://stc.animestc.com/$originalName" }
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package eu.kanade.tachiyomi.animeextension.pt.animestc.extractors
|
||||
|
||||
import android.util.Base64
|
||||
import eu.kanade.tachiyomi.animeextension.pt.animestc.dto.VideoDto.VideoLink
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class LinkBypasser(
|
||||
private val client: OkHttpClient,
|
||||
private val json: Json,
|
||||
) {
|
||||
fun bypass(video: VideoLink, episodeId: Int): String? {
|
||||
val joined = "$episodeId/${video.quality}/${video.index}"
|
||||
val encoded = Base64.encodeToString(joined.toByteArray(), Base64.NO_WRAP)
|
||||
val url = "$PROTECTOR_URL/link/$encoded"
|
||||
val res = client.newCall(GET(url)).execute()
|
||||
if (res.code != 200) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Sadly we MUST wait 6s or we are going to get a HTTP 500
|
||||
Thread.sleep(6000L)
|
||||
val id = res.asJsoup().selectFirst("meta#link-id")!!.attr("value")
|
||||
val apiCall = client.newCall(GET("$PROTECTOR_URL/api/link/$id")).execute()
|
||||
if (apiCall.code != 200) {
|
||||
return null
|
||||
}
|
||||
|
||||
val apiBody = apiCall.body.string()
|
||||
return json.decodeFromString<LinkDto>(apiBody).link
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class LinkDto(val link: String)
|
||||
|
||||
companion object {
|
||||
private const val PROTECTOR_URL = "https://protetor.animestc.xyz"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package eu.kanade.tachiyomi.animeextension.pt.animestc.extractors
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class SendcmExtractor(private val client: OkHttpClient) {
|
||||
private val playerName = "Sendcm"
|
||||
|
||||
fun videosFromUrl(url: String, quality: String): List<Video> {
|
||||
val doc = client.newCall(GET(url)).execute().asJsoup()
|
||||
val videoUrl = doc.selectFirst("video#vjsplayer > source")?.attr("src")
|
||||
return videoUrl?.let {
|
||||
val headers = Headers.headersOf("Referer", url)
|
||||
listOf(Video(it, "$playerName - $quality", it, headers = headers))
|
||||
}.orEmpty()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue