From 110f7c69f4076455cdc396e23e5076719399205e Mon Sep 17 00:00:00 2001 From: Dark25 Date: Sat, 3 Aug 2024 23:06:16 +0200 Subject: [PATCH] feat(fr/Vostfree): Add common video extractors + refactoration by hollow --- src/fr/vostfree/build.gradle | 10 +- .../animeextension/fr/vostfree/Vostfree.kt | 278 +++++++++--------- 2 files changed, 138 insertions(+), 150 deletions(-) diff --git a/src/fr/vostfree/build.gradle b/src/fr/vostfree/build.gradle index 2d02807292..996c73526c 100644 --- a/src/fr/vostfree/build.gradle +++ b/src/fr/vostfree/build.gradle @@ -1,13 +1,17 @@ ext { extName = 'Vostfree' extClass = '.Vostfree' - extVersionCode = 20 + extVersionCode = 21 } apply from: "$rootDir/common.gradle" dependencies { - implementation(project(':lib:vudeo-extractor')) implementation(project(':lib:dood-extractor')) + implementation(project(':lib:mixdrop-extractor')) implementation(project(':lib:okru-extractor')) -} \ No newline at end of file + implementation(project(':lib:sibnet-extractor')) + implementation(project(':lib:uqload-extractor')) + implementation(project(':lib:voe-extractor')) + implementation(project(':lib:vudeo-extractor')) +} diff --git a/src/fr/vostfree/src/eu/kanade/tachiyomi/animeextension/fr/vostfree/Vostfree.kt b/src/fr/vostfree/src/eu/kanade/tachiyomi/animeextension/fr/vostfree/Vostfree.kt index 142173ce98..92c3b3d1b9 100644 --- a/src/fr/vostfree/src/eu/kanade/tachiyomi/animeextension/fr/vostfree/Vostfree.kt +++ b/src/fr/vostfree/src/eu/kanade/tachiyomi/animeextension/fr/vostfree/Vostfree.kt @@ -1,7 +1,6 @@ package eu.kanade.tachiyomi.animeextension.fr.vostfree import android.app.Application -import android.content.SharedPreferences import androidx.preference.ListPreference import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource @@ -13,11 +12,17 @@ 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.mixdropextractor.MixDropExtractor import eu.kanade.tachiyomi.lib.okruextractor.OkruExtractor +import eu.kanade.tachiyomi.lib.sibnetextractor.SibnetExtractor +import eu.kanade.tachiyomi.lib.uqloadextractor.UqloadExtractor +import eu.kanade.tachiyomi.lib.voeextractor.VoeExtractor import eu.kanade.tachiyomi.lib.vudeoextractor.VudeoExtractor import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST +import eu.kanade.tachiyomi.network.await import eu.kanade.tachiyomi.util.asJsoup +import eu.kanade.tachiyomi.util.parallelCatchingFlatMap import okhttp3.FormBody import okhttp3.Request import okhttp3.Response @@ -25,7 +30,6 @@ import org.jsoup.nodes.Document import org.jsoup.nodes.Element import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -import java.lang.Exception class Vostfree : ConfigurableAnimeSource, ParsedAnimeHttpSource() { @@ -37,117 +41,35 @@ class Vostfree : ConfigurableAnimeSource, ParsedAnimeHttpSource() { override val supportsLatest = false - private val preferences: SharedPreferences by lazy { + private val preferences by lazy { Injekt.get().getSharedPreferences("source_$id", 0x0000) } - override fun popularAnimeSelector(): String = "div#page-content div.page-left div#content div#dle-content div.movie-poster" + // ============================== Popular =============================== + override fun popularAnimeSelector() = "div#dle-content div.movie-poster" - override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/films-vf-vostfr/page/$page/") + override fun popularAnimeRequest(page: Int) = GET("$baseUrl/films-vf-vostfr/page/$page/") - override fun popularAnimeFromElement(element: Element): SAnime { - val anime = SAnime.create() - anime.setUrlWithoutDomain( - element.select("div.movie-poster div.play a").attr("href"), - ) - anime.title = element.select("div.movie-poster div.info.hidden div.title").text() - anime.thumbnail_url = baseUrl + element.select("div.movie-poster span.image img").attr("src") - return anime - } - - override fun popularAnimeNextPageSelector(): String = "span.next-page" - - override fun episodeListParse(response: Response): List { - val episodes = mutableListOf() - val jsoup = response.asJsoup() - jsoup.select("select.new_player_selector option").forEachIndexed { index, it -> - val epNum = it.text().replace("Episode", "").drop(2) - - if (it.text() == "Film") { - val episode = SEpisode.create().apply { - episode_number = "1".toFloat() - name = "Film" - } - episode.url = "?episode:0/${response.request.url}" - episodes.add(episode) - } else { - val episode = SEpisode.create().apply { - episode_number = epNum.toFloat() - name = "Épisode $epNum" - } - episode.setUrlWithoutDomain("?episode:$index/${response.request.url}") - episodes.add(episode) - } + override fun popularAnimeFromElement(element: Element) = SAnime.create().apply { + with(element.selectFirst("a")!!) { + setUrlWithoutDomain(attr("href")) + title = text() } - - return episodes + thumbnail_url = element.selectFirst("span.image img")?.absUrl("src") } - override fun episodeListSelector() = throw UnsupportedOperationException() - - override fun episodeFromElement(element: Element) = throw UnsupportedOperationException() + override fun popularAnimeNextPageSelector() = "span.next-page" - override fun videoListParse(response: Response): List