Fix TMO / Lector (#2189)

* Update build.gradle

* Update build.gradle

* Update TMO

* Update LectorManga.kt

* Change Date / Time

* Update TuMangaOnline.kt

* Update date format

* Update LectorManga.kt

* Update Time

* Update Time

* Clean up TMO time code

* Clean up Lector time code

* Fix url

* Update URL

* Update userAgent Version

* Update userAgent Version
This commit is contained in:
happywillow0 2020-02-05 07:03:22 -05:00 committed by GitHub
parent a649c171c6
commit 98ff250c7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 28 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: LectorManga' appName = 'Tachiyomi: LectorManga'
pkgNameSuffix = 'es.lectormanga' pkgNameSuffix = 'es.lectormanga'
extClass = '.LectorManga' extClass = '.LectorManga'
extVersionCode = 6 extVersionCode = 7
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -42,7 +42,7 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
.followRedirects(true) .followRedirects(true)
.build()!! .build()!!
private val userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" private val userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36"
override fun headersBuilder(): Headers.Builder { override fun headersBuilder(): Headers.Builder {
return Headers.Builder() return Headers.Builder()
@ -187,16 +187,13 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector() override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
private val scriptselector = "disqus_config"
override fun chapterListParse(response: Response): List<SChapter> { override fun chapterListParse(response: Response): List<SChapter> {
time1 = SimpleDateFormat("yyyy-M-d k:m:s", Locale.US).format(Date()) //Emulate when the chapter page is opened time = serverTime() //Get time when the chapter page is opened
val document = response.asJsoup() val document = response.asJsoup()
val chapterurl = response.request().url().toString() val chapterurl = response.request().url().toString()
val script = document.select("script:containsData($scriptselector)").html() val chapteridselector = ""
val chapteridselector = script.substringAfter("getAttribute(\"").substringBefore("\"")
// One-shot // One-shot
if (document.select("#chapters").isEmpty()) { if (document.select("#chapters").isEmpty()) {
return document.select(oneShotChapterListSelector()).map { oneShotChapterFromElement(it, chapterurl, chapteridselector) } return document.select(oneShotChapterListSelector()).map { oneShotChapterFromElement(it, chapterurl, chapteridselector) }
@ -242,16 +239,21 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
} }
private fun parseChapterDate(date: String): Long = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(date).time private fun parseChapterDate(date: String): Long = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(date).time
private var time1 = SimpleDateFormat("yyyy-M-d k:m:s", Locale.US).format(Date()) //Grab time at app launch, can be updated private var time = serverTime() //Grab time at app launch, can be updated
private fun serverTime() :String {
val formatter = SimpleDateFormat("yyyy-MM-dd kk:mm:ss", Locale.US)
formatter.timeZone = TimeZone.getTimeZone("GMT+1") //Convert time to match server
return formatter.format(Date())
}
override fun pageListRequest(chapter: SChapter): Request { override fun pageListRequest(chapter: SChapter): Request {
val (chapterURL, chapterID) = chapter.url.split("#") val (chapterURL, chapterID) = chapter.url.split("#")
val response = client.newCall(GET(chapterURL, headers)).execute() //Get chapter page for current token val response = client.newCall(GET(chapterURL, headers)).execute() //Get chapter page for current token
val document = response.asJsoup() val document = response.asJsoup()
val geturl = document.select("form#$chapterID").attr("action") //Get redirect URL val geturl = document.select("form#$chapterID").attr("action")+"/$time" //Get redirect URL
val token = document.select("form#$chapterID input").attr("value") //Get token val token = document.select("form#$chapterID input").attr("value") //Get token
val method = document.select("form#$chapterID").attr("method") //Check POST or GET val method = document.select("form#$chapterID").attr("method") //Check POST or GET
val time2 = SimpleDateFormat("yyyy-M-d k:m:s", Locale.US).format(Date()) //Get time of chapter request time = serverTime() //Update time for next chapter
val getHeaders = headersBuilder() val getHeaders = headersBuilder()
.add("User-Agent", userAgent) .add("User-Agent", userAgent)
@ -263,8 +265,6 @@ class LectorManga : ConfigurableSource, ParsedHttpSource() {
"GET" -> null "GET" -> null
"POST" -> FormBody.Builder() "POST" -> FormBody.Builder()
.add("_token", token) .add("_token", token)
.add("time", time1)
.add("time2", time2)
.build() .build()
else -> throw UnsupportedOperationException("Unknown method. Open GitHub issue") else -> throw UnsupportedOperationException("Unknown method. Open GitHub issue")
} }

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: TuMangaOnline' appName = 'Tachiyomi: TuMangaOnline'
pkgNameSuffix = 'es.tumangaonline' pkgNameSuffix = 'es.tumangaonline'
extClass = '.TuMangaOnline' extClass = '.TuMangaOnline'
extVersionCode = 22 extVersionCode = 23
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -40,7 +40,7 @@ class TuMangaOnline : ConfigurableSource, ParsedHttpSource() {
.followRedirects(true) .followRedirects(true)
.build()!! .build()!!
private val userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" //last updated 2020/01/06 private val userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36" //last updated 2020/02/04
override fun headersBuilder(): Headers.Builder { override fun headersBuilder(): Headers.Builder {
return Headers.Builder() return Headers.Builder()
@ -198,16 +198,12 @@ class TuMangaOnline : ConfigurableSource, ParsedHttpSource() {
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector() override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
private val scriptselector = "addEventListener"
override fun chapterListParse(response: Response): List<SChapter> { override fun chapterListParse(response: Response): List<SChapter> {
time1 = SimpleDateFormat("yyyy-M-d k:m:s", Locale.US).format(Date()) //Emulate when the chapter pate is opened time = serverTime() //Get time when the chapter page is opened
val document = response.asJsoup() val document = response.asJsoup()
val chapterurl = response.request().url().toString() val chapterurl = response.request().url().toString()
val script = document.select("script:containsData($scriptselector)").html() val chapteridselector = ""
val chapteridselector = script.substringAfter("getAttribute(\"").substringBefore("\"")
// One-shot // One-shot
if (document.select("div.chapters").isEmpty()) { if (document.select("div.chapters").isEmpty()) {
return document.select(oneShotChapterListSelector()).map { oneShotChapterFromElement(it, chapterurl, chapteridselector) } return document.select(oneShotChapterListSelector()).map { oneShotChapterFromElement(it, chapterurl, chapteridselector) }
@ -253,17 +249,22 @@ class TuMangaOnline : ConfigurableSource, ParsedHttpSource() {
} }
private fun parseChapterDate(date: String): Long = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(date).time private fun parseChapterDate(date: String): Long = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(date).time
private var time1 = SimpleDateFormat("yyyy-M-d k:m:s", Locale.US).format(Date()) //Grab time at app launch, can be updated private var time = serverTime() //Grab time at app launch, can be updated
private fun serverTime() :String {
val formatter = SimpleDateFormat("yyyy-MM-dd kk:mm:ss", Locale.US)
formatter.timeZone = TimeZone.getTimeZone("GMT+1") //Convert time to match server
return formatter.format(Date())
}
override fun pageListRequest(chapter: SChapter): Request { override fun pageListRequest(chapter: SChapter): Request {
val (chapterURL, chapterID) = chapter.url.split("#") val (chapterURL, chapterID) = chapter.url.split("#")
val response = client.newCall(GET(chapterURL, headers)).execute() //Get chapter page for current token val response = client.newCall(GET(chapterURL, headers)).execute() //Get chapter page for current token
val document = response.asJsoup() val document = response.asJsoup()
val geturl = document.select("form#$chapterID").attr("action") //Get redirect URL val geturl = document.select("form#$chapterID").attr("action")+"/$time" //Get redirect URL
val token = document.select("form#$chapterID input").attr("value") //Get token val token = document.select("form#$chapterID input").attr("value") //Get token
val method = document.select("form#$chapterID").attr("method") //Check POST or GET val method = document.select("form#$chapterID").attr("method") //Check POST or GET
val time2 = SimpleDateFormat("yyyy-M-d k:m:s", Locale.US).format(Date()) //Get time of chapter request time = serverTime() //Update time for next chapter
val getHeaders = headersBuilder() val getHeaders = headersBuilder()
.add("User-Agent", userAgent) .add("User-Agent", userAgent)
.add("Referer", chapterURL) .add("Referer", chapterURL)
@ -274,8 +275,6 @@ class TuMangaOnline : ConfigurableSource, ParsedHttpSource() {
"GET" -> null "GET" -> null
"POST" -> FormBody.Builder() "POST" -> FormBody.Builder()
.add("_token", token) .add("_token", token)
.add("time", time1)
.add("time2", time2)
.build() .build()
else -> throw UnsupportedOperationException("Unknown method. Open GitHub issue") else -> throw UnsupportedOperationException("Unknown method. Open GitHub issue")
} }