Team X - new extension (#1856)

This commit is contained in:
Mike 2019-12-09 18:42:07 -05:00 committed by arkon
parent a48d4b1e76
commit a6ed48f4f1
8 changed files with 141 additions and 0 deletions

12
src/ar/teamx/build.gradle Normal file
View File

@ -0,0 +1,12 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
ext {
appName = 'Tachiyomi: Team X'
pkgNameSuffix = 'ar.teamx'
extClass = '.TeamX'
extVersionCode = 1
libVersion = '1.2'
}
apply from: "$rootDir/common.gradle"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -0,0 +1,129 @@
package eu.kanade.tachiyomi.extension.ar.teamx
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
class TeamX : ParsedHttpSource() {
override val name = "Team X"
override val baseUrl = "https://team1x1.com"
override val lang = "ar"
override val supportsLatest = true
override val client: OkHttpClient = network.cloudflareClient
// Popular
override fun popularMangaRequest(page: Int): Request {
return GET("$baseUrl/manga/" + if (page > 1) "page/$page/" else "", headers)
}
override fun popularMangaSelector() = "div.last-post-manga"
private val titleSelector = "h3 a"
override fun popularMangaFromElement(element: Element): SManga {
return SManga.create().apply {
title = element.select(titleSelector).text()
setUrlWithoutDomain(element.select("a").first().attr("href"))
thumbnail_url = element.select("img").first().attr("abs:src")
}
}
override fun popularMangaNextPageSelector() = "i.fa-chevron-left"
// Latest
private val titlesAdded = mutableSetOf<String>()
override fun latestUpdatesRequest(page: Int): Request {
if (page == 1) titlesAdded.clear()
return GET("$baseUrl/فصول-المانجا/" + if (page > 1) "page/$page/" else "", headers)
}
override fun latestUpdatesParse(response: Response): MangasPage {
val document = response.asJsoup()
val mangas = document.select(latestUpdatesSelector())
.distinctBy { it.select(titleSelector).text() }.let { elements ->
if (titlesAdded.isNotEmpty()) elements.filter { it.select(titleSelector).text() !in titlesAdded } else elements
}
.map {
titlesAdded.add(it.select(titleSelector).text())
latestUpdatesFromElement(it)
}
return MangasPage(mangas, document.select(latestUpdatesNextPageSelector()).isNotEmpty())
}
override fun latestUpdatesSelector() = popularMangaSelector()
override fun latestUpdatesFromElement(element: Element): SManga = popularMangaFromElement(element)
override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
// Search
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
if (page == 1) titlesAdded.clear()
return GET("$baseUrl/" + (if (page > 1) "page/$page/" else "") + "?s=$query", headers)
}
override fun searchMangaParse(response: Response): MangasPage = latestUpdatesParse(response)
override fun searchMangaSelector() = popularMangaSelector()
override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element)
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
// Details
override fun mangaDetailsParse(document: Document): SManga {
return document.select("div.single-manga > div.container > div.row").let { info ->
SManga.create().apply {
title = info.select("div.col-md-9").text()
description = info.select("div.story p").text()
genre = info.select("div.genre a").joinToString { it.text() }
thumbnail_url = info.select("img").attr("abs:src")
}
}
}
// Chapters
// Filter out the fake chapters
override fun chapterListSelector() = "div.single-manga-chapter div.col-md-12 a[href^=$baseUrl]"
override fun chapterFromElement(element: Element): SChapter {
return SChapter.create().apply {
name = element.text()
setUrlWithoutDomain(element.attr("href"))
}
}
// Pages
override fun pageListParse(document: Document): List<Page> {
return document.select("div#translationPageall img").mapIndexed { i, img ->
Page(i, "", img.attr("abs:src"))
}
}
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used")
override fun getFilterList() = FilterList()
}