Remanga & Libmanga add rate (#7147)

This commit is contained in:
Eugene 2021-05-21 15:13:32 +05:00 committed by GitHub
parent f0caf41d32
commit f34d344577
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 5 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MangaLib'
pkgNameSuffix = 'ru.libmanga'
extClass = '.LibManga'
extVersionCode = 47
extVersionCode = 48
libVersion = '1.2'
}

View File

@ -177,6 +177,21 @@ class LibManga : ConfigurableSource, HttpSource() {
else -> "манга"
}
val ratingValue = document.select(".media-rating.media-rating_lg div.media-rating__value").text().toFloat() * 2
val ratingVotes = document.select(".media-rating.media-rating_lg div.media-rating__votes").text()
val ratingStar = when {
ratingValue > 9.5 -> "★★★★★"
ratingValue > 9.0 -> "★★★★✬"
ratingValue > 7.5 -> "★★★★☆"
ratingValue > 7.0 -> "★★★✬☆"
ratingValue > 5.5 -> "★★★☆☆"
ratingValue > 5.0 -> "★★✬☆☆"
ratingValue > 3.5 -> "★★☆☆☆"
ratingValue > 3.0 -> "★✬☆☆☆"
ratingValue > 1.5 -> "★☆☆☆☆"
ratingValue > 1.0 -> "✬☆☆☆☆"
else -> "☆☆☆☆☆"
}
val genres = document.select(".media-tags > a").map { it.text() }
manga.title = document.select(".media-name__alt").text()
manga.thumbnail_url = baseUrl + document.select(".media-sidebar__cover > img").attr("src").substringAfter(baseOrig)
@ -192,7 +207,7 @@ class LibManga : ConfigurableSource, HttpSource() {
else -> SManga.UNKNOWN
}
manga.genre = genres.plusElement(category).joinToString { it.trim() }
manga.description = document.select(".media-name__main").text() + "\nАльтернативные названия:\n" + document.select(".media-info-list__item_alt-names .media-info-list__value div").map { it.text() }.joinToString(" / ") + "\n\n" + document.select(".media-description__text").text()
manga.description = document.select(".media-name__main").text() + "\n" + ratingStar + " " + ratingValue + " (голосов: " + ratingVotes + ")" + "\nАльтернативные названия:\n" + document.select(".media-info-list__item_alt-names .media-info-list__value div").map { it.text() }.joinToString(" / ") + "\n\n" + document.select(".media-description__text").text()
return manga
}

View File

@ -5,7 +5,7 @@ ext {
extName = 'Remanga'
pkgNameSuffix = 'ru.remanga'
extClass = '.Remanga'
extVersionCode = 23
extVersionCode = 24
libVersion = '1.2'
}

View File

@ -207,13 +207,28 @@ class Remanga : ConfigurableSource, HttpSource() {
}
private fun MangaDetDto.toSManga(): SManga {
val ratingValue = avg_rating.toFloat()
val ratingStar = when {
ratingValue > 9.5 -> "★★★★★"
ratingValue > 9.0 -> "★★★★✬"
ratingValue > 7.5 -> "★★★★☆"
ratingValue > 7.0 -> "★★★✬☆"
ratingValue > 5.5 -> "★★★☆☆"
ratingValue > 5.0 -> "★★✬☆☆"
ratingValue > 3.5 -> "★★☆☆☆"
ratingValue > 3.0 -> "★✬☆☆☆"
ratingValue > 1.5 -> "★☆☆☆☆"
ratingValue > 1.0 -> "✬☆☆☆☆"
else -> "☆☆☆☆☆"
}
val o = this
return SManga.create().apply {
// Do not change the title name to ensure work with a multilingual catalog!
title = en_name
url = "/api/titles/$dir/"
thumbnail_url = "$baseUrl/${img.high}"
this.description = rus_name + "\nАльтернативные названия:\n" + another_name + "\n\n" + Jsoup.parse(o.description).text()
this.description = rus_name + "\n" + ratingStar + " " + ratingValue + " (голосов: " + count_rating + ")" + "\nАльтернативные названия:\n" + another_name + "\n\n" + Jsoup.parse(o.description).text()
genre = (genres + parseType(type)).joinToString { it.name }
status = parseStatus(o.status.id)
}

View File

@ -41,7 +41,9 @@ data class MangaDetDto(
val type: GenresDto,
val genres: List<GenresDto>,
val branches: List<BranchesDto>,
val status: StatusDto
val status: StatusDto,
val avg_rating: String,
val count_rating: Int
)
data class PropsDto(