add useragent to mangadex (#500)

* add useragent

* format lines
This commit is contained in:
Carlos 2018-09-17 18:00:04 -04:00 committed by GitHub
parent 59f30cd218
commit a3d5df9b9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 49 deletions

View File

@ -5,8 +5,8 @@ ext {
appName = 'Tachiyomi: MangaDex'
pkgNameSuffix = 'all.mangadex'
extClass = '.MangadexFactory'
extVersionCode = 38
extVersionSuffix = 38
extVersionCode = 39
extVersionSuffix = 39
libVersion = '1.2'
}

View File

@ -13,10 +13,7 @@ import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.HttpUrl
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import okhttp3.*
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
@ -53,6 +50,10 @@ open class Mangadex(override val lang: String, private val internalLang: String,
chain.proceed(newReq)
}.build()!!
override fun headersBuilder() = Headers.Builder().apply {
add("User-Agent", "Tachiyomi Mozilla/5.0 (Windows NT 6.3; WOW64)")
}
private fun cookiesHeader(r18Toggle: Int, langCode: Int): String {
val cookies = mutableMapOf<String, String>()
cookies["mangadex_h_toggle"] = r18Toggle.toString()
@ -414,7 +415,7 @@ open class Mangadex(override val lang: String, private val internalLang: String,
private class TextField(name: String, val key: String) : Filter.Text(name)
private class Genre(val id: String, name: String) : Filter.TriState(name)
private class GenreList(genres: List<Genre>) : Filter.Group<Genre>("Genres", genres)
private class R18 : Filter.Select<String>("R18+", arrayOf("Default","Show all", "Show only", "Show none"))
private class R18 : Filter.Select<String>("R18+", arrayOf("Default", "Show all", "Show only", "Show none"))
private class Demographic : Filter.Select<String>("Demographic", arrayOf("All", "Shounen", "Shoujo", "Seinen", "Josei"))
private class OriginalLanguage : Filter.Select<String>("Original Language", SOURCE_LANG_LIST.map { it -> it.first }.toTypedArray())
@ -427,7 +428,7 @@ open class Mangadex(override val lang: String, private val internalLang: String,
GenreList(getGenreList())
)
private fun getGenreList() =listOf(
private fun getGenreList() = listOf(
Genre("1", "4-koma"),
Genre("2", "Action"),
Genre("3", "Adventure"),