diff --git a/src/fr/anisama/AndroidManifest.xml b/src/fr/anisama/AndroidManifest.xml new file mode 100644 index 0000000000..2a3e912449 --- /dev/null +++ b/src/fr/anisama/AndroidManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + diff --git a/src/fr/anisama/build.gradle b/src/fr/anisama/build.gradle new file mode 100644 index 0000000000..f323ce7749 --- /dev/null +++ b/src/fr/anisama/build.gradle @@ -0,0 +1,16 @@ +ext { + extName = 'AniSama' + extClass = '.AniSama' + extVersionCode = 1 +} + +apply from: "$rootDir/common.gradle" + +dependencies { + implementation(project(':lib:voe-extractor')) + implementation(project(':lib:sendvid-extractor')) + implementation(project(':lib:sibnet-extractor')) + implementation(project(':lib:filemoon-extractor')) + implementation(project(':lib:dood-extractor')) + implementation(project(':lib:streamhidevid-extractor')) +} \ No newline at end of file diff --git a/src/fr/anisama/res/mipmap-hdpi/ic_launcher.png b/src/fr/anisama/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..54bea320f6 Binary files /dev/null and b/src/fr/anisama/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/fr/anisama/res/mipmap-mdpi/ic_launcher.png b/src/fr/anisama/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..1adb79f327 Binary files /dev/null and b/src/fr/anisama/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/fr/anisama/res/mipmap-xhdpi/ic_launcher.png b/src/fr/anisama/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..60df84cd2d Binary files /dev/null and b/src/fr/anisama/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/fr/anisama/res/mipmap-xxhdpi/ic_launcher.png b/src/fr/anisama/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..9c62fe18fb Binary files /dev/null and b/src/fr/anisama/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/fr/anisama/res/mipmap-xxxhdpi/ic_launcher.png b/src/fr/anisama/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..ed8fb7c41a Binary files /dev/null and b/src/fr/anisama/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/fr/anisama/src/eu/kanade/tachiyomi/animeextension/fr/anisama/AniSama.kt b/src/fr/anisama/src/eu/kanade/tachiyomi/animeextension/fr/anisama/AniSama.kt new file mode 100644 index 0000000000..e5785d1a37 --- /dev/null +++ b/src/fr/anisama/src/eu/kanade/tachiyomi/animeextension/fr/anisama/AniSama.kt @@ -0,0 +1,345 @@ +package eu.kanade.tachiyomi.animeextension.fr.anisama + +import android.app.Application +import android.content.SharedPreferences +import androidx.preference.ListPreference +import androidx.preference.MultiSelectListPreference +import androidx.preference.PreferenceScreen +import eu.kanade.tachiyomi.animeextension.fr.anisama.extractors.VidCdnExtractor +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.ParsedAnimeHttpSource +import eu.kanade.tachiyomi.lib.doodextractor.DoodExtractor +import eu.kanade.tachiyomi.lib.filemoonextractor.FilemoonExtractor +import eu.kanade.tachiyomi.lib.sendvidextractor.SendvidExtractor +import eu.kanade.tachiyomi.lib.sibnetextractor.SibnetExtractor +import eu.kanade.tachiyomi.lib.streamhidevidextractor.StreamHideVidExtractor +import eu.kanade.tachiyomi.lib.voeextractor.VoeExtractor +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.parallelMapBlocking +import eu.kanade.tachiyomi.util.parseAs +import kotlinx.serialization.Serializable +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.Request +import okhttp3.Response +import org.jsoup.Jsoup +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element +import org.jsoup.select.Elements +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.api.get + +class AniSama : ParsedAnimeHttpSource(), ConfigurableAnimeSource { + + override val name = "AniSama" + + override val baseUrl = "https://fr.anisama.net" + + override val lang = "fr" + + override val supportsLatest = true + + private val aniSamaFilters by lazy { AniSamaFilters(baseUrl, client) } + + private val preferences: SharedPreferences by lazy { + Injekt.get().getSharedPreferences("source_$id", 0x0000) + } + + // ============================== Popular =============================== + override fun popularAnimeRequest(page: Int) = GET("$baseUrl/most-popular/?page=$page") + + override fun popularAnimeSelector() = ".film_list article" + + override fun popularAnimeFromElement(element: Element) = SAnime.create().apply { + title = element.select(".dynamic-name").text() + thumbnail_url = element.select(".film-poster-img").attr("data-src") + setUrlWithoutDomain(element.select(".film-poster-ahref").attr("href")) + } + + override fun popularAnimeNextPageSelector() = ".ap__-btn-next a:not(.disabled)" + + override fun popularAnimeParse(response: Response): AnimesPage { + aniSamaFilters.fetchFilters() + return super.popularAnimeParse(response) + } + + // =============================== Latest =============================== + override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/recently-added/?page=$page") + + override fun latestUpdatesSelector() = popularAnimeSelector() + + override fun latestUpdatesFromElement(element: Element) = popularAnimeFromElement(element) + + override fun latestUpdatesNextPageSelector() = popularAnimeNextPageSelector() + + override fun latestUpdatesParse(response: Response): AnimesPage { + aniSamaFilters.fetchFilters() + return super.latestUpdatesParse(response) + } + + // =============================== Search =============================== + override fun getFilterList() = aniSamaFilters.getFilterList() + + override suspend fun getSearchAnime(page: Int, query: String, filters: AnimeFilterList): AnimesPage { + return if (query.startsWith(PREFIX_SEARCH)) { // URL intent handler + val id = query.removePrefix(PREFIX_SEARCH) + client.newCall(GET("$baseUrl/anime/$id")).awaitSuccess().use(::searchAnimeByIdParse) + } else { + super.getSearchAnime(page, query, filters) + } + } + + private fun searchAnimeByIdParse(response: Response): AnimesPage { + val details = animeDetailsParse(response.asJsoup()) + .apply { setUrlWithoutDomain(response.request.url.toString()) } + return AnimesPage(listOf(details), false) + } + + override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request { + val url = "$baseUrl/filter".toHttpUrl().newBuilder() + url.addQueryParameter("keyword", query) + url.addQueryParameter("page", page.toString()) + filters.filterIsInstance().forEach { + val (name, value) = it.toQueryParameter() + if (value != null) url.addQueryParameter(name, value) + } + return GET(url.build()) + } + + override fun searchAnimeSelector() = popularAnimeSelector() + + override fun searchAnimeFromElement(element: Element) = popularAnimeFromElement(element) + + override fun searchAnimeNextPageSelector() = popularAnimeNextPageSelector() + + // =========================== Anime Details ============================ + private fun Elements.getMeta(name: String) = select(".item:has(.item-title:contains($name)) > .item-content") + + private fun parseStatus(status: String) = when (status) { + "Terminer" -> SAnime.COMPLETED + "En cours" -> SAnime.ONGOING + else -> SAnime.UNKNOWN + } + + override fun animeDetailsParse(document: Document): SAnime { + val details = document.select(".anime-detail") + return SAnime.create().apply { + title = details.select(".dynamic-name").text().substringBeforeLast(" ") + thumbnail_url = details.select(".film-poster-img").attr("src") + url = document.select("link[rel=canonical]").attr("href") + artist = details.getMeta("Studio").text() + status = parseStatus(details.getMeta("Status").text()) + description = details.select(".shorting").text() + genre = details.getMeta("Genre").text() + initialized = true + } + } + + // ============================== Episodes ============================== + override fun episodeListSelector() = ".ep-item" + + private fun SAnime.getId(): String = url.substringAfterLast("-") + + override fun episodeListRequest(anime: SAnime) = GET( + "$baseUrl/ajax/episode/list/${anime.getId()}", + headers.newBuilder().set("Referer", "$baseUrl${anime.url}").build(), + ) + + @Serializable + data class HtmlResponseDTO(val html: String) + + override fun episodeListParse(response: Response): List { + val document = Jsoup.parse(response.parseAs().html) + return document.select(episodeListSelector()).parallelMapBlocking(::episodeFromElement).reversed() + } + + override fun episodeFromElement(element: Element): SEpisode { + return SEpisode.create().apply { + episode_number = element.attr("data-number").toFloat() + name = element.attr("title") + val id = element.attr("href").substringAfterLast("=") + url = "/ajax/episode/servers?episodeId=$id" + } + } + + // ============================ Video Links ============================= + @Serializable + data class PlayerInfoDTO(val link: String) + + override fun videoListSelector() = ".server-item" + + private val filemoonExtractor by lazy { FilemoonExtractor(client) } + private val sibnetExtractor by lazy { SibnetExtractor(client) } + private val sendvidExtractor by lazy { SendvidExtractor(client, headers) } + private val voeExtractor by lazy { VoeExtractor(client) } + private val vidCdnExtractor by lazy { VidCdnExtractor(client) } + private val doodExtractor by lazy { DoodExtractor(client) } + private val streamHideVidExtractor by lazy { StreamHideVidExtractor(client) } + + override fun videoListRequest(episode: SEpisode) = GET( + "$baseUrl${episode.url}", + headers.newBuilder().set("Referer", "$baseUrl/").build(), + ) + + override fun videoListParse(response: Response): List