FMReader - fix thumbnails, headers (#2862)
FMReader - fix thumbnails, headers
This commit is contained in:
parent
fbdb95c820
commit
2251a97868
@ -5,7 +5,7 @@ ext {
|
|||||||
appName = 'Tachiyomi: FMReader (multiple aggregators)'
|
appName = 'Tachiyomi: FMReader (multiple aggregators)'
|
||||||
pkgNameSuffix = 'all.fmreader'
|
pkgNameSuffix = 'all.fmreader'
|
||||||
extClass = '.FMReaderFactory'
|
extClass = '.FMReaderFactory'
|
||||||
extVersionCode = 9
|
extVersionCode = 10
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import okhttp3.Request
|
|||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import org.jsoup.select.Elements
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For sites based on the Flat-Manga CMS
|
* For sites based on the Flat-Manga CMS
|
||||||
@ -36,6 +37,19 @@ abstract class FMReader(
|
|||||||
add("Referer", baseUrl)
|
add("Referer", baseUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Elements.imgAttr(): String? = getImgAttr(this.firstOrNull())
|
||||||
|
|
||||||
|
private fun Element.imgAttr(): String? = getImgAttr(this)
|
||||||
|
|
||||||
|
open fun getImgAttr(element: Element?): String? {
|
||||||
|
return when {
|
||||||
|
element == null -> null
|
||||||
|
element.hasAttr("data-original") -> element.attr("abs:data-original")
|
||||||
|
element.hasAttr("data-src") -> element.attr("abs:data-src")
|
||||||
|
else -> element.attr("abs:src")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open val requestPath = "manga-list.html"
|
open val requestPath = "manga-list.html"
|
||||||
|
|
||||||
open val popularSort = "sort=views"
|
open val popularSort = "sort=views"
|
||||||
@ -114,9 +128,7 @@ abstract class FMReader(
|
|||||||
setUrlWithoutDomain(it.attr("abs:href"))
|
setUrlWithoutDomain(it.attr("abs:href"))
|
||||||
title = it.text()
|
title = it.text()
|
||||||
}
|
}
|
||||||
thumbnail_url = element.select("img").let {
|
thumbnail_url = element.select("img").imgAttr()
|
||||||
if (it.hasAttr("src")) it.attr("abs:src") else it.attr("abs:data-original")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +155,7 @@ abstract class FMReader(
|
|||||||
genre = infoElement.select("li a.btn-danger").joinToString { it.text() }
|
genre = infoElement.select("li a.btn-danger").joinToString { it.text() }
|
||||||
status = parseStatus(infoElement.select("li a.btn-success").first()?.text())
|
status = parseStatus(infoElement.select("li a.btn-success").first()?.text())
|
||||||
description = document.select("div.row ~ div.row p").text().trim()
|
description = document.select("div.row ~ div.row p").text().trim()
|
||||||
thumbnail_url = infoElement.select("img.thumbnail").attr("abs:src")
|
thumbnail_url = infoElement.select("img.thumbnail").imgAttr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +245,7 @@ abstract class FMReader(
|
|||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
return document.select(pageListImageSelector).mapIndexed { i, img ->
|
return document.select(pageListImageSelector).mapIndexed { i, img ->
|
||||||
Page(i, "", img.attr("abs:data-src").let { if (it.isNotEmpty()) it else img.attr("abs:src") })
|
Page(i, document.location(), img.imgAttr())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.source.model.SManga
|
|||||||
import eu.kanade.tachiyomi.util.asJsoup
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
import okhttp3.FormBody
|
import okhttp3.FormBody
|
||||||
import okhttp3.Headers
|
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
@ -51,7 +50,9 @@ class FMReaderFactory : SourceFactory {
|
|||||||
class LHTranslation : FMReader("LHTranslation", "https://lhtranslation.net", "en")
|
class LHTranslation : FMReader("LHTranslation", "https://lhtranslation.net", "en")
|
||||||
|
|
||||||
class MangaHato : FMReader("MangaHato", "https://mangahato.com", "ja")
|
class MangaHato : FMReader("MangaHato", "https://mangahato.com", "ja")
|
||||||
class ManhwaScan : FMReader("ManhwaScan", "https://manhwascan.com", "en")
|
class ManhwaScan : FMReader("ManhwaScan", "https://manhwascan.com", "en") {
|
||||||
|
override fun getImgAttr(element: Element?): String? = element?.attr("abs:src")
|
||||||
|
}
|
||||||
class MangaTiki : FMReader("MangaTiki", "https://mangatiki.com", "ja")
|
class MangaTiki : FMReader("MangaTiki", "https://mangatiki.com", "ja")
|
||||||
class MangaBone : FMReader("MangaBone", "https://mangabone.com", "en")
|
class MangaBone : FMReader("MangaBone", "https://mangabone.com", "en")
|
||||||
class YoloManga : FMReader("Yolo Manga", "https://yolomanga.ca", "es") {
|
class YoloManga : FMReader("Yolo Manga", "https://yolomanga.ca", "es") {
|
||||||
@ -96,13 +97,14 @@ class ReadComicOnlineOrg : FMReader("ReadComicOnline.org", "https://readcomiconl
|
|||||||
|
|
||||||
class HanaScan : FMReader("HanaScan (RawQQ)", "https://hanascan.com", "ja") {
|
class HanaScan : FMReader("HanaScan (RawQQ)", "https://hanascan.com", "ja") {
|
||||||
override fun popularMangaNextPageSelector() = "div.col-md-8 button"
|
override fun popularMangaNextPageSelector() = "div.col-md-8 button"
|
||||||
// Referer header needs to be chapter URL or not set at all
|
// Referer needs to be chapter URL
|
||||||
override fun imageRequest(page: Page): Request = GET(page.imageUrl!!, headersBuilder().removeAll("Referer").build())
|
override fun imageRequest(page: Page): Request = GET(page.imageUrl!!, headersBuilder().set("Referer", page.url).build())
|
||||||
}
|
}
|
||||||
|
|
||||||
class RawLH : FMReader("RawLH", "https://loveheaven.net", "ja") {
|
class RawLH : FMReader("RawLH", "https://loveheaven.net", "ja") {
|
||||||
override fun popularMangaNextPageSelector() = "div.col-md-8 button"
|
override fun popularMangaNextPageSelector() = "div.col-md-8 button"
|
||||||
override fun headersBuilder(): Headers.Builder = super.headersBuilder().add("Referer", baseUrl)
|
// Referer needs to be chapter URL
|
||||||
|
override fun imageRequest(page: Page): Request = GET(page.imageUrl!!, headersBuilder().set("Referer", page.url).build())
|
||||||
}
|
}
|
||||||
|
|
||||||
class Manhwa18 : FMReader("Manhwa18", "https://manhwa18.com", "en") {
|
class Manhwa18 : FMReader("Manhwa18", "https://manhwa18.com", "en") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user