-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1109 from dragonx943/patch-2
Update domain
- Loading branch information
Showing
3 changed files
with
144 additions
and
1 deletion.
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
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/DocTruyen3Q.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,10 @@ | ||
package org.koitharu.kotatsu.parsers.site.wpcomics.vi | ||
|
||
import org.koitharu.kotatsu.parsers.MangaLoaderContext | ||
import org.koitharu.kotatsu.parsers.MangaSourceParser | ||
import org.koitharu.kotatsu.parsers.model.MangaParserSource | ||
import org.koitharu.kotatsu.parsers.site.wpcomics.WpComicsParser | ||
|
||
@MangaSourceParser("DOCTRUYEN3Q", "DocTruyen3Q", "vi") | ||
internal class DocTruyen3Q(context: MangaLoaderContext) : | ||
WpComicsParser(context, MangaParserSource.DOCTRUYEN3Q, "doctruyen3qto.pro", 36) |
133 changes: 133 additions & 0 deletions
133
src/main/kotlin/org/koitharu/kotatsu/parsers/site/wpcomics/vi/NetTruyenUU.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,133 @@ | ||
package org.koitharu.kotatsu.parsers.site.wpcomics.vi | ||
|
||
import androidx.collection.ArrayMap | ||
import kotlinx.coroutines.sync.withLock | ||
import org.koitharu.kotatsu.parsers.MangaLoaderContext | ||
import org.koitharu.kotatsu.parsers.MangaSourceParser | ||
import org.koitharu.kotatsu.parsers.exception.NotFoundException | ||
import org.koitharu.kotatsu.parsers.model.* | ||
import org.koitharu.kotatsu.parsers.site.wpcomics.WpComicsParser | ||
import org.koitharu.kotatsu.parsers.util.* | ||
import java.util.* | ||
|
||
@MangaSourceParser("NETTRUYENUU", "NetTruyenUU", "vi") | ||
internal class NetTruyenUU(context: MangaLoaderContext) : | ||
WpComicsParser(context, MangaParserSource.NETTRUYENUU, "nettruyenuu.com", 20) { | ||
|
||
override val listUrl = "/tim-kiem-nang-cao" | ||
|
||
override val availableSortOrders: Set<SortOrder> = EnumSet.of( | ||
SortOrder.UPDATED, | ||
SortOrder.POPULARITY, | ||
SortOrder.RATING, | ||
SortOrder.NEWEST, | ||
SortOrder.ALPHABETICAL, | ||
SortOrder.ALPHABETICAL_DESC, | ||
) | ||
|
||
override val filterCapabilities: MangaListFilterCapabilities | ||
get() = super.filterCapabilities.copy( | ||
isMultipleTagsSupported = true, | ||
isTagsExclusionSupported = true, | ||
) | ||
|
||
override suspend fun getFilterOptions() = super.getFilterOptions().copy( | ||
availableStates = EnumSet.of(MangaState.ONGOING, MangaState.FINISHED, MangaState.PAUSED, MangaState.ABANDONED), | ||
) | ||
|
||
override suspend fun getListPage(page: Int, order: SortOrder, filter: MangaListFilter): List<Manga> { | ||
val response = | ||
when { | ||
!filter.query.isNullOrEmpty() -> { | ||
val url = buildString { | ||
append("https://") | ||
append(domain) | ||
append("/search") | ||
append('/') | ||
append(page.toString()) | ||
append('/') | ||
append("?keyword=") | ||
append(filter.query.urlEncoded()) | ||
} | ||
|
||
val result = runCatchingCancellable { webClient.httpGet(url) } | ||
val exception = result.exceptionOrNull() | ||
if (exception is NotFoundException) { | ||
return emptyList() | ||
} | ||
result.getOrThrow() | ||
} | ||
|
||
else -> { | ||
val url = buildString { | ||
append("https://") | ||
append(domain) | ||
append(listUrl) | ||
|
||
append('/') | ||
append(page.toString()) | ||
append('/') | ||
|
||
val tagQuery = filter.tags.joinToString(",") { it.key } | ||
append("?genres=") | ||
append(tagQuery) | ||
|
||
val tagQueryExclude = filter.tagsExclude.joinToString(",") { it.key } | ||
append("¬Genres=") | ||
append(tagQueryExclude) | ||
|
||
append("&sex=All") | ||
|
||
filter.states.oneOrThrowIfMany()?.let { | ||
append("&status=") | ||
append( | ||
when (it) { | ||
MangaState.ONGOING -> "on-going" | ||
MangaState.FINISHED -> "completed" | ||
MangaState.PAUSED -> "on-hold" | ||
MangaState.ABANDONED -> "canceled" | ||
else -> "-1" | ||
}, | ||
) | ||
} | ||
|
||
append("&chapter_count=0") | ||
|
||
append("&sort=") | ||
append( | ||
when (order) { | ||
SortOrder.UPDATED -> "latest-updated" | ||
SortOrder.POPULARITY -> "views" | ||
SortOrder.NEWEST -> "new" | ||
SortOrder.RATING -> "score" | ||
SortOrder.ALPHABETICAL -> "az" | ||
SortOrder.ALPHABETICAL_DESC -> "za" | ||
else -> null | ||
}, | ||
) | ||
} | ||
|
||
webClient.httpGet(url) | ||
} | ||
} | ||
|
||
val tagMap = getOrCreateTagMap() | ||
return parseMangaList(response.parseHtml(), tagMap) | ||
} | ||
|
||
override suspend fun getOrCreateTagMap(): ArrayMap<String, MangaTag> = mutex.withLock { | ||
tagCache?.let { return@withLock it } | ||
val doc = webClient.httpGet(listUrl.toAbsoluteUrl(domain)).parseHtml() | ||
val tagItems = doc.select("div.genre-item") | ||
val result = ArrayMap<String, MangaTag>(tagItems.size) | ||
for (item in tagItems) { | ||
val title = item.text() | ||
val key = item.selectFirstOrThrow("span").attr("data-id") | ||
if (key.isNotEmpty() && title.isNotEmpty()) { | ||
result[title] = MangaTag(title = title, key = key, source = source) | ||
} | ||
} | ||
tagCache = result | ||
result | ||
} | ||
} |