Fix Anibel titles
This commit is contained in:
@@ -37,11 +37,14 @@ class AnibelRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
|
|||||||
return items.mapNotNull { card ->
|
return items.mapNotNull { card ->
|
||||||
val href = card.selectFirst("a").attr("href")
|
val href = card.selectFirst("a").attr("href")
|
||||||
val status = card.select("tr")[2].text()
|
val status = card.select("tr")[2].text()
|
||||||
|
val fullTitle = card.selectFirst("h1.anime-card-title").text()
|
||||||
|
.substringBeforeLast('[')
|
||||||
|
val titleParts = fullTitle.splitTwoParts('/')
|
||||||
Manga(
|
Manga(
|
||||||
id = generateUid(href),
|
id = generateUid(href),
|
||||||
title = card.selectFirst("h1.anime-card-title").text(),
|
title = titleParts?.first?.trim() ?: fullTitle,
|
||||||
coverUrl = card.selectFirst("img").attr("data-src").withDomain(),
|
coverUrl = card.selectFirst("img").attr("data-src").withDomain(),
|
||||||
altTitle = null,
|
altTitle = titleParts?.second?.trim(),
|
||||||
author = null,
|
author = null,
|
||||||
rating = Manga.NO_RATING,
|
rating = Manga.NO_RATING,
|
||||||
url = href,
|
url = href,
|
||||||
@@ -49,7 +52,7 @@ class AnibelRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
|
|||||||
tags = card.select("p.tupe.tag")?.select("a")?.mapNotNullToSet tags@{ x ->
|
tags = card.select("p.tupe.tag")?.select("a")?.mapNotNullToSet tags@{ x ->
|
||||||
MangaTag(
|
MangaTag(
|
||||||
title = x.text(),
|
title = x.text(),
|
||||||
key = x.attr("href") ?: return@tags null,
|
key = x.attr("href")?.substringAfterLast("=") ?: return@tags null,
|
||||||
source = source
|
source = source
|
||||||
)
|
)
|
||||||
}.orEmpty(),
|
}.orEmpty(),
|
||||||
@@ -132,11 +135,14 @@ class AnibelRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
|
|||||||
return items.mapNotNull { card ->
|
return items.mapNotNull { card ->
|
||||||
val href = card.select("a").attr("href")
|
val href = card.select("a").attr("href")
|
||||||
val status = card.select("tr")[2].text()
|
val status = card.select("tr")[2].text()
|
||||||
|
val fullTitle = card.selectFirst("h1.anime-card-title").text()
|
||||||
|
.substringBeforeLast('[')
|
||||||
|
val titleParts = fullTitle.splitTwoParts('/')
|
||||||
Manga(
|
Manga(
|
||||||
id = generateUid(href),
|
id = generateUid(href),
|
||||||
title = card.selectFirst("h1.anime-card-title").text(),
|
title = titleParts?.first?.trim() ?: fullTitle,
|
||||||
coverUrl = card.selectFirst("img").attr("src").withDomain(),
|
coverUrl = card.selectFirst("img").attr("src").withDomain(),
|
||||||
altTitle = null,
|
altTitle = titleParts?.second?.trim(),
|
||||||
author = null,
|
author = null,
|
||||||
rating = Manga.NO_RATING,
|
rating = Manga.NO_RATING,
|
||||||
url = href,
|
url = href,
|
||||||
@@ -144,7 +150,7 @@ class AnibelRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
|
|||||||
tags = card.select("p.tupe.tag")?.select("a")?.mapNotNullToSet tags@{ x ->
|
tags = card.select("p.tupe.tag")?.select("a")?.mapNotNullToSet tags@{ x ->
|
||||||
MangaTag(
|
MangaTag(
|
||||||
title = x.text(),
|
title = x.text(),
|
||||||
key = x.attr("href") ?: return@tags null,
|
key = x.attr("href")?.substringAfterLast("=") ?: return@tags null,
|
||||||
source = source
|
source = source
|
||||||
)
|
)
|
||||||
}.orEmpty(),
|
}.orEmpty(),
|
||||||
|
|||||||
@@ -77,6 +77,20 @@ fun String.ellipsize(maxLength: Int) = if (this.length > maxLength) {
|
|||||||
this.take(maxLength - 1) + Typography.ellipsis
|
this.take(maxLength - 1) + Typography.ellipsis
|
||||||
} else this
|
} else this
|
||||||
|
|
||||||
|
fun String.splitTwoParts(delimiter: Char): Pair<String, String>? {
|
||||||
|
val indices = ArrayList<Int>(4)
|
||||||
|
for ((i, c) in this.withIndex()) {
|
||||||
|
if (c == delimiter) {
|
||||||
|
indices += i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (indices.isEmpty() || indices.size and 1 == 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
val index = indices[indices.size / 2]
|
||||||
|
return substring(0, index) to substring(index + 1)
|
||||||
|
}
|
||||||
|
|
||||||
fun String.urlEncoded(): String = URLEncoder.encode(this, Charsets.UTF_8.name())
|
fun String.urlEncoded(): String = URLEncoder.encode(this, Charsets.UTF_8.name())
|
||||||
|
|
||||||
fun String.toUriOrNull(): Uri? = if (isEmpty()) {
|
fun String.toUriOrNull(): Uri? = if (isEmpty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user