mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-18 15:07:30 +01:00
LoginSource moved to an interface
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package eu.kanade.tachiyomi.data.source.online
|
||||
|
||||
import eu.kanade.tachiyomi.data.source.Source
|
||||
import okhttp3.Response
|
||||
import rx.Observable
|
||||
|
||||
interface LoginSource : Source {
|
||||
|
||||
fun isLogged(): Boolean
|
||||
|
||||
fun login(username: String, password: String): Observable<Boolean>
|
||||
|
||||
fun isAuthenticationSuccessful(response: Response): Boolean
|
||||
|
||||
}
|
||||
@@ -78,18 +78,6 @@ abstract class OnlineSource(context: Context) : Source {
|
||||
*/
|
||||
override fun toString() = "$name (${lang.code})"
|
||||
|
||||
// Login source
|
||||
|
||||
open fun isLoginRequired() = false
|
||||
|
||||
open fun isLogged(): Boolean = throw Exception("Not implemented")
|
||||
|
||||
open fun login(username: String, password: String): Observable<Boolean>
|
||||
= throw Exception("Not implemented")
|
||||
|
||||
open fun isAuthenticationSuccessful(response: Response): Boolean
|
||||
= throw Exception("Not implemented")
|
||||
|
||||
/**
|
||||
* Returns an observable containing a page with a list of manga. Normally it's not needed to
|
||||
* override this method.
|
||||
|
||||
@@ -145,8 +145,7 @@ class YamlOnlineSource(context: Context, mappings: Map<*, *>) : OnlineSource(con
|
||||
}
|
||||
|
||||
for ((i, element) in document.select(image_css).withIndex()) {
|
||||
val page = pages.getOrElse(i) { Page(i, "").apply { pages.add(this) } }
|
||||
page.imageUrl = element.attr(image_attr).let {
|
||||
pages.getOrNull(i)?.imageUrl = element.attr(image_attr).let {
|
||||
getAbsoluteUrl(it, response.request().url())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import eu.kanade.tachiyomi.data.source.EN
|
||||
import eu.kanade.tachiyomi.data.source.Language
|
||||
import eu.kanade.tachiyomi.data.source.model.MangasPage
|
||||
import eu.kanade.tachiyomi.data.source.model.Page
|
||||
import eu.kanade.tachiyomi.data.source.online.LoginSource
|
||||
import eu.kanade.tachiyomi.data.source.online.ParsedOnlineSource
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.Request
|
||||
@@ -26,7 +27,7 @@ import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class Batoto(context: Context, override val id: Int) : ParsedOnlineSource(context) {
|
||||
class Batoto(context: Context, override val id: Int) : ParsedOnlineSource(context), LoginSource {
|
||||
|
||||
override val name = "Batoto"
|
||||
|
||||
@@ -238,8 +239,6 @@ class Batoto(context: Context, override val id: Int) : ParsedOnlineSource(contex
|
||||
return client.newCall(POST(url, headers, payload)).asObservable()
|
||||
}
|
||||
|
||||
override fun isLoginRequired() = true
|
||||
|
||||
override fun isAuthenticationSuccessful(response: Response) =
|
||||
response.priorResponse() != null && response.priorResponse().code() == 302
|
||||
|
||||
|
||||
Reference in New Issue
Block a user