diff --git a/src/en/loadingartist/build.gradle b/src/en/loadingartist/build.gradle index 3b19e88cc..c88f2d057 100644 --- a/src/en/loadingartist/build.gradle +++ b/src/en/loadingartist/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Loading Artist' pkgNameSuffix = 'en.loadingartist' extClass = '.LoadingArtist' - extVersionCode = 1 + extVersionCode = 2 libVersion = '1.2' } diff --git a/src/en/loadingartist/src/eu/kanade/tachiyomi/extension/en/loadingartist/LoadingArtist.kt b/src/en/loadingartist/src/eu/kanade/tachiyomi/extension/en/loadingartist/LoadingArtist.kt index 9e71a00dd..0adeecc3b 100644 --- a/src/en/loadingartist/src/eu/kanade/tachiyomi/extension/en/loadingartist/LoadingArtist.kt +++ b/src/en/loadingartist/src/eu/kanade/tachiyomi/extension/en/loadingartist/LoadingArtist.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.extension.en.loadingartist import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page @@ -16,6 +17,9 @@ import okhttp3.Request import okhttp3.Response import rx.Observable import uy.kohesive.injekt.injectLazy +import java.text.ParseException +import java.text.SimpleDateFormat +import java.util.Locale class LoadingArtist : HttpSource() { override val name = "Loading Artist" @@ -28,53 +32,41 @@ class LoadingArtist : HttpSource() { private val json: Json by injectLazy() - private val comicList: MutableList = mutableListOf() - @Serializable private data class Comic( val url: String, - val img: String = "", val title: String, val date: String = "", - val section: String, - val keywords: List = listOf() + val section: String ) // Popular Section (list of comic archives by year) - // Retrieves the entire comic archive - override fun popularMangaRequest(page: Int): Request = GET("$baseUrl/search.json") - - override fun popularMangaParse(response: Response): MangasPage { - comicList.clear() - json.parseToJsonElement(response.body!!.string()).jsonObject.forEach { - val item = json.decodeFromJsonElement(it.value) - if (listOf("comic", "art", "game").any { type -> item.section == type }) { - comicList.add( + override fun fetchPopularManga(page: Int): Observable { + return Observable.just( + MangasPage( + listOf( SManga.create().apply { - setUrlWithoutDomain(item.url) - title = item.title - thumbnail_url = if (item.img.isEmpty()) null else "$baseUrl${item.img}" + title = "Loading Artist" + setUrlWithoutDomain("/archives") + thumbnail_url = "$baseUrl/img/bg/logo-text_dark.png" artist = "Loading Artist" author = artist - description = if (item.date.isEmpty()) null else "Date Published: ${item.date}" - genre = item.keywords.joinToString(", ") - status = SManga.COMPLETED + status = SManga.ONGOING } - ) - } - } - return MangasPage(comicList, false) - } - - // Search - - override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable { - return Observable.just( - MangasPage(comicList.filter { it.title.contains(query, true) }, false) + ), + false + ) ) } + override fun popularMangaRequest(page: Int): Request = throw Exception("Not used") + override fun popularMangaParse(response: Response): MangasPage = throw Exception("Not used") + + // Search + + override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable = + throw Exception("Search not available for this source") override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = throw Exception("Not used") override fun searchMangaParse(response: Response): MangasPage = throw Exception("Not used") @@ -89,17 +81,30 @@ class LoadingArtist : HttpSource() { // Chapters override fun fetchChapterList(manga: SManga): Observable> { - return Observable.just( - listOf( - SChapter.create().apply { - setUrlWithoutDomain(manga.url) - name = manga.title - } - ) - ) + return client.newCall(GET("$baseUrl/search.json", headers)) + .asObservableSuccess() + .map { response -> + chapterListParse(response) + } } - override fun chapterListParse(response: Response): List = throw Exception("Not used") + override fun chapterListParse(response: Response): List { + val comics = json.parseToJsonElement(response.body!!.string()).jsonObject.map { + json.decodeFromJsonElement(it.value) + } + val validTypes = listOf("comic", "game", "art") + return comics.filter { validTypes.any { type -> it.section == type } }.map { + SChapter.create().apply { + setUrlWithoutDomain(it.url) + name = it.title + date_upload = try { + SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH).parse(it.date)?.time ?: 0 + } catch (_: ParseException) { + 0 + } + } + } + } // Pages