MyReadingManga: Fix potential memory leaks and exceptions (#10848)
This commit is contained in:
parent
7b44fec7db
commit
7071d503a7
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'MyReadingManga'
|
extName = 'MyReadingManga'
|
||||||
extClass = '.MyReadingMangaFactory'
|
extClass = '.MyReadingMangaFactory'
|
||||||
extVersionCode = 58
|
extVersionCode = 59
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -144,7 +144,7 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
|
|||||||
|
|
||||||
// Manga Details
|
// Manga Details
|
||||||
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
||||||
val needCover = manga.thumbnail_url?.let { !client.newCall(GET(it, headers)).execute().isSuccessful } ?: true
|
val needCover = manga.thumbnail_url?.let { url -> client.newCall(GET(url, headers)).execute().use { !it.isSuccessful } } ?: true
|
||||||
|
|
||||||
return client.newCall(mangaDetailsRequest(manga))
|
return client.newCall(mangaDetailsRequest(manga))
|
||||||
.asObservableSuccess()
|
.asObservableSuccess()
|
||||||
@ -172,12 +172,12 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (needCover) {
|
if (needCover) {
|
||||||
thumbnail_url = getThumbnail(
|
thumbnail_url = client.newCall(GET("$baseUrl/search/?search=${document.location()}", headers))
|
||||||
getImage(
|
.execute().use {
|
||||||
client.newCall(GET("$baseUrl/search/?search=${document.location()}", headers))
|
it.asJsoup().select("div.wdm_results div.p_content img").firstOrNull()
|
||||||
.execute().asJsoup().select("div.wdm_results div.p_content img").first()!!,
|
}?.let {
|
||||||
),
|
getThumbnail(getImage(it))
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,16 +193,15 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
|
|||||||
val chapters = mutableListOf<SChapter>()
|
val chapters = mutableListOf<SChapter>()
|
||||||
|
|
||||||
val date = parseDate(document.select(".entry-time").text())
|
val date = parseDate(document.select(".entry-time").text())
|
||||||
val mangaUrl = document.baseUri()
|
|
||||||
// create first chapter since its on main manga page
|
// create first chapter since its on main manga page
|
||||||
chapters.add(createChapter("1", document.baseUri(), date, "Part 1"))
|
chapters.add(createChapter("1", document.baseUri(), date, "Part 1"))
|
||||||
// see if there are multiple chapters or not
|
// see if there are multiple chapters or not
|
||||||
val lastChapterNumber = document.select(chapterListSelector()).last()?.text()
|
val lastChapterNumber = document.select(chapterListSelector()).last()?.text()?.toIntOrNull()
|
||||||
if (lastChapterNumber != null) {
|
if (lastChapterNumber != null) {
|
||||||
// There are entries with more chapters but those never show up,
|
// There are entries with more chapters but those never show up,
|
||||||
// so we take the last one and loop it to get all hidden ones.
|
// so we take the last one and loop it to get all hidden ones.
|
||||||
// Example: 1 2 3 4 .. 7 8 9 Next
|
// Example: 1 2 3 4 .. 7 8 9 Next
|
||||||
for (i in 2..lastChapterNumber.toInt()) {
|
for (i in 2..lastChapterNumber) {
|
||||||
chapters.add(createChapter(i.toString(), document.baseUri(), date, "Part $i"))
|
chapters.add(createChapter(i.toString(), document.baseUri(), date, "Part $i"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,8 +240,9 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
|
|||||||
|
|
||||||
// Grabs page containing filters and puts it into cache
|
// Grabs page containing filters and puts it into cache
|
||||||
private fun filterAssist(url: String) {
|
private fun filterAssist(url: String) {
|
||||||
val response = client.newCall(GET(url, headers)).execute()
|
filterMap[url] = client.newCall(GET(url, headers)).execute().use {
|
||||||
filterMap[url] = response.body.string()
|
it.body.string()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun cacheAssistant() {
|
private fun cacheAssistant() {
|
||||||
@ -254,7 +254,7 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
|
|||||||
|
|
||||||
// Parses cached page for filters
|
// Parses cached page for filters
|
||||||
private fun returnFilter(url: String, css: String): Array<String> {
|
private fun returnFilter(url: String, css: String): Array<String> {
|
||||||
val document = if (filterMap.isNullOrEmpty()) {
|
val document = if (filterMap.isEmpty()) {
|
||||||
filtersCached = false
|
filtersCached = false
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
@ -294,11 +294,11 @@ open class MyReadingManga(override val lang: String, private val siteLang: Strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GenreFilter(GENRES: Array<String>) : UriSelectFilter("Genre", "genre_str", arrayOf("Any", *GENRES))
|
private class GenreFilter(genres: Array<String>) : UriSelectFilter("Genre", "genre_str", arrayOf("Any", *genres))
|
||||||
private class TagFilter(POPTAG: Array<String>) : UriSelectFilter("Popular Tags", "tags", arrayOf("Any", *POPTAG))
|
private class TagFilter(popTags: Array<String>) : UriSelectFilter("Popular Tags", "tags", arrayOf("Any", *popTags))
|
||||||
private class CatFilter(CATID: Array<String>) : UriSelectFilter("Categories", "categories", arrayOf("Any", *CATID))
|
private class CatFilter(catIds: Array<String>) : UriSelectFilter("Categories", "categories", arrayOf("Any", *catIds))
|
||||||
private class PairingFilter(PAIR: Array<String>) : UriSelectFilter("Pairing", "pairing_str", arrayOf("Any", *PAIR))
|
private class PairingFilter(pairs: Array<String>) : UriSelectFilter("Pairing", "pairing_str", arrayOf("Any", *pairs))
|
||||||
private class ScanGroupFilter(GROUP: Array<String>) : UriSelectFilter("Scanlation Group", "group_str", arrayOf("Any", *GROUP))
|
private class ScanGroupFilter(groups: Array<String>) : UriSelectFilter("Scanlation Group", "group_str", arrayOf("Any", *groups))
|
||||||
private class SearchSortTypeList : Filter.Select<String>("Sort by", arrayOf("Newest", "Oldest", "Random", "More relevant"))
|
private class SearchSortTypeList : Filter.Select<String>("Sort by", arrayOf("Newest", "Oldest", "Random", "More relevant"))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user