Use a common user-agent (#5894)

This commit is contained in:
Victorien Berlot 2021-02-17 14:38:53 +01:00 committed by GitHub
parent 2ad36b1f38
commit d25f2cc4c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 13 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Scantrad'
pkgNameSuffix = 'fr.scantrad'
extClass = '.Scantrad'
extVersionCode = 15
extVersionCode = 16
libVersion = '1.2'
}

View File

@ -21,8 +21,6 @@ import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
import java.util.concurrent.TimeUnit
import kotlin.math.absoluteValue
import kotlin.random.Random
class Scantrad : ParsedHttpSource() {
@ -43,7 +41,7 @@ class Scantrad : ParsedHttpSource() {
.build()
override fun headersBuilder(): Headers.Builder = Headers.Builder()
.add("User-Agent", generateRandomUserAgent(Random.nextInt(10, 30).absoluteValue))
.add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36")
.add("Accept-Language", "fr")
// Popular
@ -216,13 +214,4 @@ class Scantrad : ParsedHttpSource() {
override fun imageUrlParse(document: Document) = throw UnsupportedOperationException("Not used")
override fun getFilterList() = FilterList()
// Misc
private fun generateRandomUserAgent(length: Int): String {
val allowedChars: List<Char> = ('a'..'z') + ('A'..'Z') + ('0'..'9')
return (1..length)
.map { allowedChars.random() }
.joinToString("")
}
}