Refactor manga type
This commit is contained in:
parent
a4e94c1e05
commit
888bd8c8dd
1 changed files with 30 additions and 24 deletions
|
@ -64,34 +64,24 @@ interface Manga : SManga {
|
||||||
*/
|
*/
|
||||||
fun mangaType(): Int {
|
fun mangaType(): Int {
|
||||||
val sourceName = Injekt.get<SourceManager>().getOrStub(source).name
|
val sourceName = Injekt.get<SourceManager>().getOrStub(source).name
|
||||||
val currentTags = genre?.split(",")?.map { it.trim().toLowerCase(Locale.US) }
|
val currentTags =
|
||||||
return if (currentTags?.any
|
genre?.split(",")?.map { it.trim().toLowerCase(Locale.US) } ?: return TYPE_MANGA
|
||||||
{ tag ->
|
return if (currentTags.any { tag -> tag.startsWith("japanese") || isMangaTag(tag) }) {
|
||||||
tag.startsWith("japanese") || tag == "manga" || tag == "манга"
|
|
||||||
} == true)
|
|
||||||
TYPE_MANGA
|
TYPE_MANGA
|
||||||
else if (currentTags?.any
|
} else if (currentTags.any { tag -> tag.startsWith("english") || isComicTag(tag) } ||
|
||||||
{ tag ->
|
isComicSource(sourceName)) {
|
||||||
tag.startsWith("english") || tag == "comic" || tag == "комикс"
|
|
||||||
} == true || isComicSource(sourceName))
|
|
||||||
TYPE_COMIC
|
TYPE_COMIC
|
||||||
else if (currentTags?.any
|
} else if (currentTags.any { tag ->
|
||||||
{ tag ->
|
tag.startsWith("chinese") || isManhuaTag(tag)
|
||||||
tag.startsWith("chinese") || tag == "manhua" || tag == "маньхуа"
|
} || sourceName.contains("manhua", true)) {
|
||||||
} == true ||
|
|
||||||
sourceName.contains("manhua", true))
|
|
||||||
TYPE_MANHUA
|
TYPE_MANHUA
|
||||||
else if (currentTags?.any
|
} else if (currentTags.any { tag -> isManhwaTag(tag) } || isWebtoonSource(sourceName)) {
|
||||||
{ tag ->
|
TYPE_MANHWA
|
||||||
tag == "long strip" || tag == "manhwa" || tag == "манхва"
|
} else if (currentTags.any { tag -> tag.startsWith("webtoon") }) {
|
||||||
} == true || isWebtoonSource(sourceName))
|
|
||||||
TYPE_MANHWA
|
|
||||||
else if (currentTags?.any
|
|
||||||
{ tag ->
|
|
||||||
tag.startsWith("webtoon")
|
|
||||||
} == true)
|
|
||||||
TYPE_WEBTOON
|
TYPE_WEBTOON
|
||||||
else TYPE_MANGA
|
} else {
|
||||||
|
TYPE_MANGA
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,6 +106,22 @@ interface Manga : SManga {
|
||||||
else 0
|
else 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isMangaTag(tag: String): Boolean {
|
||||||
|
return tag in listOf("manga", "манга")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isManhuaTag(tag: String): Boolean {
|
||||||
|
return tag in listOf("manhua", "маньхуа")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isManhwaTag(tag: String): Boolean {
|
||||||
|
return tag in listOf("long strip", "manhwa", "манхва")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isComicTag(tag: String): Boolean {
|
||||||
|
return tag in listOf("comic", "комикс")
|
||||||
|
}
|
||||||
|
|
||||||
fun isWebtoonSource(sourceName: String): Boolean {
|
fun isWebtoonSource(sourceName: String): Boolean {
|
||||||
return sourceName.contains("webtoon", true) ||
|
return sourceName.contains("webtoon", true) ||
|
||||||
sourceName.contains("manwha", true) ||
|
sourceName.contains("manwha", true) ||
|
||||||
|
|
Reference in a new issue