From 56b0b09b544df76947bdd9e09ba45fbc2680e5e0 Mon Sep 17 00:00:00 2001 From: Claudemirovsky <63046606+Claudemirovsky@users.noreply.github.com> Date: Fri, 24 Nov 2023 06:39:01 -0300 Subject: [PATCH 01/13] feat: Start rewriting process --- src/en/hstream/AndroidManifest.xml | 22 +++ src/en/hstream/build.gradle | 15 ++ .../animeextension/en/hstream/Hstream.kt | 129 ++++++++++++++++++ .../en/hstream/HstreamUrlActivity.kt | 41 ++++++ 4 files changed, 207 insertions(+) create mode 100644 src/en/hstream/AndroidManifest.xml create mode 100644 src/en/hstream/build.gradle create mode 100644 src/en/hstream/src/eu/kanade/tachiyomi/animeextension/en/hstream/Hstream.kt create mode 100644 src/en/hstream/src/eu/kanade/tachiyomi/animeextension/en/hstream/HstreamUrlActivity.kt diff --git a/src/en/hstream/AndroidManifest.xml b/src/en/hstream/AndroidManifest.xml new file mode 100644 index 0000000000..fc9fac50e1 --- /dev/null +++ b/src/en/hstream/AndroidManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + diff --git a/src/en/hstream/build.gradle b/src/en/hstream/build.gradle new file mode 100644 index 0000000000..c0455dc2d7 --- /dev/null +++ b/src/en/hstream/build.gradle @@ -0,0 +1,15 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) +} + +ext { + extName = 'Hstream' + pkgNameSuffix = 'en.hstream' + extClass = '.Hstream' + extVersionCode = 6 + libVersion = '13' + containsNsfw = true +} + +apply from: "$rootDir/common.gradle" diff --git a/src/en/hstream/src/eu/kanade/tachiyomi/animeextension/en/hstream/Hstream.kt b/src/en/hstream/src/eu/kanade/tachiyomi/animeextension/en/hstream/Hstream.kt new file mode 100644 index 0000000000..b111709805 --- /dev/null +++ b/src/en/hstream/src/eu/kanade/tachiyomi/animeextension/en/hstream/Hstream.kt @@ -0,0 +1,129 @@ +package eu.kanade.tachiyomi.animeextension.en.hstream + +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.network.GET +import eu.kanade.tachiyomi.network.asObservableSuccess +import eu.kanade.tachiyomi.util.asJsoup +import okhttp3.Request +import okhttp3.Response +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element +import rx.Observable + +class Hstream : ParsedAnimeHttpSource() { + + override val name = "Hstream" + + override val baseUrl = "https://hstream.moe" + + override val lang = "en" + + override val supportsLatest = false + + // ============================== Popular =============================== + override fun popularAnimeRequest(page: Int): Request { + throw UnsupportedOperationException("Not used.") + } + + override fun popularAnimeSelector(): String { + throw UnsupportedOperationException("Not used.") + } + + override fun popularAnimeFromElement(element: Element): SAnime { + throw UnsupportedOperationException("Not used.") + } + + override fun popularAnimeNextPageSelector(): String? { + throw UnsupportedOperationException("Not used.") + } + + // =============================== Latest =============================== + override fun latestUpdatesRequest(page: Int): Request { + throw UnsupportedOperationException("Not used.") + } + + override fun latestUpdatesSelector(): String { + throw UnsupportedOperationException("Not used.") + } + + override fun latestUpdatesFromElement(element: Element): SAnime { + throw UnsupportedOperationException("Not used.") + } + + override fun latestUpdatesNextPageSelector(): String? { + throw UnsupportedOperationException("Not used.") + } + + // =============================== Search =============================== + override fun fetchSearchAnime(page: Int, query: String, filters: AnimeFilterList): Observable { + return if (query.startsWith(PREFIX_SEARCH)) { // URL intent handler + val id = query.removePrefix(PREFIX_SEARCH) + client.newCall(GET("$baseUrl/hentai/$id")) + .asObservableSuccess() + .map(::searchAnimeByIdParse) + } else { + super.fetchSearchAnime(page, query, filters) + } + } + + private fun searchAnimeByIdParse(response: Response): AnimesPage { + val details = animeDetailsParse(response.use { it.asJsoup() }) + return AnimesPage(listOf(details), false) + } + + override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request { + throw UnsupportedOperationException("Not used.") + } + + override fun searchAnimeSelector(): String { + throw UnsupportedOperationException("Not used.") + } + + override fun searchAnimeFromElement(element: Element): SAnime { + throw UnsupportedOperationException("Not used.") + } + + override fun searchAnimeNextPageSelector(): String? { + throw UnsupportedOperationException("Not used.") + } + + // =========================== Anime Details ============================ + override fun animeDetailsParse(document: Document): SAnime { + throw UnsupportedOperationException("Not used.") + } + + // ============================== Episodes ============================== + override fun episodeListSelector(): String { + throw UnsupportedOperationException("Not used.") + } + + override fun episodeFromElement(element: Element): SEpisode { + throw UnsupportedOperationException("Not used.") + } + + // ============================ Video Links ============================= + override fun videoListParse(response: Response): List