parent
							
								
									18206ed744
								
							
						
					
					
						commit
						b3e0ef430a
					
				@ -5,7 +5,7 @@ ext {
 | 
			
		||||
    appName = 'Tachiyomi: MangaDex'
 | 
			
		||||
    pkgNameSuffix = 'all.mangadex'
 | 
			
		||||
    extClass = '.MangadexFactory'
 | 
			
		||||
    extVersionCode = 85
 | 
			
		||||
    extVersionCode = 86
 | 
			
		||||
    libVersion = '1.2'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -33,6 +33,10 @@ abstract class Mangadex(
 | 
			
		||||
    private val internalLang: String
 | 
			
		||||
) : ConfigurableSource, ParsedHttpSource() {
 | 
			
		||||
 | 
			
		||||
    init {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override val name = "MangaDex"
 | 
			
		||||
 | 
			
		||||
    override val baseUrl = "https://mangadex.org"
 | 
			
		||||
@ -45,6 +49,10 @@ abstract class Mangadex(
 | 
			
		||||
        Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private val mangadexDescription : MangadexDescription by lazy {
 | 
			
		||||
        MangadexDescription(internalLang)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private val rateLimitInterceptor = RateLimitInterceptor(4)
 | 
			
		||||
 | 
			
		||||
    override val client: OkHttpClient = network.client.newBuilder()
 | 
			
		||||
@ -381,7 +389,7 @@ abstract class Mangadex(
 | 
			
		||||
        val chapterJson = json.getAsJsonObject("chapter")
 | 
			
		||||
        manga.title = cleanString(mangaJson.get("title").string)
 | 
			
		||||
        manga.thumbnail_url = cdnUrl + mangaJson.get("cover_url").string
 | 
			
		||||
        manga.description = cleanString(mangaJson.get("description").string)
 | 
			
		||||
        manga.description = cleanString(mangadexDescription.clean(internalLang, mangaJson.get("description").string))
 | 
			
		||||
        manga.author = mangaJson.get("author").string
 | 
			
		||||
        manga.artist = mangaJson.get("artist").string
 | 
			
		||||
        val status = mangaJson.get("status").int
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,54 @@
 | 
			
		||||
package eu.kanade.tachiyomi.extension.all.mangadex
 | 
			
		||||
 | 
			
		||||
class MangadexDescription(private val internalLang: String) {
 | 
			
		||||
 | 
			
		||||
    private val listOfLangs = when (internalLang) {
 | 
			
		||||
        "ru" -> RUSSIAN
 | 
			
		||||
        "de" -> GERMAN
 | 
			
		||||
        "it" -> ITALIAN
 | 
			
		||||
        in "es", "mx" -> SPANISH
 | 
			
		||||
        in "br", "pt" -> PORTUGESE
 | 
			
		||||
        "tr" -> TURKISH
 | 
			
		||||
        "fr" -> FRENCH
 | 
			
		||||
        "sa" -> ARABIC
 | 
			
		||||
        else -> emptyList()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun clean(internalLang: String, description: String): String {
 | 
			
		||||
        val langList = ALL_LANGS.toMutableList()
 | 
			
		||||
 | 
			
		||||
        //remove any languages before the ones provided in the langTextToCheck, if no matches or empty
 | 
			
		||||
        // just uses the original description, also removes the potential lang from all lang list
 | 
			
		||||
        var newDescription = description;
 | 
			
		||||
        listOfLangs.forEach { it ->
 | 
			
		||||
            newDescription = newDescription.substringAfter(it)
 | 
			
		||||
            langList.remove(it)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // remove any possible languages that remain to get the new description
 | 
			
		||||
        langList.forEach { it -> newDescription = newDescription.substringBefore(it) }
 | 
			
		||||
        return newDescription
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    companion object {
 | 
			
		||||
        val ARABIC = listOf("[b][u]Arabic / العربية[/u][/b]")
 | 
			
		||||
        val FRENCH = listOf(
 | 
			
		||||
            "French - Français:",
 | 
			
		||||
            "[b][u]French[/u][/b]",
 | 
			
		||||
            "[b][u]French / Français[/u][/b]"
 | 
			
		||||
        )
 | 
			
		||||
        val GERMAN = listOf("[b][u]German / Deutsch[/u][/b]", "German/Deutsch:")
 | 
			
		||||
        val ITALIAN = listOf("[b][u]Italian / Italiano[/u][/b]")
 | 
			
		||||
        val PORTUGESE = listOf(
 | 
			
		||||
            "[b][u]Portuguese (BR) / Português (BR)[/u][/b]",
 | 
			
		||||
            "[b][u]Português / Portuguese[/u][/b]",
 | 
			
		||||
            "[b][u]Portuguese / Portugu[/u][/b]"
 | 
			
		||||
        )
 | 
			
		||||
        val RUSSIAN = listOf("[b][u]Russian / Русский[/u][/b]")
 | 
			
		||||
        val SPANISH = listOf("[b][u]Español / Spanish:[/u][/b]")
 | 
			
		||||
        val TURKISH = listOf("[b][u]Turkish / Türkçe[/u][/b]")
 | 
			
		||||
 | 
			
		||||
        val ALL_LANGS =
 | 
			
		||||
            listOf(ARABIC, FRENCH, GERMAN, ITALIAN, PORTUGESE, RUSSIAN, SPANISH, TURKISH).flatten()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user