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' appName = 'Tachiyomi: MangaDex'
pkgNameSuffix = 'all.mangadex' pkgNameSuffix = 'all.mangadex'
extClass = '.MangadexFactory' extClass = '.MangadexFactory'
extVersionCode = 38 extVersionCode = 39
extVersionSuffix = 38 extVersionSuffix = 39
libVersion = '1.2' 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.ConfigurableSource
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.HttpUrl import okhttp3.*
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
@ -53,6 +50,10 @@ open class Mangadex(override val lang: String, private val internalLang: String,
chain.proceed(newReq) chain.proceed(newReq)
}.build()!! }.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 { private fun cookiesHeader(r18Toggle: Int, langCode: Int): String {
val cookies = mutableMapOf<String, String>() val cookies = mutableMapOf<String, String>()
cookies["mangadex_h_toggle"] = r18Toggle.toString() cookies["mangadex_h_toggle"] = r18Toggle.toString()