-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MeituaTop: Re-add extension with updated domain (#5556)
* Add files via upload * Update src/all/meituatop/src/eu/kanade/tachiyomi/extension/all/meituatop/MeituaTop.kt --------- Co-authored-by: AwkwardPeak7 <[email protected]>
- Loading branch information
1 parent
6571ff7
commit a289cf0
Showing
7 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ext { | ||
extName = 'Meitua.top' | ||
extClass = '.MeituaTop' | ||
extVersionCode = 7 | ||
isNsfw = true | ||
} | ||
|
||
apply from: "$rootDir/common.gradle" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
111 changes: 111 additions & 0 deletions
111
src/all/meituatop/src/eu/kanade/tachiyomi/extension/all/meituatop/MeituaTop.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package eu.kanade.tachiyomi.extension.all.meituatop | ||
|
||
import eu.kanade.tachiyomi.network.GET | ||
import eu.kanade.tachiyomi.source.model.Filter | ||
import eu.kanade.tachiyomi.source.model.FilterList | ||
import eu.kanade.tachiyomi.source.model.MangasPage | ||
import eu.kanade.tachiyomi.source.model.Page | ||
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.HttpUrl.Companion.toHttpUrl | ||
import okhttp3.Request | ||
import okhttp3.Response | ||
import org.jsoup.select.Evaluator | ||
import rx.Observable | ||
import java.text.SimpleDateFormat | ||
import java.util.Locale | ||
|
||
// Uses MACCMS http://www.maccms.la/ | ||
class MeituaTop : HttpSource() { | ||
override val name = "Meitua.top" | ||
override val lang = "all" | ||
override val supportsLatest = false | ||
|
||
override val baseUrl = "https://88188.meitu.lol" | ||
|
||
override fun popularMangaRequest(page: Int) = GET("$baseUrl/arttype/0b-$page.html", headers) | ||
|
||
override fun popularMangaParse(response: Response): MangasPage { | ||
val document = response.asJsoup() | ||
val mangas = document.selectFirst(Evaluator.Class("thumbnail-group"))!!.children().map { | ||
SManga.create().apply { | ||
url = it.selectFirst(Evaluator.Tag("a"))!!.attr("href") | ||
val image = it.selectFirst(Evaluator.Tag("img"))!! | ||
title = image.attr("alt") | ||
thumbnail_url = image.attr("src") | ||
val info = it.selectFirst(Evaluator.Tag("p"))!!.ownText().split(" - ") | ||
genre = info[0] | ||
description = info[1] | ||
status = SManga.COMPLETED | ||
initialized = true | ||
} | ||
} | ||
val pageLinks = document.select(Evaluator.Class("page_link")) | ||
if (pageLinks.isEmpty()) return MangasPage(mangas, false) | ||
val lastPage = pageLinks[3].attr("href") | ||
val hasNextPage = document.location().pageNumber() != lastPage.pageNumber() | ||
return MangasPage(mangas, hasNextPage) | ||
} | ||
|
||
override fun latestUpdatesRequest(page: Int) = throw UnsupportedOperationException() | ||
|
||
override fun latestUpdatesParse(response: Response) = throw UnsupportedOperationException() | ||
|
||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { | ||
if (query.isNotEmpty()) { | ||
val url = "$baseUrl/artsearch/-------.html".toHttpUrl().newBuilder() | ||
.addQueryParameter("wd", query) | ||
.addQueryParameter("page", page.toString()) | ||
.toString() | ||
return GET(url, headers) | ||
} | ||
|
||
val filter = filters.filterIsInstance<RegionFilter>().firstOrNull() ?: return popularMangaRequest(page) | ||
return GET("$baseUrl/arttype/${21 + filter.state}b-$page.html", headers) | ||
} | ||
|
||
override fun searchMangaParse(response: Response) = popularMangaParse(response) | ||
|
||
override fun fetchMangaDetails(manga: SManga): Observable<SManga> = Observable.just(manga) | ||
|
||
override fun mangaDetailsParse(response: Response) = throw UnsupportedOperationException() | ||
|
||
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> { | ||
val chapter = SChapter.create().apply { | ||
url = manga.url | ||
name = "Gallery" | ||
date_upload = dateFormat.parse(manga.description!!)!!.time | ||
chapter_number = -2f | ||
} | ||
return Observable.just(listOf(chapter)) | ||
} | ||
|
||
override fun chapterListParse(response: Response) = throw UnsupportedOperationException() | ||
|
||
override fun pageListParse(response: Response): List<Page> { | ||
val document = response.asJsoup() | ||
val images = document.selectFirst(Evaluator.Class("ttnr"))!!.select(Evaluator.Tag("img")) | ||
.map { it.attr("src") }.distinct() | ||
return images.mapIndexed { index, imageUrl -> Page(index, imageUrl = imageUrl) } | ||
} | ||
|
||
override fun imageUrlParse(response: Response) = throw UnsupportedOperationException() | ||
|
||
override fun getFilterList() = FilterList( | ||
Filter.Header("Category (ignored for text search)"), | ||
RegionFilter(), | ||
) | ||
|
||
private class RegionFilter : Filter.Select<String>( | ||
"Region", | ||
arrayOf("All", "国产美女", "韩国美女", "台湾美女", "日本美女", "欧美美女", "泰国美女"), | ||
) | ||
|
||
private fun String.pageNumber() = numberRegex.findAll(this).last().value.toInt() | ||
|
||
private val numberRegex by lazy { Regex("""\d+""") } | ||
|
||
private val dateFormat by lazy { SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH) } | ||
} |