Nicomanga: fix cover and image fetching (#214)
* Nicomanga: fix cover and image fetching * not extlib 1.5 yet
This commit is contained in:
		
							parent
							
								
									d88fb5f595
								
							
						
					
					
						commit
						76a7c8c54a
					
				| @ -5,7 +5,7 @@ ext { | |||||||
|     extName = 'Nicomanga' |     extName = 'Nicomanga' | ||||||
|     pkgNameSuffix = 'ja.nicomanga' |     pkgNameSuffix = 'ja.nicomanga' | ||||||
|     extClass = '.Nicomanga' |     extClass = '.Nicomanga' | ||||||
|     extVersionCode = 1 |     extVersionCode = 2 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| apply from: "$rootDir/common.gradle" | apply from: "$rootDir/common.gradle" | ||||||
|  | |||||||
| @ -34,6 +34,9 @@ class Nicomanga : HttpSource() { | |||||||
| 
 | 
 | ||||||
|     override val client: OkHttpClient = network.cloudflareClient |     override val client: OkHttpClient = network.cloudflareClient | ||||||
| 
 | 
 | ||||||
|  |     override fun headersBuilder() = super.headersBuilder() | ||||||
|  |         .add("Referer", "$baseUrl/") | ||||||
|  | 
 | ||||||
|     private fun mangaListParse(response: Response): MangasPage { |     private fun mangaListParse(response: Response): MangasPage { | ||||||
|         val doc = response.asJsoup() |         val doc = response.asJsoup() | ||||||
|         val hasNextPage = ( |         val hasNextPage = ( | ||||||
| @ -113,10 +116,17 @@ class Nicomanga : HttpSource() { | |||||||
|     override fun chapterListParse(response: Response): List<SChapter> { |     override fun chapterListParse(response: Response): List<SChapter> { | ||||||
|         val doc = response.asJsoup() |         val doc = response.asJsoup() | ||||||
|         val chapterList = doc.select("ul > a") |         val chapterList = doc.select("ul > a") | ||||||
|  |         val chapterPrefix = "$baseUrl/app/manga/controllers" | ||||||
|  | 
 | ||||||
|         val chapters = chapterList.map { chapter -> |         val chapters = chapterList.map { chapter -> | ||||||
|             SChapter.create().apply { |             SChapter.create().apply { | ||||||
|                 name = chapter.attr("title").trim() |                 name = chapter.attr("title").trim() | ||||||
|                 setUrlWithoutDomain(chapter.absUrl("href")) |                 val url = chapter.absUrl("href").run { | ||||||
|  |                     takeIf { startsWith(chapterPrefix) } | ||||||
|  |                         ?.replaceFirst(chapterPrefix, baseUrl) | ||||||
|  |                         ?: this | ||||||
|  |                 } | ||||||
|  |                 setUrlWithoutDomain(url) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return chapters |         return chapters | ||||||
| @ -124,19 +134,13 @@ class Nicomanga : HttpSource() { | |||||||
| 
 | 
 | ||||||
|     override fun pageListParse(response: Response): List<Page> { |     override fun pageListParse(response: Response): List<Page> { | ||||||
|         val id = chapterIdRegex.find(response.body.string())?.groupValues?.get(1) ?: throw Exception("chapter-id not found") |         val id = chapterIdRegex.find(response.body.string())?.groupValues?.get(1) ?: throw Exception("chapter-id not found") | ||||||
|         val headers = headersBuilder().set("referer", response.request.url.toString()).build() |  | ||||||
|         val r = client.newCall(GET("$baseUrl/app/manga/controllers/cont.imgsList.php?cid=$id", headers)).execute() |         val r = client.newCall(GET("$baseUrl/app/manga/controllers/cont.imgsList.php?cid=$id", headers)).execute() | ||||||
|         val doc = r.asJsoup() |         val doc = r.asJsoup() | ||||||
|         return doc.select("img.chapter-img").mapIndexed { i, page -> |         return doc.select("img.chapter-img").mapIndexed { i, page -> | ||||||
|             Page(i + 1, page.attr("data-src")) |             Page(i + 1, imageUrl = page.attr("data-src")) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     override fun imageRequest(page: Page): Request { |  | ||||||
|         val headers = headersBuilder().set("referer", baseUrl).build() |  | ||||||
|         return GET(page.imageUrl!!, headers) |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     override fun imageUrlParse(response: Response): String = |     override fun imageUrlParse(response: Response): String = | ||||||
|         throw UnsupportedOperationException("Not used") |         throw UnsupportedOperationException("Not used") | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Vetle Ledaal
						Vetle Ledaal