ReadComicOnline - refactor pageListParse (#2838)

ReadComicOnline - refactor pageListParse
This commit is contained in:
Mike 2020-04-26 07:00:35 -04:00 committed by GitHub
parent 28438fd55f
commit 5dd204d665
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 21 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: ReadComicOnline' appName = 'Tachiyomi: ReadComicOnline'
pkgNameSuffix = 'en.readcomiconline' pkgNameSuffix = 'en.readcomiconline'
extClass = '.Readcomiconline' extClass = '.Readcomiconline'
extVersionCode = 7 extVersionCode = 8
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -15,7 +15,6 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
import java.util.regex.Pattern
import okhttp3.FormBody import okhttp3.FormBody
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
@ -74,7 +73,6 @@ class Readcomiconline : ConfigurableSource, ParsedHttpSource() {
for (filter in if (filters.isEmpty()) getFilterList() else filters) { for (filter in if (filters.isEmpty()) getFilterList() else filters) {
when (filter) { when (filter) {
is Author -> add("authorArtist", filter.state)
is Status -> add("status", arrayOf("", "Completed", "Ongoing")[filter.state]) is Status -> add("status", arrayOf("", "Completed", "Ongoing")[filter.state])
is GenreList -> filter.state.forEach { genre -> add("genres", genre.state.toString()) } is GenreList -> filter.state.forEach { genre -> add("genres", genre.state.toString()) }
} }
@ -127,33 +125,20 @@ class Readcomiconline : ConfigurableSource, ParsedHttpSource() {
override fun pageListRequest(chapter: SChapter) = GET(baseUrl + chapter.url + "&quality=${qualitypref()}", headers) override fun pageListRequest(chapter: SChapter) = GET(baseUrl + chapter.url + "&quality=${qualitypref()}", headers)
override fun pageListParse(response: Response): List<Page> { override fun pageListParse(response: Response): List<Page> {
val pages = mutableListOf<Page>() return Regex("""lstImages\.push\("(http.*)"\)""").findAll(response.body()!!.string())
//language=RegExp .toList()
val p = Pattern.compile("""lstImages.push\("(.+?)"""") .mapIndexed { i, mr -> Page(i, "", mr.groupValues[1]) }
val m = p.matcher(response.body()!!.string())
var i = 0
while (m.find()) {
pages.add(Page(i++, "", m.group(1)))
}
return pages
} }
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> = throw UnsupportedOperationException("Not used")
throw Exception("Not used")
}
override fun imageUrlRequest(page: Page) = GET(page.url) override fun imageUrlParse(document: Document) = throw UnsupportedOperationException("Not used")
override fun imageUrlParse(document: Document) = ""
private class Status : Filter.TriState("Completed") private class Status : Filter.TriState("Completed")
private class Author : Filter.Text("Author")
private class Genre(name: String) : Filter.TriState(name) private class Genre(name: String) : Filter.TriState(name)
private class GenreList(genres: List<Genre>) : Filter.Group<Genre>("Genres", genres) private class GenreList(genres: List<Genre>) : Filter.Group<Genre>("Genres", genres)
override fun getFilterList() = FilterList( override fun getFilterList() = FilterList(
Author(),
Status(), Status(),
GenreList(getGenreList()) GenreList(getGenreList())
) )