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()
@ -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 TextField(name: String, val key: String) : Filter.Text(name)
private class Genre(val id: String, name: String) : Filter.TriState(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 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 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()) private class OriginalLanguage : Filter.Select<String>("Original Language", SOURCE_LANG_LIST.map { it -> it.first }.toTypedArray())
@ -427,48 +428,48 @@ open class Mangadex(override val lang: String, private val internalLang: String,
GenreList(getGenreList()) GenreList(getGenreList())
) )
private fun getGenreList() =listOf( private fun getGenreList() = listOf(
Genre("1", "4-koma"), Genre("1", "4-koma"),
Genre("2", "Action"), Genre("2", "Action"),
Genre("3", "Adventure"), Genre("3", "Adventure"),
Genre("4", "Award Winning"), Genre("4", "Award Winning"),
Genre("5", "Comedy"), Genre("5", "Comedy"),
Genre("6", "Cooking"), Genre("6", "Cooking"),
Genre("7", "Doujinshi"), Genre("7", "Doujinshi"),
Genre("8", "Drama"), Genre("8", "Drama"),
Genre("9", "Ecchi"), Genre("9", "Ecchi"),
Genre("10", "Fantasy"), Genre("10", "Fantasy"),
Genre("11", "Gender Bender"), Genre("11", "Gender Bender"),
Genre("12", "Harem"), Genre("12", "Harem"),
Genre("13", "Historical"), Genre("13", "Historical"),
Genre("14", "Horror"), Genre("14", "Horror"),
Genre("15", "Josei"), Genre("15", "Josei"),
Genre("16", "Martial Arts"), Genre("16", "Martial Arts"),
Genre("17", "Mecha"), Genre("17", "Mecha"),
Genre("18", "Medical"), Genre("18", "Medical"),
Genre("19", "Music"), Genre("19", "Music"),
Genre("20", "Mystery"), Genre("20", "Mystery"),
Genre("21", "Oneshot"), Genre("21", "Oneshot"),
Genre("22", "Psychological"), Genre("22", "Psychological"),
Genre("23", "Romance"), Genre("23", "Romance"),
Genre("24", "School Life"), Genre("24", "School Life"),
Genre("25", "Sci-Fi"), Genre("25", "Sci-Fi"),
Genre("26", "Seinen"), Genre("26", "Seinen"),
Genre("27", "Shoujo"), Genre("27", "Shoujo"),
Genre("28", "Shoujo Ai"), Genre("28", "Shoujo Ai"),
Genre("29", "Shounen"), Genre("29", "Shounen"),
Genre("30", "Shounen Ai"), Genre("30", "Shounen Ai"),
Genre("31", "Slice of Life"), Genre("31", "Slice of Life"),
Genre("32", "Smut"), Genre("32", "Smut"),
Genre("33", "Sports"), Genre("33", "Sports"),
Genre("34", "Supernatural"), Genre("34", "Supernatural"),
Genre("35", "Tragedy"), Genre("35", "Tragedy"),
Genre("36", "Webtoon"), Genre("36", "Webtoon"),
Genre("37", "Yaoi"), Genre("37", "Yaoi"),
Genre("38", "Yuri"), Genre("38", "Yuri"),
Genre("39", "[no chapters]"), Genre("39", "[no chapters]"),
Genre("40", "Game"), Genre("40", "Game"),
Genre("41", "Isekai")) Genre("41", "Isekai"))
companion object { companion object {
private val WHITESPACE_REGEX = "\\s".toRegex() private val WHITESPACE_REGEX = "\\s".toRegex()