Initial commit
This commit is contained in:
commit
98ed7e8839
2263 changed files with 108711 additions and 0 deletions
22
src/fr/animesama/AndroidManifest.xml
Normal file
22
src/fr/animesama/AndroidManifest.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application>
|
||||
<activity
|
||||
android:name=".fr.animesama.AnimeSamaUrlActivity"
|
||||
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="anime-sama.fr"
|
||||
android:pathPattern="/catalogue/..*"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
13
src/fr/animesama/build.gradle
Normal file
13
src/fr/animesama/build.gradle
Normal file
|
@ -0,0 +1,13 @@
|
|||
ext {
|
||||
extName = 'Anime-Sama'
|
||||
extClass = '.AnimeSama'
|
||||
extVersionCode = 9
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
||||
dependencies {
|
||||
implementation(project(':lib:sibnet-extractor'))
|
||||
implementation(project(':lib:vk-extractor'))
|
||||
implementation(project(':lib:sendvid-extractor'))
|
||||
}
|
BIN
src/fr/animesama/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
src/fr/animesama/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
BIN
src/fr/animesama/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
src/fr/animesama/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
BIN
src/fr/animesama/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
src/fr/animesama/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
BIN
src/fr/animesama/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
src/fr/animesama/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
BIN
src/fr/animesama/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
src/fr/animesama/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
src/fr/animesama/res/web_hi_res_512.png
Normal file
BIN
src/fr/animesama/res/web_hi_res_512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 65 KiB |
|
@ -0,0 +1,295 @@
|
|||
package eu.kanade.tachiyomi.animeextension.fr.animesama
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceScreen
|
||||
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.sendvidextractor.SendvidExtractor
|
||||
import eu.kanade.tachiyomi.lib.sibnetextractor.SibnetExtractor
|
||||
import eu.kanade.tachiyomi.lib.vkextractor.VkExtractor
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import eu.kanade.tachiyomi.util.parallelCatchingFlatMap
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class AnimeSama : ConfigurableAnimeSource, AnimeHttpSource() {
|
||||
|
||||
override val name = "Anime-Sama"
|
||||
|
||||
override val baseUrl = "https://anime-sama.fr"
|
||||
|
||||
override val lang = "fr"
|
||||
|
||||
override val supportsLatest = true
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
private val database by lazy {
|
||||
client.newCall(GET("$baseUrl/catalogue/listing_all.php", headers)).execute()
|
||||
.asJsoup().select(".cardListAnime")
|
||||
}
|
||||
|
||||
// ============================== Popular ===============================
|
||||
override fun popularAnimeParse(response: Response): AnimesPage {
|
||||
val doc = response.body.string()
|
||||
val page = response.request.url.fragment?.toInt() ?: 0
|
||||
val regex = Regex("^\\s*carteClassique\\(\\s*.*?\\s*,\\s*\"(.*?)\".*\\)", RegexOption.MULTILINE)
|
||||
val chunks = regex.findAll(doc).chunked(5).toList()
|
||||
val seasons = chunks.getOrNull(page - 1)?.flatMap {
|
||||
val animeUrl = "$baseUrl/catalogue/${it.groupValues[1]}"
|
||||
fetchAnimeSeasons(animeUrl)
|
||||
}?.toList().orEmpty()
|
||||
return AnimesPage(seasons, page < chunks.size)
|
||||
}
|
||||
|
||||
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/#$page")
|
||||
|
||||
// =============================== Latest ===============================
|
||||
override fun latestUpdatesParse(response: Response): AnimesPage {
|
||||
val animes = response.asJsoup()
|
||||
val seasons = animes.select("h2:contains(derniers ajouts) + .scrollBarStyled > div").flatMap {
|
||||
val animeUrl = it.getElementsByTag("a").attr("href")
|
||||
fetchAnimeSeasons(animeUrl)
|
||||
}
|
||||
return AnimesPage(seasons, false)
|
||||
}
|
||||
override fun latestUpdatesRequest(page: Int): Request = GET(baseUrl)
|
||||
|
||||
// =============================== Search ===============================
|
||||
override fun getFilterList() = AnimeSamaFilters.FILTER_LIST
|
||||
|
||||
override suspend fun getSearchAnime(page: Int, query: String, filters: AnimeFilterList): AnimesPage {
|
||||
if (query.startsWith(PREFIX_SEARCH)) {
|
||||
return AnimesPage(fetchAnimeSeasons("$baseUrl/catalogue/${query.removePrefix(PREFIX_SEARCH)}/"), false)
|
||||
}
|
||||
val params = AnimeSamaFilters.getSearchFilters(filters)
|
||||
val elements = database
|
||||
.asSequence()
|
||||
.filter { it.select("h1, p").fold(false) { v, e -> v || e.text().contains(query, true) } }
|
||||
.filter { params.include.all { p -> it.className().contains(p) } }
|
||||
.filter { params.exclude.none { p -> it.className().contains(p) } }
|
||||
.filter { params.types.fold(params.types.isEmpty()) { v, p -> v || it.className().contains(p) } }
|
||||
.filter { params.language.fold(params.language.isEmpty()) { v, p -> v || it.className().contains(p) } }
|
||||
.chunked(5)
|
||||
.toList()
|
||||
if (elements.isEmpty()) return AnimesPage(emptyList(), false)
|
||||
val animes = elements[page - 1].flatMap {
|
||||
fetchAnimeSeasons(it.getElementsByTag("a").attr("href"))
|
||||
}
|
||||
return AnimesPage(animes, page < elements.size)
|
||||
}
|
||||
|
||||
override fun searchAnimeParse(response: Response): AnimesPage = throw UnsupportedOperationException()
|
||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request = throw UnsupportedOperationException()
|
||||
|
||||
// =========================== Anime Details ============================
|
||||
override suspend fun getAnimeDetails(anime: SAnime): SAnime = anime
|
||||
|
||||
override fun animeDetailsParse(response: Response): SAnime = throw UnsupportedOperationException()
|
||||
|
||||
// ============================== Episodes ==============================
|
||||
override suspend fun getEpisodeList(anime: SAnime): List<SEpisode> {
|
||||
val animeUrl = "$baseUrl${anime.url.substringBeforeLast("/")}"
|
||||
val movie = anime.url.split("#").getOrElse(1) { "" }.toIntOrNull()
|
||||
val players = VOICES_VALUES.map { fetchPlayers("$animeUrl/$it") }
|
||||
val episodes = playersToEpisodes(players)
|
||||
return if (movie == null) episodes.reversed() else listOf(episodes[movie])
|
||||
}
|
||||
|
||||
override fun episodeListParse(response: Response): List<SEpisode> = throw UnsupportedOperationException()
|
||||
|
||||
// ============================ Video Links =============================
|
||||
override suspend fun getVideoList(episode: SEpisode): List<Video> {
|
||||
val playerUrls = json.decodeFromString<List<List<String>>>(episode.url)
|
||||
val videos = playerUrls.flatMapIndexed { i, it ->
|
||||
val prefix = "(${VOICES_VALUES[i].uppercase()}) "
|
||||
it.parallelCatchingFlatMap { playerUrl ->
|
||||
with(playerUrl) {
|
||||
when {
|
||||
contains("sibnet.ru") -> SibnetExtractor(client).videosFromUrl(playerUrl, prefix)
|
||||
contains("vk.") -> VkExtractor(client, headers).videosFromUrl(playerUrl, prefix)
|
||||
contains("sendvid.com") -> SendvidExtractor(client, headers).videosFromUrl(playerUrl, prefix)
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}.sort()
|
||||
return videos
|
||||
}
|
||||
|
||||
// ============================ Utils =============================
|
||||
private fun sanitizeEpisodesJs(doc: String) = doc
|
||||
.replace(Regex("[\"\t]"), "") // Fix trash format
|
||||
.replace("'", "\"") // Fix quotes
|
||||
.replace(Regex("/\\*.*?\\*/", setOf(RegexOption.MULTILINE, RegexOption.DOT_MATCHES_ALL)), "") // Remove block comments
|
||||
.replace(Regex("(^|,|\\[)\\s*//.*?$", RegexOption.MULTILINE), "$1") // Remove line comments
|
||||
.replace(Regex(",\\s*]"), "]") // Remove trailing comma
|
||||
|
||||
override fun List<Video>.sort(): List<Video> {
|
||||
val voices = preferences.getString(PREF_VOICES_KEY, PREF_VOICES_DEFAULT)!!
|
||||
val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!!
|
||||
|
||||
return this.sortedWith(
|
||||
compareBy(
|
||||
{ it.quality.contains(voices, true) },
|
||||
{ it.quality.contains(quality) },
|
||||
),
|
||||
).reversed()
|
||||
}
|
||||
|
||||
private fun fetchAnimeSeasons(animeUrl: String): List<SAnime> {
|
||||
val res = client.newCall(GET(animeUrl)).execute()
|
||||
return fetchAnimeSeasons(res)
|
||||
}
|
||||
|
||||
private fun fetchAnimeSeasons(response: Response): List<SAnime> {
|
||||
val animeDoc = response.asJsoup()
|
||||
val animeUrl = response.request.url
|
||||
val animeName = animeDoc.getElementById("titreOeuvre")?.text() ?: ""
|
||||
|
||||
val seasonRegex = Regex("^\\s*panneauAnime\\(\"(.*)\", \"(.*)\"\\)", RegexOption.MULTILINE)
|
||||
val scripts = animeDoc.select("h2 + p + div > script, h2 + div > script").toString()
|
||||
val animes = seasonRegex.findAll(scripts).flatMapIndexed { animeIndex, seasonMatch ->
|
||||
val (seasonName, seasonStem) = seasonMatch.destructured
|
||||
if (seasonStem.contains("film", true)) {
|
||||
val moviesUrl = "$animeUrl/$seasonStem"
|
||||
val movies = fetchPlayers(moviesUrl).ifEmpty { return@flatMapIndexed emptyList() }
|
||||
val movieNameRegex = Regex("^\\s*newSPF\\(\"(.*)\"\\);", RegexOption.MULTILINE)
|
||||
val moviesDoc = client.newCall(GET(moviesUrl)).execute().body.string()
|
||||
val matches = movieNameRegex.findAll(moviesDoc).toList()
|
||||
List(movies.size) { i ->
|
||||
val title = when {
|
||||
animeIndex == 0 && movies.size == 1 -> animeName
|
||||
matches.size > i -> "$animeName ${matches[i].destructured.component1()}"
|
||||
movies.size == 1 -> "$animeName Film"
|
||||
else -> "$animeName Film ${i + 1}"
|
||||
}
|
||||
Triple(title, "$moviesUrl#$i", SAnime.COMPLETED)
|
||||
}
|
||||
} else {
|
||||
listOf(Triple("$animeName $seasonName", "$animeUrl/$seasonStem", SAnime.UNKNOWN))
|
||||
}
|
||||
}
|
||||
|
||||
return animes.map {
|
||||
SAnime.create().apply {
|
||||
title = it.first
|
||||
thumbnail_url = animeDoc.getElementById("coverOeuvre")?.attr("src")
|
||||
description = animeDoc.select("h2:contains(synopsis) + p").text()
|
||||
genre = animeDoc.select("h2:contains(genres) + a").text()
|
||||
setUrlWithoutDomain(it.second)
|
||||
status = it.third
|
||||
initialized = true
|
||||
}
|
||||
}.toList()
|
||||
}
|
||||
|
||||
private fun playersToEpisodes(list: List<List<List<String>>>): List<SEpisode> =
|
||||
List(list.fold(0) { acc, it -> maxOf(acc, it.size) }) { episodeNumber ->
|
||||
val players = list.map { it.getOrElse(episodeNumber) { emptyList() } }
|
||||
SEpisode.create().apply {
|
||||
name = "Episode ${episodeNumber + 1}"
|
||||
url = json.encodeToString(players)
|
||||
episode_number = (episodeNumber + 1).toFloat()
|
||||
scanlator = players.mapIndexedNotNull { i, it -> if (it.isNotEmpty()) VOICES_VALUES[i] else null }.joinToString().uppercase()
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchPlayers(url: String): List<List<String>> {
|
||||
val docUrl = "$url/episodes.js"
|
||||
val players = mutableListOf<List<String>>()
|
||||
val doc = client.newCall(GET(docUrl)).execute().run {
|
||||
if (code != 200) {
|
||||
close()
|
||||
return listOf()
|
||||
}
|
||||
body.string()
|
||||
}
|
||||
val sanitizedDoc = sanitizeEpisodesJs(doc)
|
||||
for (i in 1..8) {
|
||||
val numPlayers = getPlayers("eps$i", sanitizedDoc)
|
||||
if (numPlayers != null) players.add(numPlayers)
|
||||
}
|
||||
val asPlayers = getPlayers("epsAS", sanitizedDoc)
|
||||
if (asPlayers != null) players.add(asPlayers)
|
||||
if (players.isEmpty()) return emptyList()
|
||||
return List(players[0].size) { i -> players.mapNotNull { it.getOrNull(i) }.distinct() }
|
||||
}
|
||||
|
||||
private fun getPlayers(playerName: String, doc: String): List<String>? {
|
||||
val playerRegex = Regex("$playerName\\s*=\\s*(\\[.*?])", RegexOption.DOT_MATCHES_ALL)
|
||||
val string = playerRegex.find(doc)?.groupValues?.get(1)
|
||||
return if (string != null) json.decodeFromString<List<String>>(string) else null
|
||||
}
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
ListPreference(screen.context).apply {
|
||||
key = PREF_QUALITY_KEY
|
||||
title = "Preferred quality"
|
||||
entries = arrayOf("1080p", "720p", "480p", "360p")
|
||||
entryValues = arrayOf("1080", "720", "480", "360")
|
||||
setDefaultValue(PREF_QUALITY_DEFAULT)
|
||||
summary = "%s"
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
val selected = newValue as String
|
||||
val index = findIndexOfValue(selected)
|
||||
val entry = entryValues[index] as String
|
||||
preferences.edit().putString(key, entry).commit()
|
||||
}
|
||||
}.also(screen::addPreference)
|
||||
|
||||
ListPreference(screen.context).apply {
|
||||
key = PREF_VOICES_KEY
|
||||
title = "Préférence des voix"
|
||||
entries = VOICES
|
||||
entryValues = VOICES_VALUES
|
||||
setDefaultValue(PREF_VOICES_DEFAULT)
|
||||
summary = "%s"
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
val selected = newValue as String
|
||||
val index = findIndexOfValue(selected)
|
||||
val entry = entryValues[index] as String
|
||||
preferences.edit().putString(key, entry).commit()
|
||||
}
|
||||
}.also(screen::addPreference)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val PREFIX_SEARCH = "id:"
|
||||
|
||||
private val VOICES = arrayOf(
|
||||
"Préférer VOSTFR",
|
||||
"Préférer VF",
|
||||
)
|
||||
|
||||
private val VOICES_VALUES = arrayOf(
|
||||
"vostfr",
|
||||
"vf",
|
||||
)
|
||||
|
||||
private const val PREF_VOICES_KEY = "voices_preference"
|
||||
private const val PREF_VOICES_DEFAULT = "vostfr"
|
||||
|
||||
private const val PREF_QUALITY_KEY = "preferred_quality"
|
||||
private const val PREF_QUALITY_DEFAULT = "1080"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package eu.kanade.tachiyomi.animeextension.fr.animesama
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilter
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
|
||||
object AnimeSamaFilters {
|
||||
|
||||
open class CheckBoxFilterList(name: String, values: List<CheckBox>) : AnimeFilter.Group<AnimeFilter.CheckBox>(name, values)
|
||||
|
||||
private class CheckBoxVal(name: String, state: Boolean = false) : AnimeFilter.CheckBox(name, state)
|
||||
|
||||
open class TriStateFilterList(name: String, values: List<TriFilter>) : AnimeFilter.Group<AnimeFilter.TriState>(name, values)
|
||||
|
||||
class TriFilter(name: String) : AnimeFilter.TriState(name)
|
||||
|
||||
private inline fun <reified R> AnimeFilterList.getFirst(): R {
|
||||
return this.filterIsInstance<R>().first()
|
||||
}
|
||||
|
||||
private inline fun <reified R> AnimeFilterList.parseCheckbox(
|
||||
options: Array<Pair<String, String>>,
|
||||
): List<String> {
|
||||
return (this.getFirst<R>() as CheckBoxFilterList).state
|
||||
.mapNotNull { checkbox ->
|
||||
if (checkbox.state) {
|
||||
options.find { it.first == checkbox.name }!!.second
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun <reified R> AnimeFilterList.parseTriFilter(
|
||||
options: Array<Pair<String, String>>,
|
||||
): List<List<String>> {
|
||||
return (this.getFirst<R>() as TriStateFilterList).state
|
||||
.filterNot { it.isIgnored() }
|
||||
.map { filter -> filter.state to filter.name }
|
||||
.groupBy { it.first }
|
||||
.let {
|
||||
val included = it.get(AnimeFilter.TriState.STATE_INCLUDE)?.map { options.find { o -> o.first == it.second }!!.second } ?: emptyList()
|
||||
val excluded = it.get(AnimeFilter.TriState.STATE_EXCLUDE)?.map { options.find { o -> o.first == it.second }!!.second } ?: emptyList()
|
||||
listOf(included, excluded)
|
||||
}
|
||||
}
|
||||
|
||||
class TypesFilter : CheckBoxFilterList(
|
||||
"Type",
|
||||
AnimeSamaFiltersData.TYPES.map { CheckBoxVal(it.first, false) },
|
||||
)
|
||||
|
||||
class LangFilter : CheckBoxFilterList(
|
||||
"Langage",
|
||||
AnimeSamaFiltersData.LANGUAGES.map { CheckBoxVal(it.first, false) },
|
||||
)
|
||||
|
||||
class GenresFilter : TriStateFilterList(
|
||||
"Genre",
|
||||
AnimeSamaFiltersData.GENRES.map { TriFilter(it.first) },
|
||||
)
|
||||
|
||||
val FILTER_LIST get() = AnimeFilterList(
|
||||
TypesFilter(),
|
||||
LangFilter(),
|
||||
GenresFilter(),
|
||||
)
|
||||
|
||||
data class SearchFilters(
|
||||
val types: List<String> = emptyList(),
|
||||
val language: List<String> = emptyList(),
|
||||
val include: List<String> = emptyList(),
|
||||
val exclude: List<String> = emptyList(),
|
||||
)
|
||||
|
||||
fun getSearchFilters(filters: AnimeFilterList): SearchFilters {
|
||||
if (filters.isEmpty()) return SearchFilters()
|
||||
val (include, exclude) = filters.parseTriFilter<GenresFilter>(AnimeSamaFiltersData.GENRES)
|
||||
|
||||
return SearchFilters(
|
||||
filters.parseCheckbox<TypesFilter>(AnimeSamaFiltersData.TYPES),
|
||||
filters.parseCheckbox<LangFilter>(AnimeSamaFiltersData.LANGUAGES),
|
||||
include,
|
||||
exclude,
|
||||
)
|
||||
}
|
||||
|
||||
private object AnimeSamaFiltersData {
|
||||
val TYPES = arrayOf(
|
||||
Pair("Anime", "Anime"),
|
||||
Pair("Film", "Film"),
|
||||
Pair("Autres", "Autres"),
|
||||
)
|
||||
|
||||
val LANGUAGES = arrayOf(
|
||||
Pair("VF", "VF"),
|
||||
Pair("VOSTFR", "VOSTFR"),
|
||||
)
|
||||
|
||||
val GENRES = arrayOf(
|
||||
Pair("Action", "Action"),
|
||||
Pair("Aventure", "Aventure"),
|
||||
Pair("Combats", "Combats"),
|
||||
Pair("Comédie", "Comédie"),
|
||||
Pair("Drame", "Drame"),
|
||||
Pair("Ecchi", "Ecchi"),
|
||||
Pair("École", "School-Life"),
|
||||
Pair("Fantaisie", "Fantasy"),
|
||||
Pair("Horreur", "Horreur"),
|
||||
Pair("Isekai", "Isekai"),
|
||||
Pair("Josei", "Josei"),
|
||||
Pair("Mystère", "Mystère"),
|
||||
Pair("Psychologique", "Psychologique"),
|
||||
Pair("Quotidien", "Slice-of-Life"),
|
||||
Pair("Romance", "Romance"),
|
||||
Pair("Seinen", "Seinen"),
|
||||
Pair("Shônen", "Shônen"),
|
||||
Pair("Shôjo", "Shôjo"),
|
||||
Pair("Sports", "Sports"),
|
||||
Pair("Surnaturel", "Surnaturel"),
|
||||
Pair("Tournois", "Tournois"),
|
||||
Pair("Yaoi", "Yaoi"),
|
||||
Pair("Yuri", "Yuri"),
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package eu.kanade.tachiyomi.animeextension.fr.animesama
|
||||
|
||||
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 www.anime-sama.fr/anime/<item> intents
|
||||
* and redirects them to the main Aniyomi process.
|
||||
*/
|
||||
class AnimeSamaUrlActivity : 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", "${AnimeSama.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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue