-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathCustomMonthAnimeModel.kt
More file actions
78 lines (76 loc) · 3.17 KB
/
CustomMonthAnimeModel.kt
File metadata and controls
78 lines (76 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.skyd.imomoe.model.impls.custom
import com.skyd.imomoe.bean.AnimeCoverBean
import com.skyd.imomoe.bean.PageNumberBean
import com.skyd.imomoe.config.Api
import com.skyd.imomoe.model.util.JsoupUtil
import com.skyd.imomoe.model.interfaces.IMonthAnimeModel
import org.jsoup.select.Elements
class CustomMonthAnimeModel : IMonthAnimeModel {
override suspend fun getMonthAnimeData(
partUrl: String
): Pair<ArrayList<AnimeCoverBean>, PageNumberBean?> {
val monthAnimeList: ArrayList<AnimeCoverBean> = ArrayList()
val url = Api.MAIN_URL + partUrl
var pageNumberBean: PageNumberBean? = null
val document = JsoupUtil.getDocument(url)
val area: Elements = document.getElementsByClass("area")
for (i in area.indices) {
val elements: Elements = area[i].children()
for (j in elements.indices) {
when (elements[j].className()) {
"img", "imgs" -> {
monthAnimeList.addAll(
CustomParseHtmlUtil.parseImg(
elements[j],
url
)
)
}
"fire l" -> { //右侧前半tab内容
val firsLChildren = elements[j].children()
for (k in firsLChildren.indices) {
when (firsLChildren[k].className()) {
"lpic" -> {
monthAnimeList.addAll(
CustomParseHtmlUtil.parseLpic(
firsLChildren[k],
url
)
)
}
"pages" -> {
pageNumberBean =
CustomParseHtmlUtil.parseNextPages(
firsLChildren[k]
)
}
}
}
}
"dnews" -> { //右侧后半tab内容,cover4
monthAnimeList.addAll(
CustomParseHtmlUtil.parseDnews(
elements[j],
url
)
)
}
"topli" -> { //右侧后半tab内容,cover5
monthAnimeList.addAll(
CustomParseHtmlUtil.parseTopli(
elements[j]
)
)
}
"pages" -> {
pageNumberBean =
CustomParseHtmlUtil.parseNextPages(
elements[j]
)
}
}
}
}
return Pair(monthAnimeList, pageNumberBean)
}
}