1
+ package com.lagradost.quicknovel.providers
2
+
3
+ import com.lagradost.quicknovel.*
4
+ import com.lagradost.quicknovel.MainActivity.Companion.app
5
+ import org.jsoup.Jsoup
6
+
7
+ class EngNovelProvider : MainAPI () {
8
+ override val name = " EngNovel"
9
+ override val mainUrl = " https://engnovel.com"
10
+ override val hasMainPage = true
11
+
12
+ override val iconId = R .drawable.icon_engnovel
13
+
14
+ override val iconBackgroundId = R .color.wuxiaWorldOnlineColor
15
+
16
+ override val tags = listOf (
17
+ Pair (" All" , " " ),
18
+ Pair (" Action" ," action-novels" ),
19
+ Pair (" Adult" ," adult-novels" ),
20
+ Pair (" Adventure" ," adventure-novels" ),
21
+ Pair (" Comedy" ," comedy-novels" ),
22
+ Pair (" Drama" ," drama-novels" ),
23
+ Pair (" Eastern" ," eastern-novels" ),
24
+ Pair (" Ecchi" ," ecchi-novels" ),
25
+ Pair (" Fantasy" ," fantasy-novels" ),
26
+ Pair (" Game" ," game-novels" ),
27
+ Pair (" Gender Bender" ," gender-bender-novels" ),
28
+ Pair (" Harem" ," harem-novels" ),
29
+ Pair (" Historical" ," historical-novels" ),
30
+ Pair (" Horror" ," horror-novels" ),
31
+ Pair (" Josei" ," josei-novels" ),
32
+ Pair (" Lolicon" ," lolicon-novels" ),
33
+ Pair (" Martial Arts" ," martial-arts-novels" ),
34
+ Pair (" Mature" ," mature-novels" ),
35
+ Pair (" Mecha" ," mecha-novels" ),
36
+ Pair (" Modern Life" ," modern-life-novels" ),
37
+ Pair (" Mystery" ," mystery-novels" ),
38
+ Pair (" Psychological" ," psychological-novels" ),
39
+ Pair (" Reincarnation" ," reincarnation-novels" ),
40
+ Pair (" Romance" ," romance-novels" ),
41
+ Pair (" School Life" ," school-life-novels" ),
42
+ Pair (" Sci-fi" ," sci-fi-novels" ),
43
+ Pair (" Seinen" ," seinen-novels" ),
44
+ Pair (" Shoujo" ," shoujo-novels" ),
45
+ Pair (" Shounen Ai" ," shounen-ai-novels" ),
46
+ Pair (" Shounen" ," shounen-novels" ),
47
+ Pair (" Slice of Life" ," slice-of-life-novels" ),
48
+ Pair (" Smut" ," smut-novels" ),
49
+ Pair (" Sports" ," sports-novels" ),
50
+ Pair (" Supernatural" ," supernatural-novels" ),
51
+ Pair (" Tragedy" ," tragedy-novels" ),
52
+ Pair (" Wuxia" ," wuxia-novels" ),
53
+ Pair (" Xianxia" ," xianxia-novels" ),
54
+ Pair (" Xuanhuan" ," xuanhuan-novels" ),
55
+ Pair (" Yaoi" ," yaoi-novels" ),
56
+ Pair (" Yuri" ," yuri-novels" )
57
+ )
58
+
59
+ override suspend fun loadMainPage (
60
+ page : Int ,
61
+ mainCategory : String? ,
62
+ orderBy : String? ,
63
+ tag : String?
64
+ ): HeadMainPageResponse {
65
+ val url =
66
+ if (tag.isNullOrBlank()) " $mainUrl /latest-novels/page/$page " else " $mainUrl /$tag /page/$page "
67
+ val response = app.get(url)
68
+
69
+ val document = Jsoup .parse(response.text)
70
+
71
+ val headers = document.select(" div.home-truyendecu" )
72
+ if (headers.size <= 0 ) return HeadMainPageResponse (url, ArrayList ())
73
+ val returnValue: ArrayList <SearchResponse > = ArrayList ()
74
+ for (h in headers) {
75
+
76
+ val name = h.selectFirst(" a" )!! .attr(" title" )
77
+ val posterUrl = h.selectFirst(" img" )?.attr(" src" )
78
+ val cUrl = h.selectFirst(" a" )!! .attr(" href" )
79
+ returnValue.add(
80
+ SearchResponse (
81
+ name,
82
+ cUrl,
83
+ fixUrlNull(posterUrl),
84
+ null ,
85
+ null ,
86
+ this .name
87
+ )
88
+ )
89
+ }
90
+ return HeadMainPageResponse (url, returnValue)
91
+ }
92
+
93
+ override suspend fun loadHtml (url : String ): String? {
94
+ val response = app.get(url)
95
+ val document = Jsoup .parse(response.text)
96
+ return document.selectFirst(" div.chapter-content" )?.html()
97
+ }
98
+
99
+
100
+ override suspend fun search (query : String ): List <SearchResponse > {
101
+ val document = app.get(" $mainUrl /?s=$query " ).document
102
+
103
+
104
+ val headers = document.select(" div.home-truyendecu" )
105
+ if (headers.size <= 0 ) return ArrayList ()
106
+ val returnValue: ArrayList <SearchResponse > = ArrayList ()
107
+ for (h in headers) {
108
+
109
+ val name = h.selectFirst(" a" )!! .attr(" title" )
110
+ val posterUrl = h.selectFirst(" img" )?.attr(" src" )
111
+ val cUrl = h.selectFirst(" a" )!! .attr(" href" )
112
+ returnValue.add(
113
+ SearchResponse (
114
+ name,
115
+ cUrl,
116
+ fixUrlNull(posterUrl),
117
+ null ,
118
+ null ,
119
+ this .name
120
+ )
121
+ )
122
+ }
123
+ return returnValue
124
+ }
125
+
126
+ override suspend fun load (url : String ): LoadResponse ? {
127
+ val response = app.get(url)
128
+
129
+ val document = Jsoup .parse(response.text)
130
+ val name = document.selectFirst(" h3.title" )?.text() ? : return null
131
+
132
+ val infos = document.selectFirst(" div.info" )
133
+ val author = infos?.getElementsByAttributeValue(" itemprop" , " author" )?.joinToString(" , " ) { it.text() }
134
+ val tags = infos?.getElementsByAttributeValue(" itemprop" ," genre" )?.map { it.text() }
135
+
136
+ val posterUrl = document.select(" div.book > img" ).attr(" src" )
137
+ val synopsis = document.selectFirst(" div.desc-text" )?.text()
138
+
139
+ val data: ArrayList <ChapterData > = ArrayList ()
140
+ val chapid= document.selectFirst(" input#id_post" )?.attr(" value" )
141
+ val chaptersDataphp = app.post(
142
+ " $mainUrl /wp-admin/admin-ajax.php" ,
143
+ data = mapOf (
144
+ " action" to " tw_ajax" ,
145
+ " type" to " list_chap" ,
146
+ " id" to chapid!!
147
+ )
148
+ )
149
+ val parsed = Jsoup .parse(chaptersDataphp.text).select(" option" )
150
+
151
+ for (c in parsed) {
152
+
153
+ val cUrl = c?.attr(" value" )!!
154
+ val cName = if (c.text().isEmpty()) {
155
+ " chapter $c "
156
+ } else {
157
+ c.text()
158
+ }
159
+ data.add(ChapterData (cName, cUrl, null , null ))
160
+ }
161
+
162
+
163
+ val statusdata = document.selectFirst(" div.glyphicon.glyphicon-time" )?.child(1 )?.text()
164
+
165
+ val status = when (statusdata) {
166
+ " OnGoing" -> STATUS_ONGOING
167
+ " Completed" -> STATUS_COMPLETE
168
+ else -> STATUS_NULL
169
+ }
170
+
171
+ var rating = document.getElementsByAttributeValue(" itemprop" , " ratingValue" ).text().toRate()
172
+ var peopleVoted = document.getElementsByAttributeValue(" itemprop" , " ratingCount" ).text().toInt()
173
+
174
+
175
+ return LoadResponse (
176
+ url,
177
+ name,
178
+ data,
179
+ author,
180
+ fixUrlNull(posterUrl),
181
+ rating,
182
+ peopleVoted,
183
+ null ,
184
+ synopsis,
185
+ tags,
186
+ status
187
+ )
188
+ }
189
+
190
+ }
0 commit comments