Dependency updates. OkHttp nullability changes
This commit is contained in:
parent
72ea256906
commit
211f7b591b
22 changed files with 40 additions and 45 deletions
|
@ -120,17 +120,17 @@ dependencies {
|
||||||
|
|
||||||
// ReactiveX
|
// ReactiveX
|
||||||
compile 'io.reactivex:rxandroid:1.2.1'
|
compile 'io.reactivex:rxandroid:1.2.1'
|
||||||
compile 'io.reactivex:rxjava:1.2.9'
|
compile 'io.reactivex:rxjava:1.3.0'
|
||||||
compile 'com.jakewharton.rxrelay:rxrelay:1.2.0'
|
compile 'com.jakewharton.rxrelay:rxrelay:1.2.0'
|
||||||
compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.2'
|
compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.2'
|
||||||
compile 'com.github.pwittchen:reactivenetwork:0.7.0'
|
compile 'com.github.pwittchen:reactivenetwork:0.7.0'
|
||||||
|
|
||||||
// Network client
|
// Network client
|
||||||
compile "com.squareup.okhttp3:okhttp:3.6.0"
|
compile "com.squareup.okhttp3:okhttp:3.8.0"
|
||||||
compile 'com.squareup.okio:okio:1.11.0'
|
compile 'com.squareup.okio:okio:1.13.0'
|
||||||
|
|
||||||
// REST
|
// REST
|
||||||
final retrofit_version = '2.2.0'
|
final retrofit_version = '2.3.0'
|
||||||
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
|
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
|
||||||
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
||||||
compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
|
compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
|
||||||
|
@ -160,7 +160,7 @@ dependencies {
|
||||||
compile 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0'
|
compile 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0'
|
||||||
|
|
||||||
// Database
|
// Database
|
||||||
compile "com.pushtorefresh.storio:sqlite:1.12.3"
|
compile "com.pushtorefresh.storio:sqlite:1.13.0"
|
||||||
|
|
||||||
// Model View Presenter
|
// Model View Presenter
|
||||||
final nucleus_version = '3.0.0'
|
final nucleus_version = '3.0.0'
|
||||||
|
@ -172,8 +172,8 @@ dependencies {
|
||||||
compile "uy.kohesive.injekt:injekt-core:1.16.1"
|
compile "uy.kohesive.injekt:injekt-core:1.16.1"
|
||||||
|
|
||||||
// Image library
|
// Image library
|
||||||
compile 'com.github.bumptech.glide:glide:3.7.0'
|
compile 'com.github.bumptech.glide:glide:3.8.0'
|
||||||
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
|
compile 'com.github.bumptech.glide:okhttp3-integration:1.5.0@aar'
|
||||||
// Transformations
|
// Transformations
|
||||||
compile 'jp.wasabeef:glide-transformations:2.0.2'
|
compile 'jp.wasabeef:glide-transformations:2.0.2'
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ dependencies {
|
||||||
compile 'eu.davidea:flexible-adapter:5.0.0-rc1'
|
compile 'eu.davidea:flexible-adapter:5.0.0-rc1'
|
||||||
compile 'com.nononsenseapps:filepicker:2.5.2'
|
compile 'com.nononsenseapps:filepicker:2.5.2'
|
||||||
compile 'com.github.amulyakhare:TextDrawable:558677e'
|
compile 'com.github.amulyakhare:TextDrawable:558677e'
|
||||||
compile 'com.afollestad.material-dialogs:core:0.9.4.2'
|
compile 'com.afollestad.material-dialogs:core:0.9.4.5'
|
||||||
compile 'me.zhanghai.android.systemuihelper:library:1.0.0'
|
compile 'me.zhanghai.android.systemuihelper:library:1.0.0'
|
||||||
compile 'de.hdodenhof:circleimageview:2.1.0'
|
compile 'de.hdodenhof:circleimageview:2.1.0'
|
||||||
compile 'com.nightlynexus.viewstatepageradapter:viewstatepageradapter:1.0.4'
|
compile 'com.nightlynexus.viewstatepageradapter:viewstatepageradapter:1.0.4'
|
||||||
|
|
|
@ -187,12 +187,12 @@ class ChapterCache(private val context: Context) {
|
||||||
editor = diskCache.edit(key) ?: throw IOException("Unable to edit key")
|
editor = diskCache.edit(key) ?: throw IOException("Unable to edit key")
|
||||||
|
|
||||||
// Get OutputStream and write image with Okio.
|
// Get OutputStream and write image with Okio.
|
||||||
response.body().source().saveTo(editor.newOutputStream(0))
|
response.body()!!.source().saveTo(editor.newOutputStream(0))
|
||||||
|
|
||||||
diskCache.flush()
|
diskCache.flush()
|
||||||
editor.commit()
|
editor.commit()
|
||||||
} finally {
|
} finally {
|
||||||
response.body().close()
|
response.body()?.close()
|
||||||
editor?.abortUnlessCommitted()
|
editor?.abortUnlessCommitted()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,7 +380,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro
|
||||||
.map { response ->
|
.map { response ->
|
||||||
val file = tmpDir.createFile("$filename.tmp")
|
val file = tmpDir.createFile("$filename.tmp")
|
||||||
try {
|
try {
|
||||||
response.body().source().saveTo(file.openOutputStream())
|
response.body()!!.source().saveTo(file.openOutputStream())
|
||||||
val extension = getImageExtension(response, file)
|
val extension = getImageExtension(response, file)
|
||||||
file.renameTo("$filename.$extension")
|
file.renameTo("$filename.$extension")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -403,7 +403,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro
|
||||||
*/
|
*/
|
||||||
private fun getImageExtension(response: Response, file: UniFile): String {
|
private fun getImageExtension(response: Response, file: UniFile): String {
|
||||||
// Read content type if available.
|
// Read content type if available.
|
||||||
val mime = response.body().contentType()?.let { ct -> "${ct.type()}/${ct.subtype()}" }
|
val mime = response.body()?.contentType()?.let { ct -> "${ct.type()}/${ct.subtype()}" }
|
||||||
// Else guess from the uri.
|
// Else guess from the uri.
|
||||||
?: context.contentResolver.getType(file.uri)
|
?: context.contentResolver.getType(file.uri)
|
||||||
// Else read magic numbers.
|
// Else read magic numbers.
|
||||||
|
|
|
@ -26,7 +26,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
||||||
fun addLibManga(track: Track): Observable<Track> {
|
fun addLibManga(track: Track): Observable<Track> {
|
||||||
return rest.addLibManga(track.remote_id, track.last_chapter_read, track.toAnilistStatus())
|
return rest.addLibManga(track.remote_id, track.last_chapter_read, track.toAnilistStatus())
|
||||||
.map { response ->
|
.map { response ->
|
||||||
response.body().close()
|
response.body()?.close()
|
||||||
if (!response.isSuccessful) {
|
if (!response.isSuccessful) {
|
||||||
throw Exception("Could not add manga")
|
throw Exception("Could not add manga")
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
||||||
return rest.updateLibManga(track.remote_id, track.last_chapter_read, track.toAnilistStatus(),
|
return rest.updateLibManga(track.remote_id, track.last_chapter_read, track.toAnilistStatus(),
|
||||||
track.toAnilistScore())
|
track.toAnilistScore())
|
||||||
.map { response ->
|
.map { response ->
|
||||||
response.body().close()
|
response.body()?.close()
|
||||||
if (!response.isSuccessful) {
|
if (!response.isSuccessful) {
|
||||||
throw Exception("Could not update manga")
|
throw Exception("Could not update manga")
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class AnilistInterceptor(private var refreshToken: String?) : Interceptor {
|
||||||
if (oauth == null || oauth!!.isExpired()) {
|
if (oauth == null || oauth!!.isExpired()) {
|
||||||
val response = chain.proceed(AnilistApi.refreshTokenRequest(refreshToken!!))
|
val response = chain.proceed(AnilistApi.refreshTokenRequest(refreshToken!!))
|
||||||
oauth = if (response.isSuccessful) {
|
oauth = if (response.isSuccessful) {
|
||||||
Gson().fromJson(response.body().string(), OAuth::class.java)
|
Gson().fromJson(response.body()!!.string(), OAuth::class.java)
|
||||||
} else {
|
} else {
|
||||||
response.close()
|
response.close()
|
||||||
null
|
null
|
||||||
|
|
|
@ -22,7 +22,7 @@ class KitsuInterceptor(val kitsu: Kitsu, val gson: Gson) : Interceptor {
|
||||||
if (currAuth.isExpired()) {
|
if (currAuth.isExpired()) {
|
||||||
val response = chain.proceed(KitsuApi.refreshTokenRequest(refreshToken))
|
val response = chain.proceed(KitsuApi.refreshTokenRequest(refreshToken))
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
newAuth(gson.fromJson(response.body().string(), OAuth::class.java))
|
newAuth(gson.fromJson(response.body()!!.string(), OAuth::class.java))
|
||||||
} else {
|
} else {
|
||||||
response.close()
|
response.close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class MyanimelistApi(private val client: OkHttpClient, username: String, passwor
|
||||||
} else {
|
} else {
|
||||||
client.newCall(GET(getSearchUrl(query), headers))
|
client.newCall(GET(getSearchUrl(query), headers))
|
||||||
.asObservable()
|
.asObservable()
|
||||||
.map { Jsoup.parse(it.body().string()) }
|
.map { Jsoup.parse(it.body()!!.string()) }
|
||||||
.flatMap { Observable.from(it.select("entry")) }
|
.flatMap { Observable.from(it.select("entry")) }
|
||||||
.filter { it.select("type").text() != "Novel" }
|
.filter { it.select("type").text() != "Novel" }
|
||||||
.map {
|
.map {
|
||||||
|
@ -64,7 +64,7 @@ class MyanimelistApi(private val client: OkHttpClient, username: String, passwor
|
||||||
return client
|
return client
|
||||||
.newCall(GET(getListUrl(username), headers))
|
.newCall(GET(getListUrl(username), headers))
|
||||||
.asObservable()
|
.asObservable()
|
||||||
.map { Jsoup.parse(it.body().string()) }
|
.map { Jsoup.parse(it.body()!!.string()) }
|
||||||
.flatMap { Observable.from(it.select("manga")) }
|
.flatMap { Observable.from(it.select("manga")) }
|
||||||
.map {
|
.map {
|
||||||
Track.create(TrackManager.MYANIMELIST).apply {
|
Track.create(TrackManager.MYANIMELIST).apply {
|
||||||
|
|
|
@ -86,7 +86,7 @@ class UpdateDownloaderService : IntentService(UpdateDownloaderService::class.jav
|
||||||
val apkFile = File(externalCacheDir, "update.apk")
|
val apkFile = File(externalCacheDir, "update.apk")
|
||||||
|
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
response.body().source().saveTo(apkFile)
|
response.body()!!.source().saveTo(apkFile)
|
||||||
} else {
|
} else {
|
||||||
response.close()
|
response.close()
|
||||||
throw Exception("Unsuccessful response")
|
throw Exception("Unsuccessful response")
|
||||||
|
|
|
@ -8,13 +8,10 @@ import okhttp3.Response
|
||||||
|
|
||||||
class CloudflareInterceptor : Interceptor {
|
class CloudflareInterceptor : Interceptor {
|
||||||
|
|
||||||
//language=RegExp
|
|
||||||
private val operationPattern = Regex("""setTimeout\(function\(\)\{\s+(var (?:\w,)+f.+?\r?\n[\s\S]+?a\.value =.+?)\r?\n""")
|
private val operationPattern = Regex("""setTimeout\(function\(\)\{\s+(var (?:\w,)+f.+?\r?\n[\s\S]+?a\.value =.+?)\r?\n""")
|
||||||
|
|
||||||
//language=RegExp
|
|
||||||
private val passPattern = Regex("""name="pass" value="(.+?)"""")
|
private val passPattern = Regex("""name="pass" value="(.+?)"""")
|
||||||
|
|
||||||
//language=RegExp
|
|
||||||
private val challengePattern = Regex("""name="jschl_vc" value="(\w+)"""")
|
private val challengePattern = Regex("""name="jschl_vc" value="(\w+)"""")
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
@ -34,7 +31,7 @@ class CloudflareInterceptor : Interceptor {
|
||||||
val originalRequest = response.request()
|
val originalRequest = response.request()
|
||||||
val url = originalRequest.url()
|
val url = originalRequest.url()
|
||||||
val domain = url.host()
|
val domain = url.host()
|
||||||
val content = response.body().string()
|
val content = response.body()!!.string()
|
||||||
|
|
||||||
// CloudFlare requires waiting 4 seconds before resolving the challenge
|
// CloudFlare requires waiting 4 seconds before resolving the challenge
|
||||||
Thread.sleep(4000)
|
Thread.sleep(4000)
|
||||||
|
@ -48,9 +45,7 @@ class CloudflareInterceptor : Interceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
val js = operation
|
val js = operation
|
||||||
//language=RegExp
|
|
||||||
.replace(Regex("""a\.value =(.+?) \+.*"""), "$1")
|
.replace(Regex("""a\.value =(.+?) \+.*"""), "$1")
|
||||||
//language=RegExp
|
|
||||||
.replace(Regex("""\s{3,}[a-z](?: = |\.).+"""), "")
|
.replace(Regex("""\s{3,}[a-z](?: = |\.).+"""), "")
|
||||||
.replace("\n", "")
|
.replace("\n", "")
|
||||||
|
|
||||||
|
@ -58,7 +53,7 @@ class CloudflareInterceptor : Interceptor {
|
||||||
|
|
||||||
val answer = "${result + domain.length}"
|
val answer = "${result + domain.length}"
|
||||||
|
|
||||||
val cloudflareUrl = HttpUrl.parse("${url.scheme()}://$domain/cdn-cgi/l/chk_jschl")
|
val cloudflareUrl = HttpUrl.parse("${url.scheme()}://$domain/cdn-cgi/l/chk_jschl")!!
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.addQueryParameter("jschl_vc", challenge)
|
.addQueryParameter("jschl_vc", challenge)
|
||||||
.addQueryParameter("pass", pass)
|
.addQueryParameter("pass", pass)
|
||||||
|
|
|
@ -61,7 +61,7 @@ fun OkHttpClient.newCallWithProgress(request: Request, listener: ProgressListene
|
||||||
.addNetworkInterceptor { chain ->
|
.addNetworkInterceptor { chain ->
|
||||||
val originalResponse = chain.proceed(chain.request())
|
val originalResponse = chain.proceed(chain.request())
|
||||||
originalResponse.newBuilder()
|
originalResponse.newBuilder()
|
||||||
.body(ProgressResponseBody(originalResponse.body(), listener))
|
.body(ProgressResponseBody(originalResponse.body()!!, listener))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -18,7 +18,7 @@ class PersistentCookieStore(context: Context) {
|
||||||
if (cookies != null) {
|
if (cookies != null) {
|
||||||
try {
|
try {
|
||||||
val url = HttpUrl.parse("http://$key")
|
val url = HttpUrl.parse("http://$key")
|
||||||
val nonExpiredCookies = cookies.map { Cookie.parse(url, it) }
|
val nonExpiredCookies = cookies.mapNotNull { Cookie.parse(url, it) }
|
||||||
.filter { !it.hasExpired() }
|
.filter { !it.hasExpired() }
|
||||||
cookieMap.put(key, nonExpiredCookies)
|
cookieMap.put(key, nonExpiredCookies)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ class ProgressResponseBody(private val responseBody: ResponseBody, private val p
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun contentType(): MediaType {
|
override fun contentType(): MediaType {
|
||||||
return responseBody.contentType()
|
return responseBody.contentType()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun contentLength(): Long {
|
override fun contentLength(): Long {
|
||||||
|
|
|
@ -171,7 +171,7 @@ class YamlHttpSource(mappings: Map<*, *>) : HttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val body = response.body().string()
|
val body = response.body()!!.string()
|
||||||
val url = response.request().url().toString()
|
val url = response.request().url().toString()
|
||||||
|
|
||||||
val pages = mutableListOf<Page>()
|
val pages = mutableListOf<Page>()
|
||||||
|
@ -216,7 +216,7 @@ class YamlHttpSource(mappings: Map<*, *>) : HttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(response: Response): String {
|
override fun imageUrlParse(response: Response): String {
|
||||||
val body = response.body().string()
|
val body = response.body()!!.string()
|
||||||
val url = response.request().url().toString()
|
val url = response.request().url().toString()
|
||||||
|
|
||||||
with(map.pages) {
|
with(map.pages) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ class Batoto : ParsedHttpSource(), LoginSource {
|
||||||
override fun latestUpdatesNextPageSelector() = "#show_more_row"
|
override fun latestUpdatesNextPageSelector() = "#show_more_row"
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
val url = HttpUrl.parse("$baseUrl/search_ajax").newBuilder()
|
val url = HttpUrl.parse("$baseUrl/search_ajax")!!.newBuilder()
|
||||||
if (!query.isEmpty()) url.addQueryParameter("name", query).addQueryParameter("name_cond", "c")
|
if (!query.isEmpty()) url.addQueryParameter("name", query).addQueryParameter("name_cond", "c")
|
||||||
var genres = ""
|
var genres = ""
|
||||||
filters.forEach { filter ->
|
filters.forEach { filter ->
|
||||||
|
@ -162,7 +162,7 @@ class Batoto : ParsedHttpSource(), LoginSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
val body = response.body().string()
|
val body = response.body()!!.string()
|
||||||
val matcher = staffNotice.matcher(body)
|
val matcher = staffNotice.matcher(body)
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
|
@ -271,7 +271,7 @@ class Batoto : ParsedHttpSource(), LoginSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isAuthenticationSuccessful(response: Response) =
|
override fun isAuthenticationSuccessful(response: Response) =
|
||||||
response.priorResponse() != null && response.priorResponse().code() == 302
|
response.priorResponse() != null && response.priorResponse()!!.code() == 302
|
||||||
|
|
||||||
override fun isLogged(): Boolean {
|
override fun isLogged(): Boolean {
|
||||||
return network.cookies.get(URI(baseUrl)).any { it.name() == "pass_hash" }
|
return network.cookies.get(URI(baseUrl)).any { it.name() == "pass_hash" }
|
||||||
|
|
|
@ -115,13 +115,13 @@ class Kissmanga : ParsedHttpSource() {
|
||||||
override fun pageListRequest(chapter: SChapter) = POST(baseUrl + chapter.url, headers)
|
override fun pageListRequest(chapter: SChapter) = POST(baseUrl + chapter.url, headers)
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val body = response.body().string()
|
val body = response.body()!!.string()
|
||||||
|
|
||||||
val pages = mutableListOf<Page>()
|
val pages = mutableListOf<Page>()
|
||||||
|
|
||||||
// Kissmanga now encrypts the urls, so we need to execute these two scripts in JS.
|
// Kissmanga now encrypts the urls, so we need to execute these two scripts in JS.
|
||||||
val ca = client.newCall(GET("$baseUrl/Scripts/ca.js", headers)).execute().body().string()
|
val ca = client.newCall(GET("$baseUrl/Scripts/ca.js", headers)).execute().body()!!.string()
|
||||||
val lo = client.newCall(GET("$baseUrl/Scripts/lo.js", headers)).execute().body().string()
|
val lo = client.newCall(GET("$baseUrl/Scripts/lo.js", headers)).execute().body()!!.string()
|
||||||
|
|
||||||
Duktape.create().use {
|
Duktape.create().use {
|
||||||
it.evaluate(ca)
|
it.evaluate(ca)
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Mangafox : ParsedHttpSource() {
|
||||||
override fun latestUpdatesNextPageSelector() = "a:has(span.next)"
|
override fun latestUpdatesNextPageSelector() = "a:has(span.next)"
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
val url = HttpUrl.parse("$baseUrl/search.php?name_method=cw&author_method=cw&artist_method=cw&advopts=1").newBuilder().addQueryParameter("name", query)
|
val url = HttpUrl.parse("$baseUrl/search.php?name_method=cw&author_method=cw&artist_method=cw&advopts=1")!!.newBuilder().addQueryParameter("name", query)
|
||||||
(if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
|
(if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
|
||||||
when (filter) {
|
when (filter) {
|
||||||
is Status -> url.addQueryParameter(filter.id, filter.state.toString())
|
is Status -> url.addQueryParameter(filter.id, filter.state.toString())
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Mangahere : ParsedHttpSource() {
|
||||||
override fun latestUpdatesNextPageSelector() = "div.next-page > a.next"
|
override fun latestUpdatesNextPageSelector() = "div.next-page > a.next"
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
val url = HttpUrl.parse("$baseUrl/search.php?name_method=cw&author_method=cw&artist_method=cw&advopts=1").newBuilder().addQueryParameter("name", query)
|
val url = HttpUrl.parse("$baseUrl/search.php?name_method=cw&author_method=cw&artist_method=cw&advopts=1")!!.newBuilder().addQueryParameter("name", query)
|
||||||
(if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
|
(if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
|
||||||
when (filter) {
|
when (filter) {
|
||||||
is Status -> url.addQueryParameter("is_completed", arrayOf("", "1", "0")[filter.state])
|
is Status -> url.addQueryParameter("is_completed", arrayOf("", "1", "0")[filter.state])
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Mangasee : ParsedHttpSource() {
|
||||||
override fun searchMangaSelector() = "div.requested > div.row"
|
override fun searchMangaSelector() = "div.requested > div.row"
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
val url = HttpUrl.parse("$baseUrl/search/request.php").newBuilder()
|
val url = HttpUrl.parse("$baseUrl/search/request.php")!!.newBuilder()
|
||||||
if (!query.isEmpty()) url.addQueryParameter("keyword", query)
|
if (!query.isEmpty()) url.addQueryParameter("keyword", query)
|
||||||
val genres = mutableListOf<String>()
|
val genres = mutableListOf<String>()
|
||||||
val genresNo = mutableListOf<String>()
|
val genresNo = mutableListOf<String>()
|
||||||
|
@ -84,7 +84,7 @@ class Mangasee : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun convertQueryToPost(page: Int, url: String): Pair<FormBody.Builder, String> {
|
private fun convertQueryToPost(page: Int, url: String): Pair<FormBody.Builder, String> {
|
||||||
val url = HttpUrl.parse(url)
|
val url = HttpUrl.parse(url)!!
|
||||||
val body = FormBody.Builder().add("page", page.toString())
|
val body = FormBody.Builder().add("page", page.toString())
|
||||||
for (i in 0..url.querySize() - 1) {
|
for (i in 0..url.querySize() - 1) {
|
||||||
body.add(url.queryParameterName(i), url.queryParameterValue(i))
|
body.add(url.queryParameterName(i), url.queryParameterValue(i))
|
||||||
|
|
|
@ -152,7 +152,7 @@ class Mangachan : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val html = response.body().string()
|
val html = response.body()!!.string()
|
||||||
val beginIndex = html.indexOf("fullimg\":[") + 10
|
val beginIndex = html.indexOf("fullimg\":[") + 10
|
||||||
val endIndex = html.indexOf(",]", beginIndex)
|
val endIndex = html.indexOf(",]", beginIndex)
|
||||||
val trimmedHtml = html.substring(beginIndex, endIndex).replace("\"", "")
|
val trimmedHtml = html.substring(beginIndex, endIndex).replace("\"", "")
|
||||||
|
|
|
@ -120,7 +120,7 @@ class Mintmanga : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val html = response.body().string()
|
val html = response.body()!!.string()
|
||||||
val beginIndex = html.indexOf("rm_h.init( [")
|
val beginIndex = html.indexOf("rm_h.init( [")
|
||||||
val endIndex = html.indexOf("], 0, false);", beginIndex)
|
val endIndex = html.indexOf("], 0, false);", beginIndex)
|
||||||
val trimmedHtml = html.substring(beginIndex, endIndex)
|
val trimmedHtml = html.substring(beginIndex, endIndex)
|
||||||
|
|
|
@ -120,7 +120,7 @@ class Readmanga : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val html = response.body().string()
|
val html = response.body()!!.string()
|
||||||
val beginIndex = html.indexOf("rm_h.init( [")
|
val beginIndex = html.indexOf("rm_h.init( [")
|
||||||
val endIndex = html.indexOf("], 0, false);", beginIndex)
|
val endIndex = html.indexOf("], 0, false);", beginIndex)
|
||||||
val trimmedHtml = html.substring(beginIndex, endIndex)
|
val trimmedHtml = html.substring(beginIndex, endIndex)
|
||||||
|
|
|
@ -22,5 +22,5 @@ fun Element.attrOrText(css: String): String {
|
||||||
* @param html the body of the response. Use only if the body was read before calling this method.
|
* @param html the body of the response. Use only if the body was read before calling this method.
|
||||||
*/
|
*/
|
||||||
fun Response.asJsoup(html: String? = null): Document {
|
fun Response.asJsoup(html: String? = null): Document {
|
||||||
return Jsoup.parse(html ?: body().string(), request().url().toString())
|
return Jsoup.parse(html ?: body()!!.string(), request().url().toString())
|
||||||
}
|
}
|
Reference in a new issue