From 077b90b80ea6c832c888234c1a152f72027776bb Mon Sep 17 00:00:00 2001 From: Eugene <35057681+e-shl@users.noreply.github.com> Date: Sat, 8 May 2021 15:25:49 +0500 Subject: [PATCH] Altername and open out for [RU] source (#6896) * Add Altername * OpenOut * RenameActivity --- src/ru/libmanga/build.gradle | 2 +- .../extension/ru/libmanga/LibManga.kt | 3 +- src/ru/mangapoisk/build.gradle | 2 +- .../extension/ru/mangapoisk/MangaPoisk.kt | 1 + src/ru/mintmanga/AndroidManifest.xml | 24 ++++++++++- src/ru/mintmanga/build.gradle | 2 +- .../extension/ru/mintmanga/Mintmanga.kt | 33 ++++++++++++++- .../ru/mintmanga/MintmangaActivity.kt | 40 +++++++++++++++++++ src/ru/readmanga/AndroidManifest.xml | 24 ++++++++++- src/ru/readmanga/build.gradle | 2 +- .../extension/ru/readmanga/Readmanga.kt | 34 +++++++++++++++- .../ru/readmanga/ReadmangaActivity.kt | 40 +++++++++++++++++++ src/ru/remanga/AndroidManifest.xml | 24 ++++++++++- src/ru/remanga/build.gradle | 2 +- .../tachiyomi/extension/ru/remanga/Remanga.kt | 26 +++++++++++- .../extension/ru/remanga/RemangaActivity.kt | 40 +++++++++++++++++++ .../tachiyomi/extension/ru/remanga/dto/Dto.kt | 1 + 17 files changed, 288 insertions(+), 12 deletions(-) create mode 100644 src/ru/mintmanga/src/eu/kanade/tachiyomi/extension/ru/mintmanga/MintmangaActivity.kt create mode 100644 src/ru/readmanga/src/eu/kanade/tachiyomi/extension/ru/readmanga/ReadmangaActivity.kt create mode 100644 src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/RemangaActivity.kt diff --git a/src/ru/libmanga/build.gradle b/src/ru/libmanga/build.gradle index 850e491b9..66c378114 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 = 41 + extVersionCode = 42 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 66ab8894a..8367966f7 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 @@ -171,6 +171,7 @@ class LibManga : ConfigurableSource, HttpSource() { } val genres = document.select(".media-tags > a").map { it.text() } + manga.title = document.select(".media-name__alt").text() manga.thumbnail_url = document.select(".media-sidebar__cover > img").attr("src") manga.author = body.select("div.media-info-list__title:contains(Автор) + div").text() manga.artist = body.select("div.media-info-list__title:contains(Художник) + div").text() @@ -184,7 +185,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-description__text").text() + 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() return manga } diff --git a/src/ru/mangapoisk/build.gradle b/src/ru/mangapoisk/build.gradle index 50babf7f1..b177e0e6d 100644 --- a/src/ru/mangapoisk/build.gradle +++ b/src/ru/mangapoisk/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'MangaPoisk' pkgNameSuffix = 'ru.mangapoisk' extClass = '.MangaPoisk' - extVersionCode = 1 + extVersionCode = 2 libVersion = '1.2' } diff --git a/src/ru/mangapoisk/src/eu/kanade/tachiyomi/extension/ru/mangapoisk/MangaPoisk.kt b/src/ru/mangapoisk/src/eu/kanade/tachiyomi/extension/ru/mangapoisk/MangaPoisk.kt index 07a61b774..2b9a4009e 100644 --- a/src/ru/mangapoisk/src/eu/kanade/tachiyomi/extension/ru/mangapoisk/MangaPoisk.kt +++ b/src/ru/mangapoisk/src/eu/kanade/tachiyomi/extension/ru/mangapoisk/MangaPoisk.kt @@ -115,6 +115,7 @@ class MangaPoisk : ParsedHttpSource() { override fun mangaDetailsParse(document: Document): SManga { val infoElement = document.select("article div.card-body").first() val manga = SManga.create() + manga.title = document.select(".post-name").text() manga.genre = infoElement.select(".post-info > span:eq(10) > a").joinToString { it.text() } manga.description = infoElement.select(".post-info > div .manga-description.entry").text() manga.status = parseStatus(infoElement.select(".post-info > span:eq(7)").text()) diff --git a/src/ru/mintmanga/AndroidManifest.xml b/src/ru/mintmanga/AndroidManifest.xml index 30deb7f79..03124de75 100644 --- a/src/ru/mintmanga/AndroidManifest.xml +++ b/src/ru/mintmanga/AndroidManifest.xml @@ -1,2 +1,24 @@ - + + + + + + + + + + + + + + + + diff --git a/src/ru/mintmanga/build.gradle b/src/ru/mintmanga/build.gradle index 1c3da9ae2..b1ede9bb1 100644 --- a/src/ru/mintmanga/build.gradle +++ b/src/ru/mintmanga/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Mintmanga' pkgNameSuffix = 'ru.mintmanga' extClass = '.Mintmanga' - extVersionCode = 26 + extVersionCode = 27 libVersion = '1.2' } diff --git a/src/ru/mintmanga/src/eu/kanade/tachiyomi/extension/ru/mintmanga/Mintmanga.kt b/src/ru/mintmanga/src/eu/kanade/tachiyomi/extension/ru/mintmanga/Mintmanga.kt index 04a33bf51..6de6dd9d9 100644 --- a/src/ru/mintmanga/src/eu/kanade/tachiyomi/extension/ru/mintmanga/Mintmanga.kt +++ b/src/ru/mintmanga/src/eu/kanade/tachiyomi/extension/ru/mintmanga/Mintmanga.kt @@ -5,6 +5,7 @@ import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.FilterList +import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga @@ -137,7 +138,11 @@ class Mintmanga : ParsedHttpSource() { manga.author = authorElement manga.artist = infoElement.select("span.elem_illustrator").first()?.text() manga.genre = infoElement.select("span.elem_genre").text().split(",").plusElement(category).joinToString { it.trim() } - manga.description = infoElement.select("div.manga-description").text() + var altName = "" + if (infoElement.select(".another-names").isNotEmpty()) { + altName = "Альтернативные названия:\n" + infoElement.select(".another-names").text() + "\n\n" + } + manga.description = altName + infoElement.select("div.manga-description").text() manga.status = parseStatus(infoElement.html()) manga.thumbnail_url = infoElement.select("img").attr("data-full") return manga @@ -271,6 +276,32 @@ class Mintmanga : ParsedHttpSource() { }.build() return GET(page.imageUrl!!, imgHeader) } + private fun searchMangaByIdRequest(id: String): Request { + return GET("$baseUrl/$id", headers) + } + + override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable { + return if (query.startsWith(PREFIX_SLUG_SEARCH)) { + val realQuery = query.removePrefix(PREFIX_SLUG_SEARCH) + client.newCall(searchMangaByIdRequest(realQuery)) + .asObservableSuccess() + .map { response -> + val details = mangaDetailsParse(response) + details.url = "/$realQuery" + MangasPage(listOf(details), false) + } + } else { + client.newCall(searchMangaRequest(page, query, filters)) + .asObservableSuccess() + .map { response -> + searchMangaParse(response) + } + } + } + + companion object { + const val PREFIX_SLUG_SEARCH = "slug:" + } private class OrderBy : Filter.Select( "Сортировать\n(отдельно от фильтров)", diff --git a/src/ru/mintmanga/src/eu/kanade/tachiyomi/extension/ru/mintmanga/MintmangaActivity.kt b/src/ru/mintmanga/src/eu/kanade/tachiyomi/extension/ru/mintmanga/MintmangaActivity.kt new file mode 100644 index 000000000..34432a5eb --- /dev/null +++ b/src/ru/mintmanga/src/eu/kanade/tachiyomi/extension/ru/mintmanga/MintmangaActivity.kt @@ -0,0 +1,40 @@ +package eu.kanade.tachiyomi.extension.ru.mintmanga + +import android.app.Activity +import android.content.ActivityNotFoundException +import android.content.Intent +import android.os.Bundle +import android.util.Log +import kotlin.system.exitProcess +/** + * Springboard that accepts https://mintmanga.live/xxx intents and redirects them to + * the main tachiyomi process. The idea is to not install the intent filter unless + * you have this extension installed, but still let the main tachiyomi app control + * things. + */ +class MintmangaActivity : Activity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val pathSegments = intent?.data?.pathSegments + if (pathSegments != null && pathSegments.size > 0) { + val titleid = pathSegments[0] + val mainIntent = Intent().apply { + action = "eu.kanade.tachiyomi.SEARCH" + putExtra("query", "${Mintmanga.PREFIX_SLUG_SEARCH}$titleid") + putExtra("filter", packageName) + } + + try { + startActivity(mainIntent) + } catch (e: ActivityNotFoundException) { + Log.e("MintmangaActivity", e.toString()) + } + } else { + Log.e("MintmangaaActivity", "could not parse uri from intent $intent") + } + + finish() + exitProcess(0) + } +} diff --git a/src/ru/readmanga/AndroidManifest.xml b/src/ru/readmanga/AndroidManifest.xml index 30deb7f79..3164cd86d 100644 --- a/src/ru/readmanga/AndroidManifest.xml +++ b/src/ru/readmanga/AndroidManifest.xml @@ -1,2 +1,24 @@ - + + + + + + + + + + + + + + + + diff --git a/src/ru/readmanga/build.gradle b/src/ru/readmanga/build.gradle index 00db7d8b7..0ea20226e 100644 --- a/src/ru/readmanga/build.gradle +++ b/src/ru/readmanga/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Readmanga' pkgNameSuffix = 'ru.readmanga' extClass = '.Readmanga' - extVersionCode = 25 + extVersionCode = 26 libVersion = '1.2' } diff --git a/src/ru/readmanga/src/eu/kanade/tachiyomi/extension/ru/readmanga/Readmanga.kt b/src/ru/readmanga/src/eu/kanade/tachiyomi/extension/ru/readmanga/Readmanga.kt index 78e99d8e6..1640500b0 100644 --- a/src/ru/readmanga/src/eu/kanade/tachiyomi/extension/ru/readmanga/Readmanga.kt +++ b/src/ru/readmanga/src/eu/kanade/tachiyomi/extension/ru/readmanga/Readmanga.kt @@ -5,6 +5,7 @@ import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.FilterList +import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga @@ -137,7 +138,11 @@ class Readmanga : ParsedHttpSource() { manga.author = authorElement manga.artist = infoElement.select("span.elem_illustrator").first()?.text() manga.genre = infoElement.select("span.elem_genre").text().split(",").plusElement(category).joinToString { it.trim() } - manga.description = infoElement.select("div.manga-description").text() + var altName = "" + if (infoElement.select(".another-names").isNotEmpty()) { + altName = "Альтернативные названия:\n" + infoElement.select(".another-names").text() + "\n\n" + } + manga.description = altName + infoElement.select("div.manga-description").text() manga.status = parseStatus(infoElement.html()) manga.thumbnail_url = infoElement.select("img").attr("data-full") return manga @@ -272,6 +277,33 @@ class Readmanga : ParsedHttpSource() { return GET(page.imageUrl!!, imgHeader) } + private fun searchMangaByIdRequest(id: String): Request { + return GET("$baseUrl/$id", headers) + } + + override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable { + return if (query.startsWith(PREFIX_SLUG_SEARCH)) { + val realQuery = query.removePrefix(PREFIX_SLUG_SEARCH) + client.newCall(searchMangaByIdRequest(realQuery)) + .asObservableSuccess() + .map { response -> + val details = mangaDetailsParse(response) + details.url = "/$realQuery" + MangasPage(listOf(details), false) + } + } else { + client.newCall(searchMangaRequest(page, query, filters)) + .asObservableSuccess() + .map { response -> + searchMangaParse(response) + } + } + } + + companion object { + const val PREFIX_SLUG_SEARCH = "slug:" + } + private class OrderBy : Filter.Select( "Сортировать\n(отдельно от фильтров)", arrayOf("Без(фильтры)", "По алфавиту", "По популярности", "Популярно сейчас", "По рейтингу", "Новинки", "По дате обновления") diff --git a/src/ru/readmanga/src/eu/kanade/tachiyomi/extension/ru/readmanga/ReadmangaActivity.kt b/src/ru/readmanga/src/eu/kanade/tachiyomi/extension/ru/readmanga/ReadmangaActivity.kt new file mode 100644 index 000000000..860ff0fd3 --- /dev/null +++ b/src/ru/readmanga/src/eu/kanade/tachiyomi/extension/ru/readmanga/ReadmangaActivity.kt @@ -0,0 +1,40 @@ +package eu.kanade.tachiyomi.extension.ru.readmanga + +import android.app.Activity +import android.content.ActivityNotFoundException +import android.content.Intent +import android.os.Bundle +import android.util.Log +import kotlin.system.exitProcess +/** + * Springboard that accepts https://readmanga.live/xxx intents and redirects them to + * the main tachiyomi process. The idea is to not install the intent filter unless + * you have this extension installed, but still let the main tachiyomi app control + * things. + */ +class ReadmangaActivity : Activity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val pathSegments = intent?.data?.pathSegments + if (pathSegments != null && pathSegments.size > 0) { + val titleid = pathSegments[0] + val mainIntent = Intent().apply { + action = "eu.kanade.tachiyomi.SEARCH" + putExtra("query", "${Readmanga.PREFIX_SLUG_SEARCH}$titleid") + putExtra("filter", packageName) + } + + try { + startActivity(mainIntent) + } catch (e: ActivityNotFoundException) { + Log.e("ReadmangaActivity", e.toString()) + } + } else { + Log.e("ReadmangaActivity", "could not parse uri from intent $intent") + } + + finish() + exitProcess(0) + } +} diff --git a/src/ru/remanga/AndroidManifest.xml b/src/ru/remanga/AndroidManifest.xml index 30deb7f79..ce4748114 100644 --- a/src/ru/remanga/AndroidManifest.xml +++ b/src/ru/remanga/AndroidManifest.xml @@ -1,2 +1,24 @@ - + + + + + + + + + + + + + + + + diff --git a/src/ru/remanga/build.gradle b/src/ru/remanga/build.gradle index a07800a0e..899074c1e 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 = 20 + extVersionCode = 21 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 3c98a126d..f955029c6 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 @@ -213,7 +213,7 @@ class Remanga : ConfigurableSource, HttpSource() { title = en_name url = "/api/titles/$dir/" thumbnail_url = "$baseUrl/${img.high}" - this.description = "Русское название: " + rus_name + "\n" + Jsoup.parse(o.description).text() + this.description = rus_name + "\nАльтернативные названия:\n" + another_name + "\n\n" + Jsoup.parse(o.description).text() genre = (genres + parseType(type)).joinToString { it.name } status = parseStatus(o.status.id) } @@ -339,6 +339,29 @@ class Remanga : ConfigurableSource, HttpSource() { override fun imageUrlParse(response: Response): String = throw NotImplementedError("Unused") + private fun searchMangaByIdRequest(id: String): Request { + return GET("$baseUrl/api/titles/$id", headers) + } + + override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable { + return if (query.startsWith(PREFIX_SLUG_SEARCH)) { + val realQuery = query.removePrefix(PREFIX_SLUG_SEARCH) + client.newCall(searchMangaByIdRequest(realQuery)) + .asObservableSuccess() + .map { response -> + val details = mangaDetailsParse(response) + details.url = "/$realQuery" + MangasPage(listOf(details), false) + } + } else { + client.newCall(searchMangaRequest(page, query, filters)) + .asObservableSuccess() + .map { response -> + searchMangaParse(response) + } + } + } + override fun imageRequest(page: Page): Request { val refererHeaders = headersBuilder().build() return GET(page.imageUrl!!, refererHeaders) @@ -577,5 +600,6 @@ class Remanga : ConfigurableSource, HttpSource() { private const val USERNAME_DEFAULT = "" private const val PASSWORD_TITLE = "Password" private const val PASSWORD_DEFAULT = "" + const val PREFIX_SLUG_SEARCH = "slug:" } } diff --git a/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/RemangaActivity.kt b/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/RemangaActivity.kt new file mode 100644 index 000000000..05775348e --- /dev/null +++ b/src/ru/remanga/src/eu/kanade/tachiyomi/extension/ru/remanga/RemangaActivity.kt @@ -0,0 +1,40 @@ +package eu.kanade.tachiyomi.extension.ru.remanga + +import android.app.Activity +import android.content.ActivityNotFoundException +import android.content.Intent +import android.os.Bundle +import android.util.Log +import kotlin.system.exitProcess +/** + * Springboard that accepts https://remanga.org/manga/xxx intents and redirects them to + * the main tachiyomi process. The idea is to not install the intent filter unless + * you have this extension installed, but still let the main tachiyomi app control + * things. + */ +class RemangaActivity : Activity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val pathSegments = intent?.data?.pathSegments + if (pathSegments != null && pathSegments.size > 1) { + val titleid = pathSegments[1] + val mainIntent = Intent().apply { + action = "eu.kanade.tachiyomi.SEARCH" + putExtra("query", "${Remanga.PREFIX_SLUG_SEARCH}$titleid") + putExtra("filter", packageName) + } + + try { + startActivity(mainIntent) + } catch (e: ActivityNotFoundException) { + Log.e("RemangaActivity", e.toString()) + } + } else { + Log.e("RemangaActivity", "could not parse uri from intent $intent") + } + + finish() + exitProcess(0) + } +} 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 7fa4555b9..cc643ad87 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 @@ -33,6 +33,7 @@ data class MangaDetDto( val id: Long, val en_name: String, val rus_name: String, + val another_name: String, val dir: String, val description: String, val issue_year: Int,