feat(en/uhdmovies): update domain and add domain entry pref (#1690)
This commit is contained in:
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'UHD Movies'
|
extName = 'UHD Movies'
|
||||||
pkgNameSuffix = 'en.uhdmovies'
|
pkgNameSuffix = 'en.uhdmovies'
|
||||||
extClass = '.UHDMovies'
|
extClass = '.UHDMovies'
|
||||||
extVersionCode = 15
|
extVersionCode = 16
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.animeextension.en.uhdmovies
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
|
import androidx.preference.EditTextPreference
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||||
@ -18,7 +19,6 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.awaitAll
|
import kotlinx.coroutines.awaitAll
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
@ -41,7 +41,7 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
override val name = "UHD Movies"
|
override val name = "UHD Movies"
|
||||||
|
|
||||||
override val baseUrl by lazy { preferences.getString("pref_domain", "https://uhdmovies.bio")!! }
|
override val baseUrl by lazy { preferences.getString(PREF_DOMAIN_KEY, PREF_DEFAULT_DOMAIN)!! }
|
||||||
|
|
||||||
override val lang = "en"
|
override val lang = "en"
|
||||||
|
|
||||||
@ -55,29 +55,9 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val currentBaseUrl by lazy {
|
|
||||||
runBlocking {
|
|
||||||
withContext(Dispatchers.Default) {
|
|
||||||
client.newBuilder()
|
|
||||||
.followRedirects(false)
|
|
||||||
.build()
|
|
||||||
.newCall(GET("$baseUrl/")).execute().let { resp ->
|
|
||||||
when (resp.code) {
|
|
||||||
301 -> {
|
|
||||||
(resp.headers["location"]?.substringBeforeLast("/") ?: baseUrl).also {
|
|
||||||
preferences.edit().putString("pref_domain", it).apply()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> baseUrl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================== Popular ===============================
|
// ============================== Popular ===============================
|
||||||
|
|
||||||
override fun popularAnimeRequest(page: Int): Request = GET("$currentBaseUrl/page/$page/")
|
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/page/$page/")
|
||||||
|
|
||||||
override fun popularAnimeSelector(): String = "div#content div.gridlove-posts > div.layout-masonry"
|
override fun popularAnimeSelector(): String = "div#content div.gridlove-posts > div.layout-masonry"
|
||||||
|
|
||||||
@ -107,7 +87,7 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
|
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
|
||||||
val cleanQuery = query.replace(" ", "+").lowercase()
|
val cleanQuery = query.replace(" ", "+").lowercase()
|
||||||
return GET("$currentBaseUrl/page/$page/?s=$cleanQuery")
|
return GET("$baseUrl/page/$page/?s=$cleanQuery")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun searchAnimeSelector(): String = popularAnimeSelector()
|
override fun searchAnimeSelector(): String = popularAnimeSelector()
|
||||||
@ -131,7 +111,7 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
// ============================== Episodes ==============================
|
// ============================== Episodes ==============================
|
||||||
|
|
||||||
override fun fetchEpisodeList(anime: SAnime): Observable<List<SEpisode>> {
|
override fun fetchEpisodeList(anime: SAnime): Observable<List<SEpisode>> {
|
||||||
val resp = client.newCall(GET(currentBaseUrl + anime.url)).execute().asJsoup()
|
val resp = client.newCall(GET(baseUrl + anime.url)).execute().asJsoup()
|
||||||
val episodeList = mutableListOf<SEpisode>()
|
val episodeList = mutableListOf<SEpisode>()
|
||||||
val episodeElements = resp.select("p:has(a[href*=?id=],a[href*=r?key=]):has(a[class*=maxbutton])[style*=center]")
|
val episodeElements = resp.select("p:has(a[href*=?id=],a[href*=r?key=]):has(a[class*=maxbutton])[style*=center]")
|
||||||
val qualityRegex = "\\d{3,4}p".toRegex(RegexOption.IGNORE_CASE)
|
val qualityRegex = "\\d{3,4}p".toRegex(RegexOption.IGNORE_CASE)
|
||||||
@ -481,7 +461,9 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
entries = arrayOf("Ascending", "Descending")
|
entries = arrayOf("Ascending", "Descending")
|
||||||
entryValues = arrayOf("asc", "dec")
|
entryValues = arrayOf("asc", "dec")
|
||||||
setDefaultValue("asc")
|
setDefaultValue("asc")
|
||||||
summary = "%s - Sort order to be used after the videos are sorted by their quality."
|
summary = """%s
|
||||||
|
|Sort order to be used after the videos are sorted by their quality.
|
||||||
|
""".trimMargin()
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
val selected = newValue as String
|
val selected = newValue as String
|
||||||
@ -490,9 +472,29 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
preferences.edit().putString(key, entry).commit()
|
preferences.edit().putString(key, entry).commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val domainPref = EditTextPreference(screen.context).apply {
|
||||||
|
key = PREF_DOMAIN_KEY
|
||||||
|
title = "Currently used domain"
|
||||||
|
dialogTitle = title
|
||||||
|
setDefaultValue(PREF_DEFAULT_DOMAIN)
|
||||||
|
val tempText = preferences.getString(key, PREF_DEFAULT_DOMAIN)
|
||||||
|
summary = """$tempText
|
||||||
|
|For any change to be applied App restart is required.
|
||||||
|
""".trimMargin()
|
||||||
|
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
val newValueString = newValue as String
|
||||||
|
preferences.edit().putString(key, newValueString.trim()).commit().also {
|
||||||
|
summary = """$newValueString
|
||||||
|
|For any change to be applied App restart is required.
|
||||||
|
""".trimMargin()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
screen.addPreference(videoQualityPref)
|
screen.addPreference(videoQualityPref)
|
||||||
screen.addPreference(sizeSortPref)
|
screen.addPreference(sizeSortPref)
|
||||||
|
screen.addPreference(domainPref)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -515,4 +517,9 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
runBlocking {
|
runBlocking {
|
||||||
map { async(Dispatchers.Default) { f(it) } }.awaitAll()
|
map { async(Dispatchers.Default) { f(it) } }.awaitAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val PREF_DOMAIN_KEY = "pref_domain_new"
|
||||||
|
const val PREF_DEFAULT_DOMAIN = "https://uhdmovies.site"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user