FMReader: WeLoveManga: Fix page list parsing (#9196)

* FMReader: WeLoveManga: Fix page list parsing

They appear to have changed how their page list works, to instead be driven
off an attribute with a seemingly randomly generated name.  That name is
then emitted as part of the page script.  We can just rely on that
attribute being very long instead.

Fixes #9120

* FMReader: WeLoveManga: Fix imports.

They were not copied over correctly when copying the (edited) generated
code back to the source.
This commit is contained in:
Mook 2021-09-24 03:13:00 -07:00 committed by GitHub
parent 0bc77409a9
commit a03a505b78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -1,17 +1,33 @@
package eu.kanade.tachiyomi.extension.ja.rawlh
import android.util.Base64
import eu.kanade.tachiyomi.multisrc.fmreader.FMReader
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.Page
import okhttp3.Request
import org.jsoup.nodes.Attribute
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.nio.charset.Charset
class WeLoveManga : FMReader("WeLoveManga", "https://weloma.net", "ja") {
// Formerly "RawLH"
override val id = 7595224096258102519
override val chapterUrlSelector = ""
override fun pageListParse(document: Document): List<Page> = base64PageListParse(document)
override fun pageListParse(document: Document): List<Page> {
fun Element.decoded(): String {
val attr = this.attributes().map(Attribute::key).maxByOrNull(kotlin.String::length) ?: "src"
return if (!this.attr(attr).contains(".")) {
Base64.decode(this.attr(attr), Base64.DEFAULT).toString(Charset.defaultCharset())
} else {
this.attr("abs:$attr")
}
}
return document.select(pageListImageSelector).mapIndexed { i, img ->
Page(i, document.location(), img.decoded())
}
}
// Referer needs to be chapter URL
override fun imageRequest(page: Page): Request = GET(page.imageUrl!!, headersBuilder().set("Referer", page.url).build())
}

View File

@ -21,7 +21,7 @@ class FMReaderGenerator : ThemeSourceGenerator {
SingleLang("Manga-TR", "https://manga-tr.com", "tr", className = "MangaTR"),
SingleLang("Manhwa18", "https://manhwa18.com", "en", isNsfw = true),
MultiLang("Manhwa18.net", "https://manhwa18.net", listOf("en", "ko"), className = "Manhwa18NetFactory", isNsfw = true),
SingleLang("WeLoveManga", "https://weloma.net", "ja", pkgName = "rawlh", overrideVersionCode = 1),
SingleLang("WeLoveManga", "https://weloma.net", "ja", pkgName = "rawlh", overrideVersionCode = 2),
SingleLang("Say Truyen", "https://saytruyen.net", "vi", overrideVersionCode = 1),
SingleLang("KSGroupScans", "https://ksgroupscans.com", "en"),
// Sites that went down