ReadManhua: add year to chapter timestamp (#6388)
This commit is contained in:
parent
5bf4040719
commit
5aeedf8260
|
@ -1,12 +1,52 @@
|
|||
package eu.kanade.tachiyomi.extension.en.readmanhua
|
||||
|
||||
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
||||
import eu.kanade.tachiyomi.multisrc.madara.WordSet
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import org.jsoup.nodes.Element
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
class ReadManhua : Madara(
|
||||
"ReadManhua",
|
||||
"https://readmanhua.net",
|
||||
"en",
|
||||
dateFormat = SimpleDateFormat("dd MMM yy", Locale.US)
|
||||
)
|
||||
dateFormat = SimpleDateFormat("dd MMM yyyy", Locale.US)
|
||||
) {
|
||||
|
||||
override fun chapterFromElement(element: Element): SChapter {
|
||||
val chapter = SChapter.create()
|
||||
val year = Calendar.getInstance().get(Calendar.YEAR).toLong()
|
||||
|
||||
with(element) {
|
||||
select(chapterUrlSelector).first()?.let { urlElement ->
|
||||
chapter.url = urlElement.attr("abs:href").let {
|
||||
it.substringBefore("?style=paged") + if (!it.endsWith(chapterUrlSuffix)) chapterUrlSuffix else ""
|
||||
}
|
||||
chapter.name = urlElement.text()
|
||||
}
|
||||
|
||||
// Dates can be part of a "new" graphic or plain text
|
||||
chapter.date_upload = select("img").firstOrNull()?.attr("alt")?.let { parseRelativeDate(it) }
|
||||
?: parseChapterDate(select("span.chapter-release-date i").firstOrNull()?.text() + " " + year)
|
||||
}
|
||||
|
||||
return chapter
|
||||
}
|
||||
|
||||
// Parses dates in this form:
|
||||
// 21 horas ago
|
||||
private fun parseRelativeDate(date: String): Long {
|
||||
val number = Regex("""(\d+)""").find(date)?.value?.toIntOrNull() ?: return 0
|
||||
val cal = Calendar.getInstance()
|
||||
|
||||
return when {
|
||||
WordSet("hari", "gün", "jour", "día", "dia", "day").anyWordIn(date) -> cal.apply { add(Calendar.DAY_OF_MONTH, -number) }.timeInMillis
|
||||
WordSet("jam", "saat", "heure", "hora", "hour").anyWordIn(date) -> cal.apply { add(Calendar.HOUR, -number) }.timeInMillis
|
||||
WordSet("menit", "dakika", "min", "minute", "minuto").anyWordIn(date) -> cal.apply { add(Calendar.MINUTE, -number) }.timeInMillis
|
||||
WordSet("detik", "segundo", "second").anyWordIn(date) -> cal.apply { add(Calendar.SECOND, -number) }.timeInMillis
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ class MadaraGenerator : ThemeSourceGenerator {
|
|||
SingleLang("Random Translations", "https://randomtranslations.com", "en"),
|
||||
SingleLang("RawDEX", "https://rawdex.net", "ko", isNsfw = true),
|
||||
SingleLang("Raw Mangas", "https://rawmangas.net", "ja", isNsfw = true, overrideVersionCode = 1),
|
||||
SingleLang("ReadManhua", "https://readmanhua.net", "en", overrideVersionCode = 1),
|
||||
SingleLang("ReadManhua", "https://readmanhua.net", "en", overrideVersionCode = 2),
|
||||
SingleLang("Renascence Scans (Renascans)", "https://new.renascans.com", "en", className = "RenaScans"),
|
||||
SingleLang("Rüya Manga", "https://www.ruyamanga.com", "tr", className = "RuyaManga"),
|
||||
SingleLang("S2Manga", "https://s2manga.com", "en"),
|
||||
|
|
Loading…
Reference in New Issue