From 466515c801d6a4e6d73890974b177be4ebbfd083 Mon Sep 17 00:00:00 2001 From: bake Date: Sat, 2 Jul 2016 22:16:20 +0200 Subject: [PATCH] Implement "Wie Manga!" (#379) * Implement Wie Manga! * Unnecessary import --- .../kanade/tachiyomi/data/source/Language.kt | 3 +- .../tachiyomi/data/source/SourceManager.kt | 5 +- .../data/source/online/german/WieManga.kt | 97 +++++++++++++++++++ 3 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/source/online/german/WieManga.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/source/Language.kt b/app/src/main/java/eu/kanade/tachiyomi/data/source/Language.kt index 77774e5e9..bbccebad9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/source/Language.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/source/Language.kt @@ -2,7 +2,8 @@ package eu.kanade.tachiyomi.data.source class Language(val code: String, val lang: String) +val DE = Language("DE", "German") val EN = Language("EN", "English") val RU = Language("RU", "Russian") -fun getLanguages() = listOf(EN, RU) \ No newline at end of file +fun getLanguages() = listOf(DE, EN, RU) \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/source/SourceManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/source/SourceManager.kt index e49d4e8a9..1b1b8ef08 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/source/SourceManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/source/SourceManager.kt @@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.source.online.OnlineSource import eu.kanade.tachiyomi.data.source.online.YamlOnlineSource import eu.kanade.tachiyomi.data.source.online.english.* +import eu.kanade.tachiyomi.data.source.online.german.WieManga import eu.kanade.tachiyomi.data.source.online.russian.Mangachan import eu.kanade.tachiyomi.data.source.online.russian.Mintmanga import eu.kanade.tachiyomi.data.source.online.russian.Readmanga @@ -26,8 +27,9 @@ open class SourceManager(private val context: Context) { val MANGACHAN = 7 val READMANGATODAY = 8 val MANGASEE = 9 + val WIEMANGA = 10 - val LAST_SOURCE = 9 + val LAST_SOURCE = 10 val sourcesMap = createSources() @@ -47,6 +49,7 @@ open class SourceManager(private val context: Context) { MANGACHAN -> Mangachan(context, id) READMANGATODAY -> Readmangatoday(context, id) MANGASEE -> Mangasee(context, id) + WIEMANGA -> WieManga(context, id) else -> null } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/source/online/german/WieManga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/source/online/german/WieManga.kt new file mode 100644 index 000000000..d58e5af55 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/source/online/german/WieManga.kt @@ -0,0 +1,97 @@ +package eu.kanade.tachiyomi.data.source.online.german + +import android.content.Context +import eu.kanade.tachiyomi.data.database.models.Chapter +import eu.kanade.tachiyomi.data.database.models.Manga +import eu.kanade.tachiyomi.data.source.DE +import eu.kanade.tachiyomi.data.source.Language +import eu.kanade.tachiyomi.data.source.model.Page +import eu.kanade.tachiyomi.data.source.online.ParsedOnlineSource +import eu.kanade.tachiyomi.util.asJsoup +import okhttp3.Response +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element +import java.text.SimpleDateFormat + +class WieManga(context: Context, override val id: Int) : ParsedOnlineSource(context) { + + override val name = "Wie Manga!" + + override val baseUrl = "http://www.wiemanga.com" + + override val lang: Language get() = DE + + override fun popularMangaInitialUrl() = "$baseUrl/list/Hot-Book/" + + override fun popularMangaSelector() = ".booklist td > div" + + override fun popularMangaFromElement(element: Element, manga: Manga) { + val image = element.select("dt img") + val title = element.select("dd a:first-child") + + manga.setUrlWithoutDomain(title.attr("href")) + manga.title = title.text() + manga.thumbnail_url = image.attr("src") + } + + override fun popularMangaNextPageSelector() = null + + override fun searchMangaInitialUrl(query: String) = "$baseUrl/search/?wd=$query" + + override fun searchMangaSelector() = ".searchresult td > div" + + override fun searchMangaFromElement(element: Element, manga: Manga) { + val image = element.select(".resultimg img") + val title = element.select(".resultbookname") + + manga.setUrlWithoutDomain(title.attr("href")) + manga.title = title.text() + manga.thumbnail_url = image.attr("src") + } + + override fun searchMangaNextPageSelector() = ".pagetor a.l" + + override fun mangaDetailsParse(document: Document, manga: Manga) { + val imageElement = document.select(".bookmessgae tr > td:nth-child(1)").first() + val infoElement = document.select(".bookmessgae tr > td:nth-child(2)").first() + + manga.author = infoElement.select("dd:nth-of-type(2) a").first()?.text() + manga.artist = infoElement.select("dd:nth-of-type(3) a").first()?.text() + manga.description = infoElement.select("dl > dt:last-child").first()?.text()?.replaceFirst("Beschreibung", "") + manga.thumbnail_url = imageElement.select("img").first()?.attr("src") + + if (manga.author == "RSS") + manga.author = null + + if (manga.artist == "RSS") + manga.artist = null + } + + override fun chapterListSelector() = ".chapterlist tr:not(:first-child)" + + override fun chapterFromElement(element: Element, chapter: Chapter) { + val urlElement = element.select(".col1 a").first() + val dateElement = element.select(".col3 a").first() + + chapter.setUrlWithoutDomain(urlElement.attr("href")) + chapter.name = urlElement.text() + chapter.date_upload = dateElement?.text()?.let { parseChapterDate(it) } ?: 0 + } + + private fun parseChapterDate(date: String): Long { + return SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(date).time + } + + override fun pageListParse(response: Response, pages: MutableList) { + val document = response.asJsoup() + + document.select("select#page").first().select("option").forEach { + pages.add(Page(pages.size, it.attr("value"))) + } + } + + override fun pageListParse(document: Document, pages: MutableList) {} + + override fun imageUrlParse(document: Document) = document.select("img#comicpic").first().attr("src") + +} \ No newline at end of file