Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Secozzi committed Mar 16, 2024
2 parents 1dcc48c + 39bbf47 commit e8f29b8
Show file tree
Hide file tree
Showing 23 changed files with 403 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib-multisrc/zorotheme/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id("lib-multisrc")
}

baseVersionCode = 1
baseVersionCode = 2

dependencies {
api(project(":lib:megacloud-extractor"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ abstract class ZoroTheme(
override val lang: String,
override val name: String,
override val baseUrl: String,
private val hosterNames: List<String>,
) : ConfigurableAnimeSource, ParsedAnimeHttpSource() {

override val supportsLatest = true
Expand All @@ -44,6 +45,7 @@ abstract class ZoroTheme(

val preferences: SharedPreferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
.clearOldHosts()
}

private val docHeaders = headers.newBuilder().apply {
Expand All @@ -54,8 +56,6 @@ abstract class ZoroTheme(

protected open val ajaxRoute = ""

abstract val hosterNames: List<String>

private val useEnglish by lazy { preferences.getTitleLang == "English" }
private val markFiller by lazy { preferences.markFiller }

Expand Down Expand Up @@ -238,9 +238,7 @@ abstract class ZoroTheme(
return embedLinks.parallelCatchingFlatMap(::extractVideo)
}

protected open fun extractVideo(server: VideoData): List<Video> {
return emptyList()
}
abstract fun extractVideo(server: VideoData): List<Video>

override fun videoListSelector() = throw UnsupportedOperationException()

Expand All @@ -249,6 +247,21 @@ abstract class ZoroTheme(
override fun videoUrlParse(document: Document) = throw UnsupportedOperationException()

// ============================= Utilities ==============================

private fun SharedPreferences.clearOldHosts(): SharedPreferences {
if (hostToggle.all { hosterNames.contains(it) }) {
return this
}

edit()
.remove(PREF_HOSTER_KEY)
.putStringSet(PREF_HOSTER_KEY, hosterNames.toSet())
.remove(PREF_SERVER_KEY)
.putString(PREF_SERVER_KEY, hosterNames.first())
.apply()
return this
}

private fun Set<String>.contains(s: String, ignoreCase: Boolean): Boolean {
return any { it.equals(s, ignoreCase) }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'AnimeUI'
extClass = '.AnimeUI'
extVersionCode = 1
extVersionCode = 2
}

apply from: "$rootDir/common.gradle"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.animeextension.en.animeui
package eu.kanade.tachiyomi.animeextension.all.animeui

import android.app.Application
import android.content.SharedPreferences
Expand Down Expand Up @@ -30,12 +30,14 @@ class AnimeUI : ConfigurableAnimeSource, AnimeHttpSource() {

override val baseUrl = "https://animeui.com"

override val lang = "en"
override val lang = "all"

override val supportsLatest = true

private val json: Json by injectLazy()

override val id: Long = 7372747480486811746L

private val preferences: SharedPreferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
}
Expand Down Expand Up @@ -135,7 +137,7 @@ class AnimeUI : ConfigurableAnimeSource, AnimeHttpSource() {
val subtitleList = parsed.subtitlesJson?.let {
json.decodeFromString<List<SubtitleObject>>(it).map { s ->
Track("$baseUrl/api${s.url}", s.subtitle_name)
}
}.sortSubs()
} ?: emptyList()

val cid = parsed.episode.cid
Expand All @@ -154,7 +156,17 @@ class AnimeUI : ConfigurableAnimeSource, AnimeHttpSource() {
}
}

// ============================= Utilities ==============================
// ============================= Utilities ==============================.

private fun Iterable<Track>.sortSubs(): List<Track> {
val sub = preferences.getString(PREF_SUB_LANG_KEY, PREF_SUB_LANG_DEFAULT)!!
return this.sortedWith(
compareBy<Track>(
{ it.lang.startsWith(sub, true) },
{ it.lang.contains(sub, true) },
).thenByDescending { it.lang },
).reversed()
}

override fun List<Video>.sort(): List<Video> {
val server = preferences.getString(PREF_SERVER_KEY, PREF_SERVER_DEFAULT)!!
Expand All @@ -173,6 +185,20 @@ class AnimeUI : ConfigurableAnimeSource, AnimeHttpSource() {
"Tokyo", "Kyoto", "Nagoya", "Sendai", "Sagara",
"Nara", "Osaka", "Web", "Noshiro",
)

private const val PREF_SUB_LANG_KEY = "preferred_sub_lang"
private const val PREF_SUB_LANG_DEFAULT = "English"
private val LOCALE_LIST = arrayOf(
"English",
"Spanish",
"European Spanish",
"Portuguese",
"Deutsch",
"French",
"Italian",
"Russian",
"Arabic",
)
}
// ============================== Settings ==============================

Expand All @@ -194,6 +220,22 @@ class AnimeUI : ConfigurableAnimeSource, AnimeHttpSource() {
}
}.also(screen::addPreference)

ListPreference(screen.context).apply {
key = PREF_SUB_LANG_KEY
title = "Preferred subtitle language"
entries = LOCALE_LIST
entryValues = LOCALE_LIST
setDefaultValue(PREF_SUB_LANG_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_SERVER_KEY
title = "Preferred server"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.animeextension.en.animeui
package eu.kanade.tachiyomi.animeextension.all.animeui

import eu.kanade.tachiyomi.animesource.model.SAnime
import eu.kanade.tachiyomi.animesource.model.SEpisode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.animeextension.en.animeui
package eu.kanade.tachiyomi.animeextension.all.animeui

import eu.kanade.tachiyomi.animesource.model.AnimeFilter
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
Expand Down
2 changes: 1 addition & 1 deletion src/all/chineseanime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ext {
extClass = '.ChineseAnime'
themePkg = 'animestream'
baseUrl = 'https://www.chineseanime.vip'
overrideVersionCode = 6
overrideVersionCode = 7
}

apply from: "$rootDir/common.gradle"
Expand Down
Binary file removed src/en/animeui/res/web_hi_res_512.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ class Kaido : ZoroTheme(
"en",
"Kaido",
"https://kaido.to",
) {
override val hosterNames: List<String> = listOf(
hosterNames = listOf(
"Vidstreaming",
"Vidcloud",
"StreamTape",
)

),
) {
private val streamtapeExtractor by lazy { StreamTapeExtractor(client) }
private val megaCloudExtractor by lazy { MegaCloudExtractor(client, headers, preferences) }

Expand Down
7 changes: 7 additions & 0 deletions src/en/slothanime/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ext {
extName = 'SlothAnime'
extClass = '.SlothAnime'
extVersionCode = 1
}

apply from: "$rootDir/common.gradle"
Binary file added src/en/slothanime/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/en/slothanime/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package eu.kanade.tachiyomi.animeextension.en.slothanime

import eu.kanade.tachiyomi.animesource.model.AnimeFilter

open class UriPartFilter(
name: String,
private val vals: Array<Pair<String, String>>,
defaultValue: String? = null,
) : AnimeFilter.Select<String>(
name,
vals.map { it.first }.toTypedArray(),
vals.indexOfFirst { it.second == defaultValue }.takeIf { it != -1 } ?: 0,
) {
fun getValue(): String {
return vals[state].second
}
}

open class UriMultiSelectOption(name: String, val value: String) : AnimeFilter.CheckBox(name)

open class UriMultiSelectFilter(
name: String,
private val vals: Array<Pair<String, String>>,
) : AnimeFilter.Group<UriMultiSelectOption>(name, vals.map { UriMultiSelectOption(it.first, it.second) }) {
fun getValues(): List<String> {
return state.filter { it.state }.map { it.value }
}
}

open class UriMultiTriSelectOption(name: String, val value: String) : AnimeFilter.TriState(name)

open class UriMultiTriSelectFilter(
name: String,
private val vals: Array<Pair<String, String>>,
) : AnimeFilter.Group<UriMultiTriSelectOption>(name, vals.map { UriMultiTriSelectOption(it.first, it.second) }) {
fun getIncluded(): List<String> {
return state.filter { it.state == TriState.STATE_INCLUDE }.map { it.value }
}

fun getExcluded(): List<String> {
return state.filter { it.state == TriState.STATE_EXCLUDE }.map { it.value }
}
}

class GenreFilter : UriMultiTriSelectFilter(
"Genre",
arrayOf(
Pair("Action", "action"),
Pair("Adventure", "adventure"),
Pair("Fantasy", "fantasy"),
Pair("Martial Arts", "martial_arts"),
Pair("Comedy", "comedy"),
Pair("School", "school"),
Pair("Slice of Life", "slice_of_life"),
Pair("Military", "military"),
Pair("Sci-Fi", "scifi"),
Pair("Isekai", "isekai"),
Pair("Kids", "kids"),
Pair("Iyashikei", "iyashikei"),
Pair("Horror", "horror"),
Pair("Supernatural", "supernatural"),
Pair("Avant Garde", "avant_garde"),
Pair("Demons", "demons"),
Pair("Gourmet", "gourmet"),
Pair("Music", "music"),
Pair("Drama", "drama"),
Pair("Seinen", "seinen"),
Pair("Ecchi", "ecchi"),
Pair("Harem", "harem"),
Pair("Romance", "romance"),
Pair("Magic", "magic"),
Pair("Mystery", "mystery"),
Pair("Suspense", "suspense"),
Pair("Parody", "parody"),
Pair("Psychological", "psychological"),
Pair("Super Power", "super_power"),
Pair("Vampire", "vampire"),
Pair("Shounen", "shounen"),
Pair("Space", "space"),
Pair("Mecha", "mecha"),
Pair("Sports", "sports"),
Pair("Shoujo", "shoujo"),
Pair("Girls Love", "girls_love"),
Pair("Josei", "josei"),
Pair("Mahou Shoujo", "mahou_shoujo"),
Pair("Thriller", "thriller"),
Pair("Reverse Harem", "reverse_harem"),
Pair("Boys Love", "boys_love"),
Pair("Uncategorized", "uncategorized"),
),
)

class TypeFilter : UriMultiSelectFilter(
"Type",
arrayOf(
Pair("ONA", "ona"),
Pair("TV", "tv"),
Pair("MOVIE", "movie"),
Pair("SPECIAL", "special"),
Pair("OVA", "ova"),
Pair("MUSIC", "music"),
),
)

class StatusFilter : UriPartFilter(
"Status",
arrayOf(
Pair("All", "2"),
Pair("Completed", "1"),
Pair("Releasing", "0"),
),
)

class SortFilter : UriPartFilter(
"Sort",
arrayOf(
Pair("Most Watched", "viewed"),
Pair("Scored", "scored"),
Pair("Newest", "created_at"),
Pair("Latest Update", "updated_at"),
),
)
Loading

0 comments on commit e8f29b8

Please sign in to comment.