diff --git a/lib-multisrc/pizzareader/src/eu/kanade/tachiyomi/multisrc/pizzareader/PizzaReaderDto.kt b/lib-multisrc/pizzareader/src/eu/kanade/tachiyomi/multisrc/pizzareader/PizzaReaderDto.kt index 7464a559f..1258910c6 100644 --- a/lib-multisrc/pizzareader/src/eu/kanade/tachiyomi/multisrc/pizzareader/PizzaReaderDto.kt +++ b/lib-multisrc/pizzareader/src/eu/kanade/tachiyomi/multisrc/pizzareader/PizzaReaderDto.kt @@ -21,7 +21,7 @@ data class PizzaReaderDto( @Serializable data class PizzaComicDto( - val artist: String = "", + val artist: String? = null, val author: String = "", val chapters: List = emptyList(), val description: String = "", diff --git a/src/fr/fmteam/build.gradle b/src/fr/fmteam/build.gradle index 22c5fe7f9..092a956a6 100644 --- a/src/fr/fmteam/build.gradle +++ b/src/fr/fmteam/build.gradle @@ -1,7 +1,9 @@ ext { extName = 'FMTEAM' extClass = '.FMTEAM' - extVersionCode = 2 + themePkg = 'pizzareader' + baseUrl = 'https://fmteam.fr' + overrideVersionCode = 3 } apply from: "$rootDir/common.gradle" diff --git a/src/fr/fmteam/src/eu/kanade/tachiyomi/extension/fr/fmteam/FMTEAM.kt b/src/fr/fmteam/src/eu/kanade/tachiyomi/extension/fr/fmteam/FMTEAM.kt index da78a015e..d6af61f0c 100644 --- a/src/fr/fmteam/src/eu/kanade/tachiyomi/extension/fr/fmteam/FMTEAM.kt +++ b/src/fr/fmteam/src/eu/kanade/tachiyomi/extension/fr/fmteam/FMTEAM.kt @@ -1,129 +1,7 @@ package eu.kanade.tachiyomi.extension.fr.fmteam -import eu.kanade.tachiyomi.network.GET -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.HttpSource -import kotlinx.serialization.decodeFromString -import kotlinx.serialization.json.Json -import okhttp3.Request -import okhttp3.Response -import uy.kohesive.injekt.injectLazy -import java.text.SimpleDateFormat -import java.util.Locale -import java.util.TimeZone +import eu.kanade.tachiyomi.multisrc.pizzareader.PizzaReader -class FMTEAM : HttpSource() { - override val name = "FMTEAM" - override val baseUrl = "https://fmteam.fr" - override val lang = "fr" - override val supportsLatest = true +class FMTEAM : PizzaReader("FMTEAM", "https://fmteam.fr", "fr") { override val versionId = 2 - - private val json: Json by injectLazy() - - companion object { - private val DATE_FORMATTER by lazy { - SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US).apply { - timeZone = TimeZone.getTimeZone("UTC") - } - } - } - - // All manga - override fun popularMangaRequest(page: Int): Request = GET("$baseUrl/api/comics") - - override fun popularMangaParse(response: Response): MangasPage { - val results = json.decodeFromString(response.body.string()) - - return MangasPage(results.comics.sortedByDescending { it.views }.map(::fmTeamComicToSManga), false) - } - - // Latest - override fun latestUpdatesRequest(page: Int): Request = GET("$baseUrl/api/comics") - - override fun latestUpdatesParse(response: Response): MangasPage { - val results = json.decodeFromString(response.body.string()) - - return MangasPage(results.comics.sortedByDescending { parseDate(it.last_chapter.published_on) }.map(::fmTeamComicToSManga), false) - } - - // Search - override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = GET("$baseUrl/api/search/$query") - - override fun searchMangaParse(response: Response): MangasPage { - val results = json.decodeFromString(response.body.string()) - - return MangasPage(results.comics.map(::fmTeamComicToSManga), false) - } - - // Manga details - override fun mangaDetailsRequest(manga: SManga): Request = GET("$baseUrl/api${manga.url}") - - override fun mangaDetailsParse(response: Response): SManga { - val results = json.decodeFromString(response.body.string()) - - return fmTeamComicToSManga(results.comic) - } - - override fun getMangaUrl(manga: SManga): String { - return "$baseUrl${manga.url}" - } - - // Chapter list - override fun chapterListRequest(manga: SManga): Request = GET("$baseUrl/api${manga.url}") - - override fun chapterListParse(response: Response): List { - val results = json.decodeFromString(response.body.string()) - - return results.comic.chapters?.map(::fmTeamChapterToSChapter) ?: emptyList() - } - - override fun getChapterUrl(chapter: SChapter): String { - return "$baseUrl${chapter.url}" - } - - // Pages - override fun pageListRequest(chapter: SChapter): Request = GET("$baseUrl/api${chapter.url}") - - override fun pageListParse(response: Response): List { - val results = json.decodeFromString(response.body.string()) - - return results.chapter.pages.orEmpty() - .mapIndexed { i, page -> Page(i, "${results.chapter.url}#${i + 1}", page) } - } - - override fun imageUrlParse(response: Response): String = throw UnsupportedOperationException() - - // Utils - private fun fmTeamComicToSManga(comic: FmteamComic): SManga = SManga.create().apply { - url = comic.url - title = comic.title - artist = comic.artist - author = comic.author - description = comic.description - genre = comic.genres.joinToString { it.name } - status = when (comic.status) { - "En cours" -> SManga.ONGOING - "Termin\u00e9" -> SManga.COMPLETED - else -> SManga.UNKNOWN - } - thumbnail_url = comic.thumbnail - initialized = true - } - - private fun fmTeamChapterToSChapter(chapter: FmteamChapter): SChapter = SChapter.create().apply { - url = chapter.url - name = chapter.full_title - date_upload = parseDate(chapter.published_on) - scanlator = chapter.teams.filterNotNull().joinToString { it.name } - } - - private fun parseDate(dateStr: String): Long { - return runCatching { DATE_FORMATTER.parse(dateStr)?.time } - .getOrNull() ?: 0L - } } diff --git a/src/fr/fmteam/src/eu/kanade/tachiyomi/extension/fr/fmteam/FMTEAMDto.kt b/src/fr/fmteam/src/eu/kanade/tachiyomi/extension/fr/fmteam/FMTEAMDto.kt deleted file mode 100644 index cf6074a76..000000000 --- a/src/fr/fmteam/src/eu/kanade/tachiyomi/extension/fr/fmteam/FMTEAMDto.kt +++ /dev/null @@ -1,54 +0,0 @@ -package eu.kanade.tachiyomi.extension.fr.fmteam - -import kotlinx.serialization.Serializable - -@Serializable -data class FmteamComicListPage( - val comics: List, -) - -@Serializable -data class FmteamComicDetailPage( - val comic: FmteamComic, -) - -@Serializable -data class FmteamChapterDetailPage( - val chapter: FmteamChapter, -) - -@Serializable -data class FmteamComic( - val title: String, - val thumbnail: String, - val description: String, - val author: String, - val artist: String?, - val genres: List, - val status: String, - val views: Int, - val url: String, - val last_chapter: FmteamChapter, - val chapters: List?, -) - -@Serializable -data class FmteamTag( - val name: String, -) - -@Serializable -data class FmteamChapter( - val full_title: String, - val chapter: Int, - val subchapter: Int?, - val teams: List, - val published_on: String, - val url: String, - val pages: List?, -) - -@Serializable -data class FmteamTeam( - val name: String, -)