The Property of Hate: fix webview URL (#10025)

Amongst other things
This commit is contained in:
ObserverOfTime 2021-12-08 12:55:42 +02:00 committed by GitHub
parent 41f326eb54
commit 8121c2063e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 62 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'The Property of Hate'
pkgNameSuffix = 'en.thepropertyofhate'
extClass = '.ThePropertyOfHate'
extVersionCode = 3
extVersionCode = 4
}
apply from: "$rootDir/common.gradle"

View File

@ -12,25 +12,21 @@ import okhttp3.Request
import okhttp3.Response
import rx.Observable
/**
* @author Aria Moradi <aria.moradi007@gmail.com>
*/
/** @author Aria Moradi <aria.moradi007@gmail.com> */
class ThePropertyOfHate : HttpSource() {
override val name = "The Property of Hate"
override val baseUrl = "http://jolleycomics.com"
val firstChapterUrl = "/TPoH/The Hook/"
override val baseUrl = "https://jolleycomics.com"
override val lang = "en"
override val supportsLatest: Boolean = false
override val supportsLatest = false
private val firstChapterUrl = "/TPoH/The Hook/"
// the one and only manga entry
fun manga(): SManga {
return SManga.create().apply {
private val manga: SManga
get() = SManga.create().apply {
title = "The Property of Hate"
thumbnail_url = "https://pbs.twimg.com/media/DOBCcMiWkAA8Hvu.jpg"
artist = "Sarah Jolley"
@ -38,78 +34,70 @@ class ThePropertyOfHate : HttpSource() {
status = SManga.UNKNOWN
url = baseUrl
}
}
override fun fetchPopularManga(page: Int): Observable<MangasPage> {
return Observable.just(MangasPage(listOf(manga()), false))
}
override fun fetchPopularManga(page: Int) =
Observable.just(MangasPage(listOf(manga), false))!!
override fun popularMangaRequest(page: Int): Request = throw Exception("Not used")
// write the data again to avoid bugs in backup restore
override fun fetchMangaDetails(manga: SManga): Observable<SManga> =
Observable.just(this.manga.also { it.initialized = true })!!
override fun popularMangaParse(response: Response): MangasPage = throw Exception("Not used")
// needed for the webview
override fun mangaDetailsRequest(manga: SManga) = GET(baseUrl, headers)
// latest Updates not used
override fun latestUpdatesParse(response: Response): MangasPage = throw Exception("Not used")
override fun latestUpdatesRequest(page: Int): Request = throw Exception("Not used")
// the manga is one and only, but still write the data again to avoid bugs in backup restore
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
return Observable.just(manga())
}
override fun mangaDetailsParse(response: Response): SManga = throw Exception("Not used")
// chapter list
override fun chapterListRequest(manga: SManga): Request {
return GET(baseUrl + firstChapterUrl, headers) // no real base url for this comic so must read the first chapter's link
}
// no real base url for this comic so must read the first chapter's link
override fun chapterListRequest(manga: SManga) =
GET(baseUrl + firstChapterUrl, headers)
override fun chapterListParse(response: Response): List<SChapter> {
val document = response.asJsoup()
val chapters = mutableListOf<SChapter>(
SChapter.create().apply() { // must hard code the first one
val chapters = mutableListOf(
// must hard code the first one
SChapter.create().apply {
url = firstChapterUrl
chapter_number = 1f
name = "The Hook"
}
)
document.select("select > option").forEach { option ->
if (!option.text().startsWith("-")) // ignore "jump to entry" option
chapters.add(
SChapter.create().apply {
url = option.attr("value")
name = option.text()
}
)
}
document.select("select > option:not(:first-child)")
.mapIndexed { num, opt ->
SChapter.create().apply {
setUrlWithoutDomain(opt.attr("value"))
chapter_number = num + 2f
name = opt.text()
}
}.let(chapters::addAll)
return chapters.reversed()
}
override fun pageListParse(response: Response): List<Page> {
val document = response.asJsoup()
override fun pageListParse(response: Response) =
response.asJsoup().select("select > optgroup > option")
.mapIndexed { num, opt -> Page(num, opt.absUrl("value")) }
// parse the options for this chapter to get page links
val pages = document.select("select > optgroup > option").mapIndexed { pageNum, option ->
Page(pageNum, baseUrl + option.attr("value"))
}
override fun imageUrlParse(response: Response) =
response.asJsoup().selectFirst(".comic_comic > img").absUrl("src")!!
return pages
}
override fun popularMangaRequest(page: Int): Request =
throw UnsupportedOperationException("Not used")
override fun imageUrlParse(response: Response): String {
val document = response.asJsoup()
override fun popularMangaParse(response: Response): MangasPage =
throw UnsupportedOperationException("Not used")
return baseUrl + document.select(".comic_comic > img").first().attr("src")
}
override fun latestUpdatesParse(response: Response): MangasPage =
throw UnsupportedOperationException("Not used")
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> = throw Exception("Search functionality is not available.")
override fun latestUpdatesRequest(page: Int): Request =
throw UnsupportedOperationException("Not used")
override fun searchMangaParse(response: Response): MangasPage = throw Exception("Not used")
override fun mangaDetailsParse(response: Response): SManga =
throw UnsupportedOperationException("Not used")
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = throw Exception("Not used")
override fun searchMangaParse(response: Response): MangasPage =
throw UnsupportedOperationException("Not used")
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request =
throw UnsupportedOperationException("Search functionality is not available.")
}