Fix Comick Genres \ Tags (#18789)
* Simplify Manifest data entries * Map MD and MU tags to genres * Switch separator for Ignored Groups setting From comma to newlines for better readability * Make MU Tags optional via preferences Because they might contain spoilers. - Include demographic \ target audience into genres * Switch from flattening list to a builder * Remove unneeded Listener * Switch migration check to preference boolean Rename muTags parameter to includeMuTags * Rename a couple variables More in line with their context
This commit is contained in:
parent
fffb9e929a
commit
1f7aedd8af
|
@ -13,14 +13,10 @@
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data
|
<data android:scheme="https" />
|
||||||
android:host="comick.app"
|
<data android:host="comick.app" />
|
||||||
android:pathPattern="/comic/.*/..*"
|
<data android:pathPattern="/comic/.*/..*" />
|
||||||
android:scheme="https" />
|
<data android:pathPattern="/comic/..*" />
|
||||||
<data
|
|
||||||
android:host="comick.app"
|
|
||||||
android:pathPattern="/comic/..*"
|
|
||||||
android:scheme="https" />
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Comick'
|
extName = 'Comick'
|
||||||
pkgNameSuffix = 'all.comickfun'
|
pkgNameSuffix = 'all.comickfun'
|
||||||
extClass = '.ComickFunFactory'
|
extClass = '.ComickFunFactory'
|
||||||
extVersionCode = 36
|
extVersionCode = 37
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Application
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.preference.EditTextPreference
|
import androidx.preference.EditTextPreference
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
||||||
|
@ -59,7 +60,7 @@ abstract class ComickFun(
|
||||||
key = IGNORED_GROUPS_PREF
|
key = IGNORED_GROUPS_PREF
|
||||||
title = "Ignored Groups"
|
title = "Ignored Groups"
|
||||||
summary =
|
summary =
|
||||||
"Chapters from these groups won't be shown.\nComma-separated list of group names (case-insensitive)"
|
"Chapters from these groups won't be shown.\nOne group name per line (case-insensitive)"
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
preferences.edit()
|
preferences.edit()
|
||||||
|
@ -67,18 +68,33 @@ abstract class ComickFun(
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
}.also(screen::addPreference)
|
}.also(screen::addPreference)
|
||||||
|
|
||||||
|
SwitchPreferenceCompat(screen.context).apply {
|
||||||
|
key = INCLUDE_MU_TAGS_PREF
|
||||||
|
title = "Include Tags"
|
||||||
|
summaryOn = "More specific, but might contain spoilers!"
|
||||||
|
summaryOff = "Only the broader genres"
|
||||||
|
setDefaultValue(true)
|
||||||
|
}.also(screen::addPreference)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val SharedPreferences.ignoredGroups
|
private val SharedPreferences.ignoredGroups
|
||||||
get() = getString(IGNORED_GROUPS_PREF, "")
|
get() = getString(IGNORED_GROUPS_PREF, "")
|
||||||
?.lowercase()
|
?.lowercase()
|
||||||
?.split(",")
|
?.split("\n")
|
||||||
?.map(String::trim)
|
?.map(String::trim)
|
||||||
?.filter(String::isNotEmpty)
|
?.filter(String::isNotEmpty)
|
||||||
?.sorted()
|
?.sorted()
|
||||||
.orEmpty()
|
.orEmpty()
|
||||||
.toSet()
|
.toSet()
|
||||||
|
|
||||||
|
private val SharedPreferences.includeMuTags
|
||||||
|
get() = getBoolean(INCLUDE_MU_TAGS_PREF, true)
|
||||||
|
|
||||||
|
init {
|
||||||
|
preferences.newLineIgnoredGroups()
|
||||||
|
}
|
||||||
|
|
||||||
override fun headersBuilder() = Headers.Builder().apply {
|
override fun headersBuilder() = Headers.Builder().apply {
|
||||||
add("Referer", "$baseUrl/")
|
add("Referer", "$baseUrl/")
|
||||||
add("User-Agent", "Tachiyomi ${System.getProperty("http.agent")}")
|
add("User-Agent", "Tachiyomi ${System.getProperty("http.agent")}")
|
||||||
|
@ -263,7 +279,7 @@ abstract class ComickFun(
|
||||||
|
|
||||||
override fun mangaDetailsParse(response: Response): SManga {
|
override fun mangaDetailsParse(response: Response): SManga {
|
||||||
val mangaData = response.parseAs<Manga>()
|
val mangaData = response.parseAs<Manga>()
|
||||||
return mangaData.toSManga()
|
return mangaData.toSManga(includeMuTags = preferences.includeMuTags)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getMangaUrl(manga: SManga): String {
|
override fun getMangaUrl(manga: SManga): String {
|
||||||
|
@ -347,9 +363,28 @@ abstract class ComickFun(
|
||||||
|
|
||||||
override fun getFilterList() = getFilters()
|
override fun getFilterList() = getFilters()
|
||||||
|
|
||||||
|
private fun SharedPreferences.newLineIgnoredGroups() {
|
||||||
|
if (getBoolean(MIGRATED_IGNORED_GROUPS, false)) return
|
||||||
|
val ignoredGroups = getString(IGNORED_GROUPS_PREF, "").orEmpty()
|
||||||
|
|
||||||
|
edit()
|
||||||
|
.putString(
|
||||||
|
IGNORED_GROUPS_PREF,
|
||||||
|
ignoredGroups
|
||||||
|
.split(",")
|
||||||
|
.map(String::trim)
|
||||||
|
.filter(String::isNotEmpty)
|
||||||
|
.joinToString("\n"),
|
||||||
|
)
|
||||||
|
.putBoolean(MIGRATED_IGNORED_GROUPS, true)
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SLUG_SEARCH_PREFIX = "id:"
|
const val SLUG_SEARCH_PREFIX = "id:"
|
||||||
private const val IGNORED_GROUPS_PREF = "IgnoredGroups"
|
private const val IGNORED_GROUPS_PREF = "IgnoredGroups"
|
||||||
|
private const val INCLUDE_MU_TAGS_PREF = "IncludeMangaUpdatesTags"
|
||||||
|
private const val MIGRATED_IGNORED_GROUPS = "MigratedIgnoredGroups"
|
||||||
private const val limit = 20
|
private const val limit = 20
|
||||||
val dateFormat by lazy {
|
val dateFormat by lazy {
|
||||||
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH).apply {
|
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH).apply {
|
||||||
|
|
|
@ -27,8 +27,9 @@ data class Manga(
|
||||||
val artists: List<Name> = emptyList(),
|
val artists: List<Name> = emptyList(),
|
||||||
val authors: List<Name> = emptyList(),
|
val authors: List<Name> = emptyList(),
|
||||||
val genres: List<Name> = emptyList(),
|
val genres: List<Name> = emptyList(),
|
||||||
|
val demographic: String? = null,
|
||||||
) {
|
) {
|
||||||
fun toSManga() = SManga.create().apply {
|
fun toSManga(includeMuTags: Boolean = false) = SManga.create().apply {
|
||||||
// appennding # at end as part of migration from slug to hid
|
// appennding # at end as part of migration from slug to hid
|
||||||
url = "/comic/${comic.hid}#"
|
url = "/comic/${comic.hid}#"
|
||||||
title = comic.title
|
title = comic.title
|
||||||
|
@ -48,7 +49,19 @@ data class Manga(
|
||||||
thumbnail_url = parseCover(comic.cover, comic.mdCovers)
|
thumbnail_url = parseCover(comic.cover, comic.mdCovers)
|
||||||
artist = artists.joinToString { it.name.trim() }
|
artist = artists.joinToString { it.name.trim() }
|
||||||
author = authors.joinToString { it.name.trim() }
|
author = authors.joinToString { it.name.trim() }
|
||||||
genre = (listOfNotNull(comic.origination) + genres)
|
genre = buildList {
|
||||||
|
comic.origination?.let(::add)
|
||||||
|
demographic?.let { add(Name(it)) }
|
||||||
|
addAll(genres)
|
||||||
|
addAll(comic.mdGenres.mapNotNull { it.name })
|
||||||
|
if (includeMuTags) {
|
||||||
|
comic.muGenres.categories.forEach { category ->
|
||||||
|
category.category?.title?.let { add(Name(it)) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.distinctBy { it.name }
|
||||||
|
.filter { it.name.isNotBlank() }
|
||||||
.joinToString { it.name.trim() }
|
.joinToString { it.name.trim() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +77,8 @@ data class Comic(
|
||||||
@SerialName("translation_completed") val translationComplete: Boolean? = true,
|
@SerialName("translation_completed") val translationComplete: Boolean? = true,
|
||||||
@SerialName("md_covers") val mdCovers: List<MDcovers> = emptyList(),
|
@SerialName("md_covers") val mdCovers: List<MDcovers> = emptyList(),
|
||||||
@SerialName("cover_url") val cover: String? = null,
|
@SerialName("cover_url") val cover: String? = null,
|
||||||
|
@SerialName("md_comic_md_genres") val mdGenres: List<MdGenres>,
|
||||||
|
@SerialName("mu_comics") val muGenres: MuComicCategories,
|
||||||
) {
|
) {
|
||||||
val origination = when (country) {
|
val origination = when (country) {
|
||||||
"jp" -> Name("Manga")
|
"jp" -> Name("Manga")
|
||||||
|
@ -73,6 +88,21 @@ data class Comic(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class MdGenres(
|
||||||
|
@SerialName("md_genres") val name: Name? = null,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class MuComicCategories(
|
||||||
|
@SerialName("mu_comic_categories") val categories: List<MuCategories> = emptyList(),
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class MuCategories(
|
||||||
|
@SerialName("mu_categories") val category: Title? = null,
|
||||||
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class MDcovers(
|
data class MDcovers(
|
||||||
val b2key: String?,
|
val b2key: String?,
|
||||||
|
|
Loading…
Reference in New Issue