diff --git a/src/en/nollyverse/res/web_hi_res_512.png b/src/en/nollyverse/res/web_hi_res_512.png deleted file mode 100644 index cd31026f19..0000000000 Binary files a/src/en/nollyverse/res/web_hi_res_512.png and /dev/null differ diff --git a/src/en/nollyverse/src/eu/kanade/tachiyomi/animeextension/en/nollyverse/NollyVerse.kt b/src/en/nollyverse/src/eu/kanade/tachiyomi/animeextension/en/nollyverse/NollyVerse.kt index 7fea856d69..52fae35762 100644 --- a/src/en/nollyverse/src/eu/kanade/tachiyomi/animeextension/en/nollyverse/NollyVerse.kt +++ b/src/en/nollyverse/src/eu/kanade/tachiyomi/animeextension/en/nollyverse/NollyVerse.kt @@ -23,7 +23,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 NollyVerse : ConfigurableAnimeSource, ParsedAnimeHttpSource() { @@ -260,7 +259,7 @@ class NollyVerse : ConfigurableAnimeSource, ParsedAnimeHttpSource() { private fun nextPageSelector(): String = "ul.pagination.pagination-md li:nth-last-child(2)" - override fun searchAnimeNextPageSelector(): String = throw Exception("Not used") + override fun searchAnimeNextPageSelector(): String = throw UnsupportedOperationException() // =========================== Anime Details ============================ @@ -339,7 +338,7 @@ class NollyVerse : ConfigurableAnimeSource, ParsedAnimeHttpSource() { } } - override fun episodeListSelector() = throw Exception("not used") + override fun episodeListSelector() = throw UnsupportedOperationException() // ============================ Video Links ============================= @@ -385,11 +384,11 @@ class NollyVerse : ConfigurableAnimeSource, ParsedAnimeHttpSource() { return videoList.sort() } - override fun videoListSelector() = throw Exception("not used") + override fun videoListSelector() = throw UnsupportedOperationException() - override fun videoFromElement(element: Element) = throw Exception("not used") + override fun videoFromElement(element: Element) = throw UnsupportedOperationException() - override fun videoUrlParse(document: Document) = throw Exception("not used") + override fun videoUrlParse(document: Document) = throw UnsupportedOperationException() // ============================= Utilities ============================== diff --git a/src/en/superstream/build.gradle b/src/en/superstream/build.gradle index dea13c5dd2..fe460c5db5 100644 --- a/src/en/superstream/build.gradle +++ b/src/en/superstream/build.gradle @@ -1,7 +1,8 @@ ext { extName = 'SuperStream' extClass = '.SuperStream' - extVersionCode = 10 + extVersionCode = 11 + isNsfw = true } apply from: "$rootDir/common.gradle" diff --git a/src/en/superstream/src/eu/kanade/tachiyomi/animeextension/en/superstream/SuperStream.kt b/src/en/superstream/src/eu/kanade/tachiyomi/animeextension/en/superstream/SuperStream.kt index 32a4e5dfa1..b80c051d4c 100644 --- a/src/en/superstream/src/eu/kanade/tachiyomi/animeextension/en/superstream/SuperStream.kt +++ b/src/en/superstream/src/eu/kanade/tachiyomi/animeextension/en/superstream/SuperStream.kt @@ -2,8 +2,10 @@ package eu.kanade.tachiyomi.animeextension.en.superstream import android.app.Application import android.content.SharedPreferences +import android.widget.Toast import androidx.preference.ListPreference import androidx.preference.PreferenceScreen +import androidx.preference.SwitchPreferenceCompat import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource import eu.kanade.tachiyomi.animesource.model.AnimeFilterList import eu.kanade.tachiyomi.animesource.model.AnimesPage @@ -31,13 +33,13 @@ class SuperStream : ConfigurableAnimeSource, AnimeHttpSource() { private val json: Json by injectLazy() - private val superStreamAPI = SuperStreamAPI(json) + private val preferences: SharedPreferences = Injekt.get().getSharedPreferences("source_$id", 0x0000) - override val baseUrl = superStreamAPI.apiUrl + private val hideNsfw = if (preferences.getBoolean(PREF_HIDE_NSFW_KEY, PREF_HIDE_NSFW_DEFAULT)) 1 else 0 - private val preferences: SharedPreferences by lazy { - Injekt.get().getSharedPreferences("source_$id", 0x0000) - } + private val superStreamAPI = SuperStreamAPI(json, hideNsfw) + + override val baseUrl = superStreamAPI.apiUrl override suspend fun getPopularAnime(page: Int): AnimesPage { val animes = superStreamAPI.getMainPage(page) @@ -187,8 +189,10 @@ class SuperStream : ConfigurableAnimeSource, AnimeHttpSource() { } override fun animeDetailsParse(response: Response) = throw UnsupportedOperationException() + // ============================== Settings ============================== + override fun setupPreferenceScreen(screen: PreferenceScreen) { - val videoQualityPref = ListPreference(screen.context).apply { + ListPreference(screen.context).apply { key = "preferred_quality" title = "Preferred quality" entries = arrayOf("4k", "1080p", "720p", "480p", "360p", "240p") @@ -202,8 +206,20 @@ class SuperStream : ConfigurableAnimeSource, AnimeHttpSource() { val entry = entryValues[index] as String preferences.edit().putString(key, entry).commit() } - } - screen.addPreference(videoQualityPref) + }.also(screen::addPreference) + + SwitchPreferenceCompat(screen.context).apply { + key = PREF_HIDE_NSFW_KEY + title = "Hide NSFW content" + setDefaultValue(PREF_HIDE_NSFW_DEFAULT) + summary = "requires restart" + + setOnPreferenceChangeListener { _, newValue -> + val new = newValue as Boolean + Toast.makeText(screen.context, "Restart Aniyomi to apply new setting.", Toast.LENGTH_LONG).show() + preferences.edit().putBoolean(key, new).commit() + } + }.also(screen::addPreference) } private fun LinkData.toJson(): String { @@ -218,3 +234,6 @@ class SuperStream : ConfigurableAnimeSource, AnimeHttpSource() { } } } + +private const val PREF_HIDE_NSFW_KEY = "pref_hide_nsfw" +private const val PREF_HIDE_NSFW_DEFAULT = true diff --git a/src/en/superstream/src/eu/kanade/tachiyomi/animeextension/en/superstream/SuperStreamAPI.kt b/src/en/superstream/src/eu/kanade/tachiyomi/animeextension/en/superstream/SuperStreamAPI.kt index e574abde4d..7f66d1bea9 100644 --- a/src/en/superstream/src/eu/kanade/tachiyomi/animeextension/en/superstream/SuperStreamAPI.kt +++ b/src/en/superstream/src/eu/kanade/tachiyomi/animeextension/en/superstream/SuperStreamAPI.kt @@ -713,13 +713,10 @@ const val TYPE_SERIES = 2 const val TYPE_MOVIES = 1 // Ported from CS3 -class SuperStreamAPI(val json: Json) { +class SuperStreamAPI(private val json: Json, private val hideNsfw: Int) { private val client = configureToIgnoreCertificate() - // 0 to get nsfw - private val hideNsfw = 1 - private val headers = Headers.headersOf( "Platform", "android",