mirror of
https://github.com/keiyoushi/extensions-source.git
synced 2024-11-24 03:12:42 +01:00
Add Usagi and unparseable date fix (#6085)
* chapter numbers fix * chapter numbers fix * Add Usagi * Unparseable date fix --------- Co-authored-by: romshke <@>
This commit is contained in:
parent
819cc2beea
commit
ebe5868db6
@ -2,4 +2,4 @@ plugins {
|
||||
id("lib-multisrc")
|
||||
}
|
||||
|
||||
baseVersionCode = 25
|
||||
baseVersionCode = 26
|
||||
|
@ -268,10 +268,14 @@ abstract class GroupLe(
|
||||
chapter.chapter_number = chapterInf.attr("data-num").toFloat() / 10
|
||||
|
||||
chapter.date_upload = element.select("td.d-none").last()?.text()?.let {
|
||||
try {
|
||||
SimpleDateFormat("dd.MM.yy", Locale.US).parse(it)?.time ?: 0L
|
||||
} catch (e: ParseException) {
|
||||
SimpleDateFormat("dd/MM/yy", Locale.US).parse(it)?.time ?: 0L
|
||||
if (it.isEmpty()) {
|
||||
0L
|
||||
} else {
|
||||
try {
|
||||
SimpleDateFormat("dd.MM.yy", Locale.US).parse(it)?.time ?: 0L
|
||||
} catch (e: ParseException) {
|
||||
SimpleDateFormat("dd/MM/yy", Locale.US).parse(it)?.time ?: 0L
|
||||
}
|
||||
}
|
||||
} ?: 0
|
||||
return chapter
|
||||
|
10
src/ru/usagi/build.gradle
Normal file
10
src/ru/usagi/build.gradle
Normal file
@ -0,0 +1,10 @@
|
||||
ext {
|
||||
extName = 'Usagi'
|
||||
extClass = '.Usagi'
|
||||
themePkg = 'grouple'
|
||||
baseUrl = 'https://web.usagi.one'
|
||||
overrideVersionCode = 0
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
BIN
src/ru/usagi/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
src/ru/usagi/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
BIN
src/ru/usagi/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
src/ru/usagi/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
BIN
src/ru/usagi/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
src/ru/usagi/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
src/ru/usagi/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
src/ru/usagi/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
src/ru/usagi/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
src/ru/usagi/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
199
src/ru/usagi/src/eu/kanade/tachiyomi/extension/ru/usagi/Usagi.kt
Normal file
199
src/ru/usagi/src/eu/kanade/tachiyomi/extension/ru/usagi/Usagi.kt
Normal file
@ -0,0 +1,199 @@
|
||||
package eu.kanade.tachiyomi.extension.ru.usagi
|
||||
|
||||
import android.app.Application
|
||||
import android.widget.Toast
|
||||
import androidx.preference.EditTextPreference
|
||||
import eu.kanade.tachiyomi.multisrc.grouple.GroupLe
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import okhttp3.Request
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class Usagi : GroupLe("Usagi", "https://web.usagi.one/", "ru") {
|
||||
|
||||
private val preferences =
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
|
||||
override val baseUrl by lazy { getPrefBaseUrl() }
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
val url = super.searchMangaRequest(page, query, filters).url.newBuilder()
|
||||
(if (filters.isEmpty()) getFilterList().reversed() else filters.reversed()).forEach { filter ->
|
||||
when (filter) {
|
||||
is GenreList -> filter.state.forEach { genre ->
|
||||
if (genre.state != Filter.TriState.STATE_IGNORE) {
|
||||
url.addQueryParameter(genre.id, arrayOf("=", "=in", "=ex")[genre.state])
|
||||
}
|
||||
}
|
||||
is Category -> filter.state.forEach { category ->
|
||||
if (category.state != Filter.TriState.STATE_IGNORE) {
|
||||
url.addQueryParameter(category.id, arrayOf("=", "=in", "=ex")[category.state])
|
||||
}
|
||||
}
|
||||
is AgeList -> filter.state.forEach { age ->
|
||||
if (age.state != Filter.TriState.STATE_IGNORE) {
|
||||
url.addQueryParameter(age.id, arrayOf("=", "=in", "=ex")[age.state])
|
||||
}
|
||||
}
|
||||
is More -> filter.state.forEach { more ->
|
||||
if (more.state != Filter.TriState.STATE_IGNORE) {
|
||||
url.addQueryParameter(more.id, arrayOf("=", "=in", "=ex")[more.state])
|
||||
}
|
||||
}
|
||||
is FilList -> filter.state.forEach { fils ->
|
||||
if (fils.state != Filter.TriState.STATE_IGNORE) {
|
||||
url.addQueryParameter(fils.id, arrayOf("=", "=in", "=ex")[fils.state])
|
||||
}
|
||||
}
|
||||
is OrderBy -> {
|
||||
if (url.toString().contains("&") && filter.state < 6) {
|
||||
url.addQueryParameter("sortType", arrayOf("RATING", "POPULARITY", "YEAR", "NAME", "DATE_CREATE", "DATE_UPDATE, USER_RATING")[filter.state])
|
||||
} else {
|
||||
val ord = arrayOf("rate", "popularity", "year", "name", "created", "updated", "votes")[filter.state]
|
||||
return GET("$baseUrl/list?sortType=$ord&offset=${70 * (page - 1)}", headers)
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
return if (url.toString().contains("&")) {
|
||||
GET(url.toString().replace("=%3D", "="), headers)
|
||||
} else {
|
||||
popularMangaRequest(page)
|
||||
}
|
||||
}
|
||||
|
||||
private class OrderBy : Filter.Select<String>(
|
||||
"Сортировка",
|
||||
arrayOf("По популярности", "Популярно сейчас", "По году", "По имени", "Новинки", "По дате обновления", "По рейтингу"),
|
||||
)
|
||||
|
||||
private class Genre(name: String, val id: String) : Filter.TriState(name)
|
||||
|
||||
private class GenreList(genres: List<Genre>) : Filter.Group<Genre>("Жанры", genres)
|
||||
private class Category(categories: List<Genre>) : Filter.Group<Genre>("Категории", categories)
|
||||
private class AgeList(ages: List<Genre>) : Filter.Group<Genre>("Возрастная рекомендация", ages)
|
||||
private class More(moren: List<Genre>) : Filter.Group<Genre>("Прочее", moren)
|
||||
private class FilList(fils: List<Genre>) : Filter.Group<Genre>("Фильтры", fils)
|
||||
|
||||
override fun getFilterList() = FilterList(
|
||||
OrderBy(),
|
||||
Category(getCategoryList()),
|
||||
GenreList(getGenreList()),
|
||||
AgeList(getAgeList()),
|
||||
More(getMore()),
|
||||
FilList(getFilList()),
|
||||
)
|
||||
private fun getFilList() = listOf(
|
||||
Genre("Высокий рейтинг", "s_high_rate"),
|
||||
Genre("Сингл", "s_single"),
|
||||
Genre("Для взрослых", "s_mature"),
|
||||
Genre("Завершенная", "s_completed"),
|
||||
Genre("Переведено", "s_translated"),
|
||||
Genre("Заброшен перевод", "s_abandoned_popular"),
|
||||
Genre("Длинная", "s_many_chapters"),
|
||||
Genre("Ожидает загрузки", "s_wait_upload"),
|
||||
Genre("Лицензия", "s_sale"),
|
||||
Genre("Белые жанры", "s_not_pessimized"),
|
||||
)
|
||||
private fun getMore() = listOf(
|
||||
Genre("В цвете", "el_7290"),
|
||||
Genre("Веб", "el_2160"),
|
||||
Genre("На экранах", "el_9795"),
|
||||
Genre("Сборник", "el_2157"),
|
||||
)
|
||||
|
||||
private fun getAgeList() = listOf(
|
||||
Genre("G", "el_6180"),
|
||||
Genre("NC-17", "el_9848"),
|
||||
Genre("PG", "el_6179"),
|
||||
Genre("PG-13", "el_6181"),
|
||||
Genre("R", "el_9847"),
|
||||
)
|
||||
|
||||
private fun getCategoryList() = listOf(
|
||||
Genre("OEL-манга", "el_9577"),
|
||||
Genre("Арт", "el_5685"),
|
||||
Genre("Додзинси", "el_2141"),
|
||||
Genre("Ёнкома", "el_2161"),
|
||||
Genre("Комикс", "el_3515"),
|
||||
Genre("Манга", "el_9451"),
|
||||
Genre("Манхва", "el_3001"),
|
||||
Genre("Маньхуа", "el_3002"),
|
||||
)
|
||||
|
||||
private fun getGenreList() = listOf(
|
||||
Genre("боевик", "el_2155"),
|
||||
Genre("боевые искусства", "el_2143"),
|
||||
Genre("гарем", "el_2142"),
|
||||
Genre("гендерная интрига", "el_2156"),
|
||||
Genre("героическое фэнтези", "el_2146"),
|
||||
Genre("детектив", "el_2152"),
|
||||
Genre("дзёсэй", "el_2158"),
|
||||
Genre("драма", "el_2118"),
|
||||
Genre("игра", "el_2154"),
|
||||
Genre("история", "el_2119"),
|
||||
Genre("исэкай", "el_9450"),
|
||||
Genre("киберпанк", "el_8032"),
|
||||
Genre("кодомо", "el_2137"),
|
||||
Genre("комедия", "el_2136"),
|
||||
Genre("махо-сёдзё", "el_2147"),
|
||||
Genre("меха", "el_2126"),
|
||||
Genre("научная фантастика", "el_2133"),
|
||||
Genre("повседневность", "el_2135"),
|
||||
Genre("постапокалиптика", "el_2151"),
|
||||
Genre("приключения", "el_2130"),
|
||||
Genre("психология", "el_2144"),
|
||||
Genre("романтика", "el_2121"),
|
||||
Genre("самурайский боевик", "el_2124"),
|
||||
Genre("сверхъестественное", "el_2159"),
|
||||
Genre("сёдзё", "el_2122"),
|
||||
Genre("сёнэн", "el_2134"),
|
||||
Genre("спорт", "el_2129"),
|
||||
Genre("сэйнэн", "el_2138"),
|
||||
Genre("сянься", "el_9561"),
|
||||
Genre("трагедия", "el_2153"),
|
||||
Genre("триллер", "el_2150"),
|
||||
Genre("ужасы", "el_2125"),
|
||||
Genre("уся", "el_9560"),
|
||||
Genre("фэнтези", "el_2131"),
|
||||
Genre("школа", "el_2127"),
|
||||
Genre("этти", "el_2149"),
|
||||
)
|
||||
|
||||
override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) {
|
||||
super.setupPreferenceScreen(screen)
|
||||
EditTextPreference(screen.context).apply {
|
||||
key = DOMAIN_PREF
|
||||
title = DOMAIN_TITLE
|
||||
setDefaultValue(super.baseUrl)
|
||||
dialogTitle = DOMAIN_TITLE
|
||||
dialogMessage = "Default URL:\n\t${super.baseUrl}"
|
||||
setOnPreferenceChangeListener { _, _ ->
|
||||
Toast.makeText(screen.context, "Для смены домена необходимо перезапустить приложение с полной остановкой.", Toast.LENGTH_LONG).show()
|
||||
true
|
||||
}
|
||||
}.let(screen::addPreference)
|
||||
}
|
||||
|
||||
private fun getPrefBaseUrl(): String = preferences.getString(DOMAIN_PREF, super.baseUrl)!!
|
||||
|
||||
init {
|
||||
preferences.getString(DEFAULT_DOMAIN_PREF, null).let { defaultBaseUrl ->
|
||||
if (defaultBaseUrl != super.baseUrl) {
|
||||
preferences.edit()
|
||||
.putString(DOMAIN_PREF, super.baseUrl)
|
||||
.putString(DEFAULT_DOMAIN_PREF, super.baseUrl)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val DOMAIN_PREF = "pref_domain"
|
||||
private const val DEFAULT_DOMAIN_PREF = "pref_default_domain"
|
||||
private const val DOMAIN_TITLE = "Домен"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user