From f34d3445772da4a38d91427661fcd4ca230800ec Mon Sep 17 00:00:00 2001 From: Eugene <35057681+e-shl@users.noreply.github.com> Date: Fri, 21 May 2021 15:13:32 +0500 Subject: [PATCH] Remanga & Libmanga add rate (#7147) --- src/ru/libmanga/build.gradle | 2 +- .../tachiyomi/extension/ru/libmanga/LibManga.kt | 17 ++++++++++++++++- src/ru/remanga/build.gradle | 2 +- .../tachiyomi/extension/ru/remanga/Remanga.kt | 17 ++++++++++++++++- .../tachiyomi/extension/ru/remanga/dto/Dto.kt | 4 +++- 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/ru/libmanga/build.gradle b/src/ru/libmanga/build.gradle index 5340641a0..4a6d4eb68 100644 --- a/src/ru/libmanga/build.gradle +++ b/src/ru/libmanga/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'MangaLib' pkgNameSuffix = 'ru.libmanga' extClass = '.LibManga' - extVersionCode = 47 + extVersionCode = 48 libVersion = '1.2' } diff --git a/src/ru/libmanga/src/eu/kanade/tachiyomi/extension/ru/libmanga/LibManga.kt b/src/ru/libmanga/src/eu/kanade/tachiyomi/extension/ru/libmanga/LibManga.kt index b76ffcfc5..995370755 100644 --- a/src/ru/libmanga/src/eu/kanade/tachiyomi/extension/ru/libmanga/LibManga.kt +++ b/src/ru/libmanga/src/eu/kanade/tachiyomi/extension/ru/libmanga/LibManga.kt @@ -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 } diff --git a/src/ru/remanga/build.gradle b/src/ru/remanga/build.gradle index 3eb1c191d..0e088c7cb 100644 --- a/src/ru/remanga/build.gradle +++ b/src/ru/remanga/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Remanga' pkgNameSuffix = 'ru.remanga' extClass = '.Remanga' - extVersionCode = 23 + extVersionCode = 24 libVersion = '1.2' } diff --git a/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/Remanga.kt b/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/Remanga.kt index 9080cf519..d4007a8f7 100644 --- a/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/Remanga.kt +++ b/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/Remanga.kt @@ -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) } diff --git a/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/dto/Dto.kt b/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/dto/Dto.kt index cc643ad87..db42658e4 100644 --- a/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/dto/Dto.kt +++ b/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/dto/Dto.kt @@ -41,7 +41,9 @@ data class MangaDetDto( val type: GenresDto, val genres: List, val branches: List, - val status: StatusDto + val status: StatusDto, + val avg_rating: String, + val count_rating: Int ) data class PropsDto(