Skip to content

Commit 70c9a60

Browse files
committed
Copymangas: 增加排行榜、最新上架 & 修复题材筛选
* 增加`CHANGELOG.md`
1 parent 2dacdb7 commit 70c9a60

File tree

5 files changed

+97
-10
lines changed

5 files changed

+97
-10
lines changed

src/zh/copymangas/CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## 1.4.53
2+
3+
### 功能
4+
5+
* 筛选中增加排行榜、最新上架
6+
7+
### 修复
8+
9+
* 修复筛选中“题材”获取失败的问题
10+
11+
## 1.4.52
12+
13+
### 功能
14+
15+
* 支持章末吐槽:使用热辣漫画时会显示拷贝的吐槽(因为热辣没有吐槽功能)
16+
17+
## 1.4.51
18+
19+
### 功能
20+
21+
* 支持热辣漫画:可在设置里直接切换热辣漫画/拷贝漫画,切换后建议重启应用!(立即生效,书架里的漫画也不需要迁移,但是插件的设置务必重启后再修改!)
22+
23+

src/zh/copymangas/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ext {
22
extName = 'CopyMangas'
33
extClass = '.CopyMangas'
4-
extVersionCode = 52
4+
extVersionCode = 53
55
}
66

77
apply from: "$rootDir/common.gradle"

src/zh/copymangas/src/eu/kanade/tachiyomi/extension/zh/copymangas/CopyMangas.kt

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import eu.kanade.tachiyomi.source.model.Page
2121
import eu.kanade.tachiyomi.source.model.SChapter
2222
import eu.kanade.tachiyomi.source.model.SManga
2323
import eu.kanade.tachiyomi.source.online.HttpSource
24+
import keiyoushi.utils.firstInstanceOrNull
2425
import keiyoushi.utils.getPreferencesLazy
2526
import keiyoushi.utils.parseAs
2627
import kotlinx.serialization.json.Json
@@ -256,27 +257,54 @@ class CopyMangas : HttpSource(), ConfigurableSource {
256257
val builder = getUrl("api").toHttpUrl().newBuilder()
257258
.addQueryParameter("limit", "$PAGE_SIZE")
258259
.addQueryParameter("offset", "$offset")
260+
259261
if (query.isNotBlank()) {
260262
builder.addPathSegments("api/v3/search/comic")
261263
.addQueryParameter("q", query)
262-
filters.filterIsInstance<SearchFilter>().firstOrNull()?.addQuery(builder)
264+
filters.firstInstanceOrNull<SearchFilter>()?.addQuery(builder)
263265
// builder.addQueryParameter("q_type", "")
264266
headersBuilder.setToken(preferences.getString(if (useHotmanga) HOTMANGA_TOKEN_PREF else TOKEN_PREF, "")!!)
265267
} else {
266-
builder.addPathSegments("api/v3/comics")
267-
filters.filterIsInstance<CopyMangaFilter>().forEach {
268-
if (it !is SearchFilter) {
269-
it.addQuery(builder)
268+
val ranking = filters.firstInstanceOrNull<RankingGroup>()
269+
if (ranking != null && (ranking.state[0] as TypeFilter).state != 0) {
270+
val rankType = (ranking.state[0] as TypeFilter).state
271+
if (rankType != 1) {
272+
// 排行榜
273+
builder.addPathSegments("api/v3/ranks")
274+
.addQueryParameter("type", "1")
275+
ranking.state.filterIsInstance<CopyMangaFilter>().forEach {
276+
it.addQuery(builder)
277+
}
278+
} else {
279+
// 最新上架
280+
builder.addPathSegments("api/v3/update/newest")
281+
}
282+
} else {
283+
// 分类/发现
284+
builder.addPathSegments("api/v3/comics")
285+
filters.filterIsInstance<CopyMangaFilter>().forEach {
286+
if (it !is SearchFilter) {
287+
it.addQuery(builder)
288+
}
270289
}
271290
}
272291
}
273292
return Request.Builder().url(builder.build()).headers(headersBuilder.build()).build()
274293
}
275294

276295
override fun searchMangaParse(response: Response): MangasPage {
277-
val page = response.parseAs<ResultDto<ListDto<MangaDto>>>().results
296+
val page = if (response.request.url.pathSegments.last() != "comics") {
297+
response.parseAs<ResultDto<ListDto<RanksListWrapperDto>>>().results
298+
} else {
299+
response.parseAs<ResultDto<ListDto<MangaDto>>>().results
300+
}
301+
302+
val mangas = page.list.map {
303+
if (it is RanksListWrapperDto) it.comic.toSManga() else (it as MangaDto).toSManga()
304+
}
278305
val hasNextPage = page.offset + page.limit < page.total
279-
return MangasPage(page.list.map { it.toSManga() }, hasNextPage)
306+
307+
return MangasPage(mangas, hasNextPage)
280308
}
281309

282310
override fun getMangaUrl(manga: SManga) = getUrl("web") + manga.url
@@ -410,6 +438,8 @@ class CopyMangas : HttpSource(), ConfigurableSource {
410438
return FilterList(
411439
SearchFilter(),
412440
Filter.Separator(),
441+
RankingGroup(),
442+
Filter.Separator(),
413443
Filter.Header("分类(搜索文本时无效)"),
414444
genreFilter,
415445
TopFilter(),
@@ -430,7 +460,7 @@ class CopyMangas : HttpSource(), ConfigurableSource {
430460
apiHeaders,
431461
),
432462
).execute()
433-
val list = response.parseAs<ListDto<KeywordDto>>().list.sortedBy { it.name }
463+
val list = response.parseAs<ResultDto<ListDto<KeywordDto>>>().results.list.filter { it.count != null && it.count != 0 }.sortedBy { it.name }
434464
val result = ArrayList<Param>(list.size + 1).apply { add(Param("全部", "")) }
435465
genres = list.mapTo(result) { it.toParam() }.toTypedArray()
436466
} catch (e: Exception) {

src/zh/copymangas/src/eu/kanade/tachiyomi/extension/zh/copymangas/CopyMangasDto.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class ChapterDto(
6565
}
6666

6767
@Serializable
68-
class KeywordDto(val name: String, val path_word: String) {
68+
class KeywordDto(val name: String, val path_word: String, val count: Int?) {
6969
fun toParam() = Param(ChineseUtils.toSimplified(name), path_word)
7070
}
7171

@@ -89,6 +89,9 @@ class UrlDto(val url: String)
8989
@Serializable
9090
class ChapterPageListWrapperDto(val chapter: ChapterPageListDto)
9191

92+
@Serializable
93+
class RanksListWrapperDto(val comic: MangaDto)
94+
9295
@Serializable
9396
class ListDto<T>(
9497
val total: Int,

src/zh/copymangas/src/eu/kanade/tachiyomi/extension/zh/copymangas/CopyMangasFilters.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,34 @@ private val SORT_VALUES = arrayOf(
4444
Param("更新时间", "-datetime_updated"),
4545
Param("更新时间(逆序)", "datetime_updated"),
4646
)
47+
48+
class RankingGroup : Filter.Group<Filter<*>>(
49+
"排行榜(搜索文本时无效)",
50+
listOf<Filter<*>>(
51+
TypeFilter(),
52+
DateFilter(),
53+
),
54+
) {
55+
private class DateFilter : CopyMangaFilter(
56+
"时间",
57+
"date_type",
58+
arrayOf(
59+
Param("今日", "day"),
60+
Param("近七天", "week"),
61+
Param("近三十天", "month"),
62+
Param("总榜单", "total"),
63+
),
64+
)
65+
}
66+
67+
class TypeFilter : CopyMangaFilter(
68+
"类型",
69+
"audience_type",
70+
arrayOf(
71+
Param("不查看排行榜", ""),
72+
Param("最新上架", ""),
73+
Param("男频", "male"),
74+
Param("女频", "female"),
75+
76+
),
77+
)

0 commit comments

Comments
 (0)