Lint fixes

This commit is contained in:
arkon
2020-04-24 23:15:45 -04:00
committed by arkon
parent 60ef2bea02
commit 5d5c6016ea
77 changed files with 644 additions and 588 deletions

View File

@ -4,10 +4,6 @@ import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.os.Build
import com.google.gson.Gson
import okhttp3.OkHttpClient
import okhttp3.Request
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import java.io.PrintWriter
import java.security.cert.CertificateException
import java.time.ZonedDateTime
@ -16,6 +12,10 @@ import java.util.concurrent.TimeUnit
import javax.net.ssl.SSLContext
import javax.net.ssl.TrustManager
import javax.net.ssl.X509TrustManager
import okhttp3.OkHttpClient
import okhttp3.Request
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
/**
* This class generates the sources for MMRCMS.
@ -55,10 +55,10 @@ class Generator {
var prefix = itemUrl.substringAfterLast("/").substringBeforeLast("/")
//Sometimes itemUrl is the root of the website, and thus the prefix found is the website address.
// Sometimes itemUrl is the root of the website, and thus the prefix found is the website address.
// In this case, we set the default prefix as "manga".
if (prefix.startsWith("www")){
prefix="manga"
if (prefix.startsWith("www")) {
prefix = "manga"
}
val mangaListDocument = getDocument("${it.third}/$prefix-list")!!
@ -78,10 +78,8 @@ class Generator {
val toJson = Gson().toJson(map)
buffer.append("private const val MMRSOURCE_$number = \"\"\"$toJson\"\"\"\n")
number++
} catch (e: Exception) {
println("error generating source ${it.second} ${e.printStackTrace()}")
}
@ -104,7 +102,6 @@ class Generator {
val writer = PrintWriter(relativePath)
writer.write(buffer.toString())
writer.close()
} else {
val writer = PrintWriter(relativePathTest)
writer.write(buffer.toString())
@ -158,14 +155,13 @@ class Generator {
array.add(map)
}
return array
}
private fun getItemUrl(document: Document): String {
return document.toString().substringAfter("showURL = \"").substringAfter("showURL=\"").substringBefore("/SELECTION\";")
//Some websites like mangasyuri use javascript minifiers, and thus "showURL = " becomes "showURL="https://mangasyuri.net/manga/SELECTION""
//(without spaces). Hence the double substringAfter.
// Some websites like mangasyuri use javascript minifiers, and thus "showURL = " becomes "showURL="https://mangasyuri.net/manga/SELECTION""
// (without spaces). Hence the double substringAfter.
}
private fun supportsLatest(third: String): Boolean {
@ -190,7 +186,6 @@ class Generator {
return array
}
@Throws(Exception::class)
private fun getOkHttpClient(): OkHttpClient {
val trustAllCerts = arrayOf<TrustManager>(object : X509TrustManager {
@ -227,7 +222,6 @@ class Generator {
.build()
}
companion object {
const val DRY_RUN = false
val sources = listOf(
@ -239,7 +233,7 @@ class Generator {
Triple("en", "White Cloud Pavilion", "https://www.whitecloudpavilion.com/manga/free"),
Triple("fr", "Scan FR", "https://www.scan-fr.co"),
Triple("fr", "Scan VF", "https://www.scan-vf.net"),
Triple("fr", "Scan OP","https://scan-op.com"),
Triple("fr", "Scan OP", "https://scan-op.com"),
Triple("id", "Komikid", "https://www.komikid.com"),
Triple("pl", "ToraScans", "http://torascans.pl"),
Triple("pt", "Comic Space", "https://www.comicspace.com.br"),
@ -256,70 +250,69 @@ class Generator {
Triple("bg", "Utsukushii", "https://manga.utsukushii-bg.com"),
Triple("es", "Universo Yuri", "https://universoyuri.com"),
Triple("pl", "Phoenix-Scans", "https://phoenix-scans.pl"),
Triple("ru", "Japit Comics","https://j-comics.ru"),
Triple("ru", "Japit Comics", "https://j-comics.ru"),
Triple("tr", "Puzzmos", "https://puzzmos.com"),
Triple("fr", "Scan-1", "https://www.scan-1.com"),
Triple("fr", "Lelscan-VF", "https://www.lelscan-vf.com"),
//NOTE: THIS SOURCE CONTAINS A CUSTOM LANGUAGE SYSTEM (which will be ignored)!
// NOTE: THIS SOURCE CONTAINS A CUSTOM LANGUAGE SYSTEM (which will be ignored)!
Triple("other", "HentaiShark", "https://www.hentaishark.com"))
//Changed CMS
//Triple("en", "MangaTreat Scans", "http://www.mangatreat.com"),
//Triple("en", "Chibi Manga Reader", "https://www.cmreader.info"),
//Triple("tr", "Epikmanga", "https://www.epikmanga.com"),
//Triple("en", "Hatigarm Scans", "https://hatigarmscans.net"),
//Went offline
//Triple("ru", "Anigai clan", "http://anigai.ru"),
//Triple("en", "ZXComic", "http://zxcomic.com"),
//Triple("es", "SOS Scanlation", "https://sosscanlation.com"),
//Triple("es", "MangaCasa", "https://mangacasa.com"))
//Triple("ja", "RAW MANGA READER", "https://rawmanga.site"),
//Triple("ar", "Manga FYI", "http://mangafyi.com/manga/arabic"),
//Triple("en", "MangaRoot", "http://mangaroot.com"),
//Triple("en", "MangaForLife", "http://manga4ever.com"),
//Triple("en", "Manga Spoil", "http://mangaspoil.com"),
//Triple("en", "MangaBlue", "http://mangablue.com"),
//Triple("en", "Manga Forest", "https://mangaforest.com"),
//Triple("en", "DManga", "http://dmanga.website"),
//Triple("en", "DB Manga", "http://dbmanga.com"),
//Triple("en", "Mangacox", "http://mangacox.com"),
//Triple("en", "GO Manhwa", "http://gomanhwa.xyz"),
//Triple("en", "KoManga", "https://komanga.net"),
//Triple("en", "Manganimecan", "http://manganimecan.com"),
//Triple("en", "Hentai2Manga", "http://hentai2manga.com"),
//Triple("en", "4 Manga", "http://4-manga.com"),
//Triple("en", "XYXX.INFO", "http://xyxx.info"),
//Triple("en", "Isekai Manga Reader", "https://isekaimanga.club"),
//Triple("fa", "TrinityReader", "http://trinityreader.pw"),
//Triple("fr", "Manga-LEL", "https://www.manga-lel.com"),
//Triple("fr", "Manga Etonnia", "https://www.etonnia.com"),
//Triple("fr", "ScanFR.com"), "http://scanfr.com"),
//Triple("fr", "Manga FYI", "http://mangafyi.com/manga/french"),
//Triple("fr", "scans-manga", "http://scans-manga.com"),
//Triple("fr", "Henka no Kaze", "http://henkanokazelel.esy.es/upload"),
//Triple("fr", "Tous Vos Scans", "http://www.tous-vos-scans.com"),
//Triple("id", "Manga Desu", "http://mangadesu.net"),
//Triple("id", "Komik Mangafire.ID", "http://go.mangafire.id"),
//Triple("id", "MangaOnline", "https://mangaonline.web.id"),
//Triple("id", "MangaNesia", "https://manganesia.com"),
//Triple("id", "MangaID", "https://mangaid.me"
//Triple("id", "Manga Seru", "http://www.mangaseru.top"
//Triple("id", "Manga FYI", "http://mangafyi.com/manga/indonesian"
//Triple("id", "Bacamangaku", "http://www.bacamangaku.com"),
//Triple("id", "Indo Manga Reader", "http://indomangareader.com"),
//Triple("it", "Kingdom Italia Reader", "http://kireader.altervista.org"),
//Triple("ja", "IchigoBook", "http://ichigobook.com"),
//Triple("ja", "Mangaraw Online", "http://mangaraw.online"
//Triple("ja", "Mangazuki RAWS", "https://raws.mangazuki.co"),
//Triple("ja", "MangaRAW", "https://www.mgraw.com"),
//Triple("ja", "マンガ/漫画 マガジン/雑誌 raw", "http://netabare-manga-raw.com"),
//Triple("ru", "NAKAMA", "http://nakama.ru"),
//Triple("tr", "MangAoi", "http://mangaoi.com"),
//Triple("tr", "ManhuaTR", "http://www.manhua-tr.com"),
// Changed CMS
// Triple("en", "MangaTreat Scans", "http://www.mangatreat.com"),
// Triple("en", "Chibi Manga Reader", "https://www.cmreader.info"),
// Triple("tr", "Epikmanga", "https://www.epikmanga.com"),
// Triple("en", "Hatigarm Scans", "https://hatigarmscans.net"),
// Went offline
// Triple("ru", "Anigai clan", "http://anigai.ru"),
// Triple("en", "ZXComic", "http://zxcomic.com"),
// Triple("es", "SOS Scanlation", "https://sosscanlation.com"),
// Triple("es", "MangaCasa", "https://mangacasa.com"))
// Triple("ja", "RAW MANGA READER", "https://rawmanga.site"),
// Triple("ar", "Manga FYI", "http://mangafyi.com/manga/arabic"),
// Triple("en", "MangaRoot", "http://mangaroot.com"),
// Triple("en", "MangaForLife", "http://manga4ever.com"),
// Triple("en", "Manga Spoil", "http://mangaspoil.com"),
// Triple("en", "MangaBlue", "http://mangablue.com"),
// Triple("en", "Manga Forest", "https://mangaforest.com"),
// Triple("en", "DManga", "http://dmanga.website"),
// Triple("en", "DB Manga", "http://dbmanga.com"),
// Triple("en", "Mangacox", "http://mangacox.com"),
// Triple("en", "GO Manhwa", "http://gomanhwa.xyz"),
// Triple("en", "KoManga", "https://komanga.net"),
// Triple("en", "Manganimecan", "http://manganimecan.com"),
// Triple("en", "Hentai2Manga", "http://hentai2manga.com"),
// Triple("en", "4 Manga", "http://4-manga.com"),
// Triple("en", "XYXX.INFO", "http://xyxx.info"),
// Triple("en", "Isekai Manga Reader", "https://isekaimanga.club"),
// Triple("fa", "TrinityReader", "http://trinityreader.pw"),
// Triple("fr", "Manga-LEL", "https://www.manga-lel.com"),
// Triple("fr", "Manga Etonnia", "https://www.etonnia.com"),
// Triple("fr", "ScanFR.com"), "http://scanfr.com"),
// Triple("fr", "Manga FYI", "http://mangafyi.com/manga/french"),
// Triple("fr", "scans-manga", "http://scans-manga.com"),
// Triple("fr", "Henka no Kaze", "http://henkanokazelel.esy.es/upload"),
// Triple("fr", "Tous Vos Scans", "http://www.tous-vos-scans.com"),
// Triple("id", "Manga Desu", "http://mangadesu.net"),
// Triple("id", "Komik Mangafire.ID", "http://go.mangafire.id"),
// Triple("id", "MangaOnline", "https://mangaonline.web.id"),
// Triple("id", "MangaNesia", "https://manganesia.com"),
// Triple("id", "MangaID", "https://mangaid.me"
// Triple("id", "Manga Seru", "http://www.mangaseru.top"
// Triple("id", "Manga FYI", "http://mangafyi.com/manga/indonesian"
// Triple("id", "Bacamangaku", "http://www.bacamangaku.com"),
// Triple("id", "Indo Manga Reader", "http://indomangareader.com"),
// Triple("it", "Kingdom Italia Reader", "http://kireader.altervista.org"),
// Triple("ja", "IchigoBook", "http://ichigobook.com"),
// Triple("ja", "Mangaraw Online", "http://mangaraw.online"
// Triple("ja", "Mangazuki RAWS", "https://raws.mangazuki.co"),
// Triple("ja", "MangaRAW", "https://www.mgraw.com"),
// Triple("ja", "マンガ/漫画 マガジン/雑誌 raw", "http://netabare-manga-raw.com"),
// Triple("ru", "NAKAMA", "http://nakama.ru"),
// Triple("tr", "MangAoi", "http://mangaoi.com"),
// Triple("tr", "ManhuaTR", "http://www.manhua-tr.com"),
val relativePath = System.getProperty("user.dir") + "/src/all/mmrcms/src/eu/kanade/tachiyomi/extension/all/mmrcms/GeneratedSources.kt"
val relativePathTest = System.getProperty("user.dir") + "/src/all/mmrcms/TestGeneratedSources.kt"
@JvmStatic
fun main(args: Array<String>) {
Generator().generate()

View File

@ -16,22 +16,24 @@ import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Element
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.Locale
import java.util.concurrent.TimeUnit
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Element
class MyMangaReaderCMSSource(override val lang: String,
override val name: String,
override val baseUrl: String,
override val supportsLatest: Boolean,
private val itemUrl: String,
private val categoryMappings: List<Pair<String, String>>,
private val tagMappings: List<Pair<String, String>>?) : HttpSource() {
class MyMangaReaderCMSSource(
override val lang: String,
override val name: String,
override val baseUrl: String,
override val supportsLatest: Boolean,
private val itemUrl: String,
private val categoryMappings: List<Pair<String, String>>,
private val tagMappings: List<Pair<String, String>>?
) : HttpSource() {
private val jsonParser = JsonParser()
private val itemUrlPath = Uri.parse(itemUrl).pathSegments.firstOrNull()
private val parsedBaseUrl = Uri.parse(baseUrl)
@ -49,7 +51,7 @@ class MyMangaReaderCMSSource(override val lang: String,
}
}
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
//Query overrides everything
// Query overrides everything
val url: Uri.Builder
if (query.isNotBlank()) {
url = Uri.parse("$baseUrl/search")!!.buildUpon()
@ -67,7 +69,7 @@ class MyMangaReaderCMSSource(override val lang: String,
override fun popularMangaParse(response: Response) = internalMangaParse(response)
override fun searchMangaParse(response: Response): MangasPage {
return if (response.request().url().queryParameter("query")?.isNotBlank() == true) {
//If a search query was specified, use search instead!
// If a search query was specified, use search instead!
MangasPage(jsonParser
.parse(response.body()!!.string())["suggestions"].array
.map {
@ -120,7 +122,7 @@ class MyMangaReaderCMSSource(override val lang: String,
if (urlElement.size == 0) {
url = getUrlWithoutBaseUrl(it.select("a").attr("href"))
title = it.select("div.caption").text()
it.select("div.caption div").text().let { if (it.isNotEmpty()) title = title.substringBefore(it)} // To clean submanga's titles without breaking hentaishark's
it.select("div.caption div").text().let { if (it.isNotEmpty()) title = title.substringBefore(it) } // To clean submanga's titles without breaking hentaishark's
} else {
url = getUrlWithoutBaseUrl(urlElement.attr("href"))
title = urlElement.text().trim()
@ -175,19 +177,19 @@ class MyMangaReaderCMSSource(override val lang: String,
thumbnail_url = coverGuess(document.select(".row [class^=img-responsive]").firstOrNull()?.attr("abs:src"), document.location())
description = document.select(".row .well p").text().trim()
val detailAuthor = setOf("author(s)","autor(es)","auteur(s)","著作","yazar(lar)","mangaka(lar)","pengarang/penulis","pengarang","penulis","autor","المؤلف","перевод", "autor/autorzy")
val detailArtist = setOf("artist(s)","artiste(s)","sanatçi(lar)","artista(s)","artist(s)/ilustrator","الرسام","seniman", "rysownik/rysownicy")
val detailGenre = setOf("categories","categorías","catégories","ジャンル","kategoriler","categorias","kategorie","التصنيفات","жанр","kategori", "tagi")
val detailStatus = setOf("status","statut","estado","状態","durum","الحالة","статус")
val detailStatusComplete = setOf("complete","مكتملة","complet","completo", "zakończone")
val detailStatusOngoing = setOf("ongoing","مستمرة","en cours","em lançamento", "prace w toku")
val detailDescription = setOf("description","resumen")
val detailAuthor = setOf("author(s)", "autor(es)", "auteur(s)", "著作", "yazar(lar)", "mangaka(lar)", "pengarang/penulis", "pengarang", "penulis", "autor", "المؤلف", "перевод", "autor/autorzy")
val detailArtist = setOf("artist(s)", "artiste(s)", "sanatçi(lar)", "artista(s)", "artist(s)/ilustrator", "الرسام", "seniman", "rysownik/rysownicy")
val detailGenre = setOf("categories", "categorías", "catégories", "ジャンル", "kategoriler", "categorias", "kategorie", "التصنيفات", "жанр", "kategori", "tagi")
val detailStatus = setOf("status", "statut", "estado", "状態", "durum", "الحالة", "статус")
val detailStatusComplete = setOf("complete", "مكتملة", "complet", "completo", "zakończone")
val detailStatusOngoing = setOf("ongoing", "مستمرة", "en cours", "em lançamento", "prace w toku")
val detailDescription = setOf("description", "resumen")
for (element in document.select(".row .dl-horizontal dt")) {
when (element.text().trim().toLowerCase()) {
in detailAuthor -> author = element.nextElementSibling().text()
in detailArtist -> artist = element.nextElementSibling().text()
in detailGenre-> genre = element.nextElementSibling().select("a").joinToString {
in detailGenre -> genre = element.nextElementSibling().select("a").joinToString {
it.text().trim()
}
in detailStatus -> status = when (element.nextElementSibling().text().trim().toLowerCase()) {
@ -231,7 +233,7 @@ class MyMangaReaderCMSSource(override val lang: String,
* Returns the Jsoup selector that returns a list of [Element] corresponding to each chapter.
*/
private fun chapterListSelector() = "ul[class^=chapters] > li:not(.btn), table.table tr"
//Some websites add characters after "chapters" thus the need of checking classes that starts with "chapters"
// Some websites add characters after "chapters" thus the need of checking classes that starts with "chapters"
/**
* Returns a chapter from the given element.
@ -243,7 +245,7 @@ class MyMangaReaderCMSSource(override val lang: String,
try {
val titleWrapper = element.select("[class^=chapter-title-rtl]").first()
//Some websites add characters after "..-rtl" thus the need of checking classes that starts with that
// Some websites add characters after "..-rtl" thus the need of checking classes that starts with that
val url = titleWrapper.getElementsByTag("a").attr("href")
// Ensure chapter actually links to a manga
@ -278,7 +280,7 @@ class MyMangaReaderCMSSource(override val lang: String,
return null
}
private fun parseDate (dateText: String): Long {
private fun parseDate(dateText: String): Long {
return try {
DATE_FORMAT.parse(dateText).time
} catch (e: ParseException) {
@ -299,7 +301,7 @@ class MyMangaReaderCMSSource(override val lang: String,
// Mangas.pw encodes some of their urls, decode them
if (url.contains("mangas.pw") && url.contains("img.php")) {
url = url.substringAfter("i=")
repeat (5) {
repeat(5) {
url = Base64.decode(url, Base64.DEFAULT).toString(Charsets.UTF_8).substringBefore("=")
}
}
@ -348,10 +350,14 @@ class MyMangaReaderCMSSource(override val lang: String,
* If an entry is selected it is appended as a query parameter onto the end of the URI.
* If `firstIsUnspecified` is set to true, if the first entry is selected, nothing will be appended on the the URI.
*/
//vals: <name, display>
open class UriSelectFilter(displayName: String, private val uriParam: String, private val vals: Array<Pair<String, String>>,
private val firstIsUnspecified: Boolean = true,
defaultValue: Int = 0) :
// vals: <name, display>
open class UriSelectFilter(
displayName: String,
private val uriParam: String,
private val vals: Array<Pair<String, String>>,
private val firstIsUnspecified: Boolean = true,
defaultValue: Int = 0
) :
Filter.Select<String>(displayName, vals.map { it.second }.toTypedArray(), defaultValue), UriFilter {
override fun addToUri(uri: Uri.Builder) {
if (state != 0 || !firstIsUnspecified)

View File

@ -86,5 +86,3 @@ class MyMangaReaderCMSSources : SourceFactory {
it["id"].string to it["name"].string
}
}