Fix tags case

pull/100/head
Koitharu 4 years ago
parent 5d26743c8f
commit 27658eea20
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

@ -237,7 +237,6 @@ class AnibelRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
when { when {
c == '-' -> { c == '-' -> {
builder.setCharAt(i, ' ') builder.setCharAt(i, ' ')
capitalize = true
} }
capitalize -> { capitalize -> {
builder.setCharAt(i, c.uppercaseChar()) builder.setCharAt(i, c.uppercaseChar())

@ -61,7 +61,7 @@ abstract class ChanRepository(loaderContext: MangaLoaderContext) : RemoteMangaRe
tags = runCatching { tags = runCatching {
row.selectFirst("div.genre")?.select("a")?.mapToSet { row.selectFirst("div.genre")?.select("a")?.mapToSet {
MangaTag( MangaTag(
title = it.text(), title = it.text().toTitleCase(),
key = it.attr("href").substringAfterLast('/').urlEncoded(), key = it.attr("href").substringAfterLast('/').urlEncoded(),
source = source source = source
) )
@ -136,7 +136,7 @@ abstract class ChanRepository(loaderContext: MangaLoaderContext) : RemoteMangaRe
return root.select("li.sidetag").mapToSet { li -> return root.select("li.sidetag").mapToSet { li ->
val a = li.children().last() ?: throw ParseException("a is null") val a = li.children().last() ?: throw ParseException("a is null")
MangaTag( MangaTag(
title = a.text().toCamelCase(), title = a.text().toTitleCase(),
key = a.attr("href").substringAfterLast('/'), key = a.attr("href").substringAfterLast('/'),
source = source source = source
) )

@ -85,7 +85,7 @@ class DesuMeRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
tags = json.getJSONArray("genres").mapToSet { tags = json.getJSONArray("genres").mapToSet {
MangaTag( MangaTag(
key = it.getString("text"), key = it.getString("text"),
title = it.getString("russian"), title = it.getString("russian").toTitleCase(),
source = manga.source source = manga.source
) )
}, },
@ -133,7 +133,7 @@ class DesuMeRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
MangaTag( MangaTag(
source = source, source = source,
key = it.selectFirst("input")?.attr("data-genre") ?: parseFailed(), key = it.selectFirst("input")?.attr("data-genre") ?: parseFailed(),
title = it.selectFirst("label")?.text() ?: parseFailed() title = it.selectFirst("label")?.text()?.toTitleCase() ?: parseFailed()
) )
} }
} }

@ -85,7 +85,7 @@ class ExHentaiRepository(
val tagsDiv = glink.nextElementSibling() ?: parseFailed("tags div not found") val tagsDiv = glink.nextElementSibling() ?: parseFailed("tags div not found")
val mainTag = td2.selectFirst("div.cn")?.let { div -> val mainTag = td2.selectFirst("div.cn")?.let { div ->
MangaTag( MangaTag(
title = div.text(), title = div.text().toTitleCase(),
key = tagIdByClass(div.classNames()) ?: return@let null, key = tagIdByClass(div.classNames()) ?: return@let null,
source = source, source = source,
) )
@ -181,7 +181,7 @@ class ExHentaiRepository(
val id = div.id().substringAfterLast('_').toIntOrNull() val id = div.id().substringAfterLast('_').toIntOrNull()
?: return@mapNotNullToSet null ?: return@mapNotNullToSet null
MangaTag( MangaTag(
title = div.text(), title = div.text().toTitleCase(),
key = id.toString(), key = id.toString(),
source = source source = source
) )

@ -89,7 +89,7 @@ abstract class GroupleRepository(loaderContext: MangaLoaderContext) :
tileInfo?.select("a.element-link") tileInfo?.select("a.element-link")
?.mapToSet { ?.mapToSet {
MangaTag( MangaTag(
title = it.text(), title = it.text().toTitleCase(),
key = it.attr("href").substringAfterLast('/'), key = it.attr("href").substringAfterLast('/'),
source = source source = source
) )
@ -119,7 +119,7 @@ abstract class GroupleRepository(loaderContext: MangaLoaderContext) :
.mapNotNull { .mapNotNull {
val a = it.selectFirst("a.element-link") ?: return@mapNotNull null val a = it.selectFirst("a.element-link") ?: return@mapNotNull null
MangaTag( MangaTag(
title = a.text(), title = a.text().toTitleCase(),
key = a.attr("href").substringAfterLast('/'), key = a.attr("href").substringAfterLast('/'),
source = source source = source
) )
@ -183,7 +183,7 @@ abstract class GroupleRepository(loaderContext: MangaLoaderContext) :
?.selectFirst("table.table") ?: parseFailed("Cannot find root") ?.selectFirst("table.table") ?: parseFailed("Cannot find root")
return root.select("a.element-link").mapToSet { a -> return root.select("a.element-link").mapToSet { a ->
MangaTag( MangaTag(
title = a.text().toCamelCase(), title = a.text().toTitleCase(),
key = a.attr("href").substringAfterLast('/'), key = a.attr("href").substringAfterLast('/'),
source = source source = source
) )

@ -5,6 +5,7 @@ import org.koitharu.kotatsu.core.exceptions.ParseException
import org.koitharu.kotatsu.core.model.* import org.koitharu.kotatsu.core.model.*
import org.koitharu.kotatsu.utils.ext.mapToSet import org.koitharu.kotatsu.utils.ext.mapToSet
import org.koitharu.kotatsu.utils.ext.parseHtml import org.koitharu.kotatsu.utils.ext.parseHtml
import org.koitharu.kotatsu.utils.ext.toTitleCase
class HenChanRepository(loaderContext: MangaLoaderContext) : ChanRepository(loaderContext) { class HenChanRepository(loaderContext: MangaLoaderContext) : ChanRepository(loaderContext) {
@ -36,7 +37,7 @@ class HenChanRepository(loaderContext: MangaLoaderContext) : ChanRepository(load
tags = root.selectFirst("div.sidetags")?.select("li.sidetag")?.mapToSet { tags = root.selectFirst("div.sidetags")?.select("li.sidetag")?.mapToSet {
val a = it.children().last() ?: parseFailed("Invalid tag") val a = it.children().last() ?: parseFailed("Invalid tag")
MangaTag( MangaTag(
title = a.text(), title = a.text().toTitleCase(),
key = a.attr("href").substringAfterLast('/'), key = a.attr("href").substringAfterLast('/'),
source = source source = source
) )

@ -94,7 +94,8 @@ class MangaDexRepository(loaderContext: MangaLoaderContext) : RemoteMangaReposit
MangaTag( MangaTag(
title = tag.getJSONObject("attributes") title = tag.getJSONObject("attributes")
.getJSONObject("name") .getJSONObject("name")
.firstStringValue(), .firstStringValue()
.toTitleCase(),
key = tag.getString("id"), key = tag.getString("id"),
source = source, source = source,
) )
@ -194,7 +195,7 @@ class MangaDexRepository(loaderContext: MangaLoaderContext) : RemoteMangaReposit
.getJSONArray("data") .getJSONArray("data")
return tags.mapToSet { jo -> return tags.mapToSet { jo ->
MangaTag( MangaTag(
title = jo.getJSONObject("attributes").getJSONObject("name").firstStringValue(), title = jo.getJSONObject("attributes").getJSONObject("name").firstStringValue().toTitleCase(),
key = jo.getString("id"), key = jo.getString("id"),
source = source, source = source,
) )

@ -139,7 +139,7 @@ open class MangaLibRepository(loaderContext: MangaLoaderContext) :
tags = info?.selectFirst("div.media-tags") tags = info?.selectFirst("div.media-tags")
?.select("a.media-tag-item")?.mapToSet { a -> ?.select("a.media-tag-item")?.mapToSet { a ->
MangaTag( MangaTag(
title = a.text().toCamelCase(), title = a.text().toTitleCase(),
key = a.attr("href").substringAfterLast('='), key = a.attr("href").substringAfterLast('='),
source = source source = source
) )
@ -203,7 +203,7 @@ open class MangaLibRepository(loaderContext: MangaLoaderContext) :
result += MangaTag( result += MangaTag(
source = source, source = source,
key = x.getInt("id").toString(), key = x.getInt("id").toString(),
title = x.getString("name").toCamelCase() title = x.getString("name").toTitleCase(),
) )
} }
return result return result

@ -91,7 +91,7 @@ class MangaOwlRepository(loaderContext: MangaLoaderContext) : RemoteMangaReposit
.mapNotNull { .mapNotNull {
val a = it.selectFirst("a") ?: return@mapNotNull null val a = it.selectFirst("a") ?: return@mapNotNull null
MangaTag( MangaTag(
title = a.text(), title = a.text().toTitleCase(),
key = a.attr("href"), key = a.attr("href"),
source = source source = source
) )
@ -144,7 +144,7 @@ class MangaOwlRepository(loaderContext: MangaLoaderContext) : RemoteMangaReposit
return root.mapToSet { p -> return root.mapToSet { p ->
val a = p.selectFirst("a") ?: parseFailed("a is null") val a = p.selectFirst("a") ?: parseFailed("a is null")
MangaTag( MangaTag(
title = a.text().toCamelCase(), title = a.text().toTitleCase(),
key = a.attr("href"), key = a.attr("href"),
source = source source = source
) )

@ -80,7 +80,7 @@ class MangaTownRepository(loaderContext: MangaLoaderContext) :
}, },
tags = li.selectFirst("p.keyWord")?.select("a")?.mapNotNullToSet tags@{ x -> tags = li.selectFirst("p.keyWord")?.select("a")?.mapNotNullToSet tags@{ x ->
MangaTag( MangaTag(
title = x.attr("title"), title = x.attr("title").toTitleCase(),
key = x.attr("href").parseTagKey() ?: return@tags null, key = x.attr("href").parseTagKey() ?: return@tags null,
source = MangaSource.MANGATOWN source = MangaSource.MANGATOWN
) )
@ -104,7 +104,7 @@ class MangaTownRepository(loaderContext: MangaLoaderContext) :
x.selectFirst("b")?.ownText() == "Genre(s):" x.selectFirst("b")?.ownText() == "Genre(s):"
}?.select("a")?.mapNotNull { a -> }?.select("a")?.mapNotNull { a ->
MangaTag( MangaTag(
title = a.attr("title"), title = a.attr("title").toTitleCase(),
key = a.attr("href").parseTagKey() ?: return@mapNotNull null, key = a.attr("href").parseTagKey() ?: return@mapNotNull null,
source = MangaSource.MANGATOWN source = MangaSource.MANGATOWN
) )
@ -172,7 +172,7 @@ class MangaTownRepository(loaderContext: MangaLoaderContext) :
MangaTag( MangaTag(
source = MangaSource.MANGATOWN, source = MangaSource.MANGATOWN,
key = key, key = key,
title = a.text() title = a.text().toTitleCase()
) )
} }
} }

@ -62,7 +62,7 @@ class MangareadRepository(
tags = summary?.selectFirst(".mg_genres")?.select("a")?.mapToSet { a -> tags = summary?.selectFirst(".mg_genres")?.select("a")?.mapToSet { a ->
MangaTag( MangaTag(
key = a.attr("href").removeSuffix("/").substringAfterLast('/'), key = a.attr("href").removeSuffix("/").substringAfterLast('/'),
title = a.text(), title = a.text().toTitleCase(),
source = MangaSource.MANGAREAD source = MangaSource.MANGAREAD
) )
}.orEmpty(), }.orEmpty(),
@ -91,7 +91,7 @@ class MangareadRepository(
} }
MangaTag( MangaTag(
key = href, key = href,
title = a.text(), title = a.text().toTitleCase(),
source = MangaSource.MANGAREAD source = MangaSource.MANGAREAD
) )
} }
@ -113,7 +113,7 @@ class MangareadRepository(
?.mapNotNullToSet { a -> ?.mapNotNullToSet { a ->
MangaTag( MangaTag(
key = a.attr("href").removeSuffix("/").substringAfterLast('/'), key = a.attr("href").removeSuffix("/").substringAfterLast('/'),
title = a.text(), title = a.text().toTitleCase(),
source = MangaSource.MANGAREAD source = MangaSource.MANGAREAD
) )
} ?: manga.tags, } ?: manga.tags,

@ -94,7 +94,7 @@ abstract class NineMangaRepository(
tags = infoRoot.getElementsByAttributeValue("itemprop", "genre").first() tags = infoRoot.getElementsByAttributeValue("itemprop", "genre").first()
?.select("a")?.mapToSet { a -> ?.select("a")?.mapToSet { a ->
MangaTag( MangaTag(
title = a.text(), title = a.text().toTitleCase(),
key = a.attr("href").substringBetween("/", "."), key = a.attr("href").substringBetween("/", "."),
source = source, source = source,
) )

@ -73,7 +73,7 @@ class RemangaRepository(loaderContext: MangaLoaderContext) : RemoteMangaReposito
author = null, author = null,
tags = jo.optJSONArray("genres")?.mapToSet { g -> tags = jo.optJSONArray("genres")?.mapToSet { g ->
MangaTag( MangaTag(
title = g.getString("name"), title = g.getString("name").toTitleCase(),
key = g.getInt("id").toString(), key = g.getInt("id").toString(),
source = MangaSource.REMANGA source = MangaSource.REMANGA
) )
@ -109,7 +109,7 @@ class RemangaRepository(loaderContext: MangaLoaderContext) : RemoteMangaReposito
}, },
tags = content.getJSONArray("genres").mapToSet { g -> tags = content.getJSONArray("genres").mapToSet { g ->
MangaTag( MangaTag(
title = g.getString("name"), title = g.getString("name").toTitleCase(),
key = g.getInt("id").toString(), key = g.getInt("id").toString(),
source = MangaSource.REMANGA source = MangaSource.REMANGA
) )
@ -175,7 +175,7 @@ class RemangaRepository(loaderContext: MangaLoaderContext) : RemoteMangaReposito
.parseJson().getJSONObject("content").getJSONArray("genres") .parseJson().getJSONObject("content").getJSONArray("genres")
return content.mapToSet { jo -> return content.mapToSet { jo ->
MangaTag( MangaTag(
title = jo.getString("name"), title = jo.getString("name").toTitleCase(),
key = jo.getInt("id").toString(), key = jo.getInt("id").toString(),
source = source source = source
) )

@ -7,10 +7,7 @@ import org.koitharu.kotatsu.core.model.Manga
import org.koitharu.kotatsu.core.model.MangaChapter import org.koitharu.kotatsu.core.model.MangaChapter
import org.koitharu.kotatsu.core.model.MangaSource import org.koitharu.kotatsu.core.model.MangaSource
import org.koitharu.kotatsu.core.model.MangaTag import org.koitharu.kotatsu.core.model.MangaTag
import org.koitharu.kotatsu.utils.ext.getBooleanOrDefault import org.koitharu.kotatsu.utils.ext.*
import org.koitharu.kotatsu.utils.ext.getLongOrDefault
import org.koitharu.kotatsu.utils.ext.getStringOrNull
import org.koitharu.kotatsu.utils.ext.mapToSet
class MangaIndex(source: String?) { class MangaIndex(source: String?) {
@ -61,7 +58,7 @@ class MangaIndex(source: String?) {
description = json.getStringOrNull("description"), description = json.getStringOrNull("description"),
tags = json.getJSONArray("tags").mapToSet { x -> tags = json.getJSONArray("tags").mapToSet { x ->
MangaTag( MangaTag(
title = x.getString("title"), title = x.getString("title").toTitleCase(),
key = x.getString("key"), key = x.getString("key"),
source = source source = source
) )

Loading…
Cancel
Save