diff --git a/src/en/mangastream/build.gradle b/src/en/mangastream/build.gradle index 163df03f6..844629e6b 100644 --- a/src/en/mangastream/build.gradle +++ b/src/en/mangastream/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: Mangastream' pkgNameSuffix = 'en.mangastream' extClass = '.Mangastream' - extVersionCode = 3 + extVersionCode = 4 libVersion = '1.2' } diff --git a/src/en/mangastream/src/eu/kanade/tachiyomi/extension/en/mangastream/Mangastream.kt b/src/en/mangastream/src/eu/kanade/tachiyomi/extension/en/mangastream/Mangastream.kt index 2ee70982a..24247b505 100644 --- a/src/en/mangastream/src/eu/kanade/tachiyomi/extension/en/mangastream/Mangastream.kt +++ b/src/en/mangastream/src/eu/kanade/tachiyomi/extension/en/mangastream/Mangastream.kt @@ -2,7 +2,11 @@ package eu.kanade.tachiyomi.extension.en.mangastream import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.asObservableSuccess -import eu.kanade.tachiyomi.source.model.* +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 import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.util.asJsoup import okhttp3.Response @@ -11,20 +15,24 @@ import org.jsoup.nodes.Element import rx.Observable import java.text.ParseException import java.text.SimpleDateFormat -import java.util.* +import java.util.Calendar +import java.util.Date +import java.util.Locale import java.util.regex.Pattern class Mangastream : ParsedHttpSource() { override val name = "Mangastream" - override val baseUrl = "https://mangastream.com" + override val baseUrl = "https://readms.net/" override val lang = "en" override val supportsLatest = true - private val datePattern = Pattern.compile("(\\d+) days? ago") + private val datePattern by lazy { + Pattern.compile("(\\d+) days? ago") + } override fun popularMangaSelector() = "table.table-striped > tbody > tr > td:nth-of-type(1)" @@ -83,10 +91,10 @@ class Mangastream : ParsedHttpSource() { override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable { return client.newCall(searchMangaRequest(page, query, filters)) - .asObservableSuccess() - .map { response -> - searchMangaParse(response, query) - } + .asObservableSuccess() + .map { response -> + searchMangaParse(response, query) + } } override fun mangaDetailsParse(document: Document): SManga { @@ -114,27 +122,27 @@ class Mangastream : ParsedHttpSource() { val dateEl = element.select("td:nth-of-type(2)") val chapter = SChapter.create() - chapter.setUrlWithoutDomain(urlEl.attr("href")) + chapter.url = urlEl.attr("href") chapter.name = urlEl.text() chapter.date_upload = dateEl.text()?.let { dateParse(it) } ?: 0 + return chapter } private fun dateParse(dateAsString: String): Long { - var date: Date - try { - date = SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH).parse(dateAsString.replace(Regex("(st|nd|rd|th)"), "")) + val date: Date = try { + SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH).parse(dateAsString.replace(Regex("(st|nd|rd|th)"), "")) } catch (e: ParseException) { val m = datePattern.matcher(dateAsString) if (dateAsString != "Today" && m.matches()) { val amount = m.group(1).toInt() - date = Calendar.getInstance().apply { + Calendar.getInstance().apply { add(Calendar.DATE, -amount) }.time - } else if (dateAsString == "Today"){ - date = Calendar.getInstance().time + } else if (dateAsString == "Today") { + Calendar.getInstance().time } else return 0 } @@ -147,13 +155,14 @@ class Mangastream : ParsedHttpSource() { val pages = mutableListOf() for (i in 1..num) - pages.add(Page(i-1, url + i )) + pages.add(Page(i - 1, url + i)) pages.getOrNull(0)?.imageUrl = imageUrlParse(document) return pages } - override fun imageUrlParse(document: Document) = "http:" + document.getElementById("manga-page").attr("src") + override fun imageUrlParse(document: Document): String { + return "http:" + document.getElementById("manga-page").attr("src") + } - override fun getFilterList() = super.getFilterList() }