From 3fd2222c994aeeb19c92f54f396a860ba9c1a076 Mon Sep 17 00:00:00 2001 From: Taumer Date: Sun, 15 Apr 2018 13:47:39 +0300 Subject: [PATCH] Update russian sources (#1362) 1) moved headerBuilder to imageRequest 2) changed the method of gets thumbnails 3) updated js for genres 4) update genre list --- .../source/online/russian/Mangachan.kt | 36 ++++++++----------- .../source/online/russian/Mintmanga.kt | 33 ++++++++++------- .../source/online/russian/Readmanga.kt | 33 ++++++++++------- 3 files changed, 57 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mangachan.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mangachan.kt index 6bcc61707a..5f7f057f0a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mangachan.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mangachan.kt @@ -49,8 +49,12 @@ class Mangachan : ParsedHttpSource() { } } } - is OrderBy -> { if (filter.state!!.ascending && filter.state!!.index == 0) { statusParam = false } } - is Status -> status = arrayOf("", "all_done", "end", "ongoing", "new_ch")[filter.state] + is OrderBy -> { + if (filter.state!!.ascending && filter.state!!.index == 0) { + statusParam = false + } + } + is Status -> status = arrayOf("", "all_done", "end", "ongoing", "new_ch")[filter.state] } } @@ -103,6 +107,7 @@ class Mangachan : ParsedHttpSource() { override fun popularMangaFromElement(element: Element): SManga { val manga = SManga.create() + manga.thumbnail_url = element.select("div.manga_images img").first().attr("src") element.select("h2 > a").first().let { manga.setUrlWithoutDomain(it.attr("href")) manga.title = it.text() @@ -220,32 +225,22 @@ class Mangachan : ParsedHttpSource() { GenreList(getGenreList()) ) -// private class StatusList(status: List) : Filter.Group("Статус", status) -// private class Status(name: String, val id: String) : Filter.CheckBox(name, false) -// private fun getStatusList() = listOf( -// Status("Перевод завершен", "/all_done"), -// Status("Выпуск завершен", "/end"), -// Status("Онгоинг", "/ongoing"), -// Status("Новые главы", "/new_ch") -// ) - - /* [...document.querySelectorAll("li.sidetag > a:nth-child(1)")].map((el,i) => - * { const link=el.getAttribute('href');const id=link.substr(6,link.length); - * return `Genre("${id.replace("_", " ")}")` }).join(',\n') + /* [...document.querySelectorAll("li.sidetag > a:nth-child(1)")] + * .map(el => `Genre("${el.getAttribute('href').substr(6)}")`).join(',\n') * on http://mangachan.me/ */ private fun getGenreList() = listOf( - Genre("18 плюс"), + Genre("18_плюс"), Genre("bdsm"), Genre("арт"), Genre("боевик"), - Genre("боевые искусства"), + Genre("боевые_искусства"), Genre("вампиры"), Genre("веб"), Genre("гарем"), - Genre("гендерная интрига"), - Genre("героическое фэнтези"), + Genre("гендерная_интрига"), + Genre("героическое_фэнтези"), Genre("детектив"), Genre("дзёсэй"), Genre("додзинси"), @@ -262,13 +257,13 @@ class Mangachan : ParsedHttpSource() { Genre("меха"), Genre("мистика"), Genre("музыка"), - Genre("научная фантастика"), + Genre("научная_фантастика"), Genre("повседневность"), Genre("постапокалиптика"), Genre("приключения"), Genre("психология"), Genre("романтика"), - Genre("самурайский боевик"), + Genre("самурайский_боевик"), Genre("сборник"), Genre("сверхъестественное"), Genre("сказка"), @@ -279,7 +274,6 @@ class Mangachan : ParsedHttpSource() { Genre("сёдзё-ай"), Genre("сёнэн"), Genre("сёнэн-ай"), - Genre("темное фэнтези"), Genre("тентакли"), Genre("трагедия"), Genre("триллер"), diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt index 066be0e5c6..74779b4b5e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt @@ -24,23 +24,19 @@ class Mintmanga : ParsedHttpSource() { override val supportsLatest = true - override fun headersBuilder() = Headers.Builder().apply { - add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64)") - add("Referer", baseUrl) - } - override fun popularMangaRequest(page: Int): Request = GET("$baseUrl/list?sortType=rate&offset=${70 * (page - 1)}&max=70", headers) override fun latestUpdatesRequest(page: Int): Request = GET("$baseUrl/list?sortType=updated&offset=${70 * (page - 1)}&max=70", headers) - override fun popularMangaSelector() = "div.desc" + override fun popularMangaSelector() = "div.tile" - override fun latestUpdatesSelector() = "div.desc" + override fun latestUpdatesSelector() = "div.tile" override fun popularMangaFromElement(element: Element): SManga { val manga = SManga.create() + manga.thumbnail_url = element.select("img.lazy").first().attr("data-original") element.select("h3 > a").first().let { manga.setUrlWithoutDomain(it.attr("href")) manga.title = it.attr("title") @@ -90,10 +86,15 @@ class Mintmanga : ParsedHttpSource() { override fun chapterFromElement(element: Element): SChapter { val urlElement = element.select("a").first() + val urlText = urlElement.text() val chapter = SChapter.create() - chapter.setUrlWithoutDomain(urlElement.attr("href") + "?mature=1") - chapter.name = urlElement.text().replace(" новое", "") + chapter.setUrlWithoutDomain(urlElement.attr("href") + "?mtr=1") + if (urlText.endsWith(" новое")) { + chapter.name = urlText.dropLast(6) + } else { + chapter.name = urlText + } chapter.date_upload = element.select("td:eq(1)").first()?.text()?.let { SimpleDateFormat("dd/MM/yy", Locale.US).parse(it).time } ?: 0 @@ -143,11 +144,19 @@ class Mintmanga : ParsedHttpSource() { override fun imageUrlParse(document: Document) = "" + override fun imageRequest(page: Page): Request { + val imgHeader = Headers.Builder().apply { + add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64)") + add("Referer", baseUrl) + }.build() + return GET(page.imageUrl!!, imgHeader) + } + private class Genre(name: String, val id: String) : Filter.TriState(name) - /* [...document.querySelectorAll("tr.advanced_option:nth-child(1) > td:nth-child(3) span.js-link")].map((el,i) => { - * const onClick=el.getAttribute('onclick');const id=onClick.substr(31,onClick.length-33); - * return `Genre("${el.textContent.trim()}", "${id}")` }).join(',\n') + /* [...document.querySelectorAll("tr.advanced_option:nth-child(1) > td:nth-child(3) span.js-link")] + * .map(el => `Genre("${el.textContent.trim()}", $"{el.getAttribute('onclick') + * .substr(31,el.getAttribute('onclick').length-33)"})`).join(',\n') * on http://mintmanga.com/search/advanced */ override fun getFilterList() = FilterList( diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt index 1fe8cbb657..3f2a268261 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt @@ -24,14 +24,9 @@ class Readmanga : ParsedHttpSource() { override val supportsLatest = true - override fun headersBuilder() = Headers.Builder().apply { - add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64)") - add("Referer", baseUrl) - } + override fun popularMangaSelector() = "div.tile" - override fun popularMangaSelector() = "div.desc" - - override fun latestUpdatesSelector() = "div.desc" + override fun latestUpdatesSelector() = "div.tile" override fun popularMangaRequest(page: Int): Request = GET("$baseUrl/list?sortType=rate&offset=${70 * (page - 1)}&max=70", headers) @@ -41,6 +36,7 @@ class Readmanga : ParsedHttpSource() { override fun popularMangaFromElement(element: Element): SManga { val manga = SManga.create() + manga.thumbnail_url = element.select("img.lazy").first().attr("data-original") element.select("h3 > a").first().let { manga.setUrlWithoutDomain(it.attr("href")) manga.title = it.attr("title") @@ -90,10 +86,15 @@ class Readmanga : ParsedHttpSource() { override fun chapterFromElement(element: Element): SChapter { val urlElement = element.select("a").first() + val urlText = urlElement.text() val chapter = SChapter.create() - chapter.setUrlWithoutDomain(urlElement.attr("href") + "?mature=1") - chapter.name = urlElement.text().replace(" новое", "") + chapter.setUrlWithoutDomain(urlElement.attr("href") + "?mtr=1") + if (urlText.endsWith(" новое")) { + chapter.name = urlText.dropLast(6) + } else { + chapter.name = urlText + } chapter.date_upload = element.select("td:eq(1)").first()?.text()?.let { SimpleDateFormat("dd/MM/yy", Locale.US).parse(it).time } ?: 0 @@ -143,11 +144,19 @@ class Readmanga : ParsedHttpSource() { override fun imageUrlParse(document: Document) = "" + override fun imageRequest(page: Page): Request { + val imgHeader = Headers.Builder().apply { + add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64)") + add("Referer", baseUrl) + }.build() + return GET(page.imageUrl!!, imgHeader) + } + private class Genre(name: String, val id: String) : Filter.TriState(name) - /* [...document.querySelectorAll("tr.advanced_option:nth-child(1) > td:nth-child(3) span.js-link")].map((el,i) => { - * const onClick=el.getAttribute('onclick');const id=onClick.substr(31,onClick.length-33); - * return `Genre("${el.textContent.trim()}", "${id}")` }).join(',\n') + /* [...document.querySelectorAll("tr.advanced_option:nth-child(1) > td:nth-child(3) span.js-link")] + * .map(el => `Genre("${el.textContent.trim()}", $"{el.getAttribute('onclick') + * .substr(31,el.getAttribute('onclick').length-33)"})`).join(',\n') * on http://readmanga.me/search/advanced */ override fun getFilterList() = FilterList(