MayoTune: Change to multi language (#9431)

This commit is contained in:
Nam Anh 2025-06-28 22:05:04 +07:00 committed by Draff
parent e9a8b1b19a
commit b7b69b73fa
Signed by: Draff
GPG Key ID: E8A89F3211677653
9 changed files with 33 additions and 15 deletions

View File

@ -1,8 +1,7 @@
ext { ext {
extName = 'MayoTune' extName = 'MayoTune'
extClass = '.MayoTune' extClass = '.MayoTuneFactory'
extVersionCode = 2 extVersionCode = 1
baseUrl = 'https://mayotune.xyz'
isNsfw = false isNsfw = false
} }

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.extension.en.mayotune package eu.kanade.tachiyomi.extension.all.mayotune
import keiyoushi.utils.tryParse import keiyoushi.utils.tryParse
import kotlinx.serialization.Contextual import kotlinx.serialization.Contextual
@ -15,10 +15,10 @@ data class ChapterDto(
val date: String, val date: String,
) { ) {
@Contextual @Contextual
private val sdf = SimpleDateFormat("yyyy-MM-dd", Locale.US) private val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US)
fun getChapterURL(): String = fun getChapterURL(chapterEndpoint: String): String =
"/api/chapters?id=$id&number=${this.getNumberStr()}" "/api/$chapterEndpoint/chapters?id=$id&number=${this.getNumberStr()}"
fun getNumberStr(): String = if (this.number % 1 == 0f) { fun getNumberStr(): String = if (this.number % 1 == 0f) {
this.number.toInt().toString() this.number.toInt().toString()

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.extension.en.mayotune package eu.kanade.tachiyomi.extension.all.mayotune
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
@ -14,14 +14,22 @@ import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import rx.Observable import rx.Observable
class MayoTune() : HttpSource() { class MayoTune(
override val lang: String,
private val chapterEndpoint: String,
) : HttpSource() {
override val name: String = "MayoTune" override val name: String = "MayoTune"
override val baseUrl: String = "https://mayotune.xyz" override val baseUrl: String = "https://mayotune.xyz"
override val lang: String = "en"
override val versionId: Int = 1 override val versionId: Int = 1
private val names = mapOf(
"en" to "Tune In to the Midnight Heart",
"ja" to "真夜中ハートチューン",
"all" to "Mayonaka Heart Tune",
)
private val source = SManga.create().apply { private val source = SManga.create().apply {
title = "Mayonaka Heart Tune" title = names[lang] ?: names["all"]!!
url = "/" url = "/"
thumbnail_url = "$baseUrl/img/cover.jpg" thumbnail_url = "$baseUrl/img/cover.jpg"
author = "Masakuni Igarashi" author = "Masakuni Igarashi"
@ -54,7 +62,7 @@ class MayoTune() : HttpSource() {
): Observable<MangasPage> { ): Observable<MangasPage> {
val mangas = mutableListOf<SManga>() val mangas = mutableListOf<SManga>()
if (source.title.lowercase().contains(query.lowercase()) || if (names.any { it.value.lowercase().contains(query.lowercase()) } ||
source.author?.lowercase()?.contains(query.lowercase()) == true source.author?.lowercase()?.contains(query.lowercase()) == true
) { ) {
mangas.add(source) mangas.add(source)
@ -71,12 +79,12 @@ class MayoTune() : HttpSource() {
// Get Override // Get Override
override fun chapterListRequest(manga: SManga): Request { override fun chapterListRequest(manga: SManga): Request {
return GET("$baseUrl/api/chapters", headers) return GET("$baseUrl/api/$chapterEndpoint/chapters", headers)
} }
override fun getChapterUrl(chapter: SChapter): String { override fun getChapterUrl(chapter: SChapter): String {
val id = (baseUrl + chapter.url).toHttpUrl().queryParameter("id") val id = (baseUrl + chapter.url).toHttpUrl().queryParameter("id")
return "$baseUrl/chapter/$id" return "$baseUrl/$chapterEndpoint/chapter/$id"
} }
// Details // Details
@ -110,7 +118,7 @@ class MayoTune() : HttpSource() {
val chapters = response.parseAs<List<ChapterDto>>() val chapters = response.parseAs<List<ChapterDto>>()
return chapters.sortedByDescending { it.number }.map { chapter -> return chapters.sortedByDescending { it.number }.map { chapter ->
SChapter.create().apply { SChapter.create().apply {
url = chapter.getChapterURL() url = chapter.getChapterURL(chapterEndpoint)
name = chapter.getChapterTitle() name = chapter.getChapterTitle()
chapter_number = chapter.number chapter_number = chapter.number
date_upload = chapter.getDateTimestamp() date_upload = chapter.getDateTimestamp()

View File

@ -0,0 +1,11 @@
package eu.kanade.tachiyomi.extension.all.mayotune
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory
class MayoTuneFactory : SourceFactory {
override fun createSources(): List<Source> = listOf(
MayoTune("en", ""),
MayoTune("ja", "raw"),
)
}