Tapastic - chapter lock icon (#1853)
This commit is contained in:
		
							parent
							
								
									3d6991f7be
								
							
						
					
					
						commit
						a48d4b1e76
					
				| @ -2,10 +2,10 @@ apply plugin: 'com.android.application' | |||||||
| apply plugin: 'kotlin-android' | apply plugin: 'kotlin-android' | ||||||
| 
 | 
 | ||||||
| ext { | ext { | ||||||
|     appName = 'Tachiyomi: Tapastic' |     appName = 'Tachiyomi: Tapas' | ||||||
|     pkgNameSuffix = 'en.tapastic' |     pkgNameSuffix = 'en.tapastic' | ||||||
|     extClass = '.Tapastic' |     extClass = '.Tapastic' | ||||||
|     extVersionCode = 3 |     extVersionCode = 4 | ||||||
|     libVersion = '1.2' |     libVersion = '1.2' | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,7 +2,8 @@ package eu.kanade.tachiyomi.extension.en.tapastic | |||||||
| 
 | 
 | ||||||
| import android.net.Uri | import android.net.Uri | ||||||
| import com.github.salomonbrys.kotson.* | import com.github.salomonbrys.kotson.* | ||||||
| import com.google.gson.JsonParser | import com.google.gson.Gson | ||||||
|  | import com.google.gson.JsonArray | ||||||
| import eu.kanade.tachiyomi.network.GET | import eu.kanade.tachiyomi.network.GET | ||||||
| import eu.kanade.tachiyomi.source.model.* | import eu.kanade.tachiyomi.source.model.* | ||||||
| import eu.kanade.tachiyomi.source.online.ParsedHttpSource | import eu.kanade.tachiyomi.source.online.ParsedHttpSource | ||||||
| @ -21,7 +22,7 @@ class Tapastic : ParsedHttpSource() { | |||||||
|     private val browseMangaSelector = ".content-item" |     private val browseMangaSelector = ".content-item" | ||||||
|     private val nextPageSelector = "a.paging-btn.next" |     private val nextPageSelector = "a.paging-btn.next" | ||||||
| 
 | 
 | ||||||
|     private val jsonParser by lazy { JsonParser() } |     private val gson by lazy { Gson() } | ||||||
| 
 | 
 | ||||||
|     override fun popularMangaSelector() = browseMangaSelector |     override fun popularMangaSelector() = browseMangaSelector | ||||||
| 
 | 
 | ||||||
| @ -82,52 +83,35 @@ class Tapastic : ParsedHttpSource() { | |||||||
| 
 | 
 | ||||||
|         description = document.getElementById("series-desc-body").text().trim() |         description = document.getElementById("series-desc-body").text().trim() | ||||||
| 
 | 
 | ||||||
|         genre = document.getElementsByClass("genre").text() |         genre = document.getElementsByClass("genre").joinToString { it.text() } | ||||||
| 
 | 
 | ||||||
|         status = SManga.UNKNOWN |         status = SManga.UNKNOWN | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/comics?pageNumber=$page&browse=FRESH") |     override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/comics?pageNumber=$page&browse=FRESH") | ||||||
| 
 | 
 | ||||||
|     override fun chapterListParse(response: Response) |     override fun chapterListParse(response: Response): List<SChapter> { | ||||||
|         //Chapters are stored in JavaScript as JSON! |         //Chapters are stored in JavaScript as JSON! | ||||||
|             = response.asJsoup().getElementsByTag("script").filter { |         return response.asJsoup().select("script:containsData(_data)").first()?.data().let { script -> | ||||||
|         it.data().trim().startsWith("var _data") |             if (script.isNullOrEmpty() || !script.contains("episodeList : [")) { | ||||||
|     }.flatMap { |                 emptyList() | ||||||
|         val text = it.data() |             } else { | ||||||
|         val episodeVar = text.indexOf("episodeList") |                 gson.fromJson<JsonArray>(script.substringAfter("episodeList : ").substringBefore(",\n")) | ||||||
|         if (episodeVar == -1) |                     //Ensure that the chapter is published (source allows scheduling chapters) | ||||||
|             return@flatMap emptyList<SChapter>() |                     .filter { it["orgScene"].int != 0 } | ||||||
| 
 |                     .map { json -> | ||||||
|         val episodeLeftBracket = text.indexOf('[', startIndex = episodeVar) |  | ||||||
|         if (episodeLeftBracket == -1) |  | ||||||
|             return@flatMap emptyList<SChapter>() |  | ||||||
| 
 |  | ||||||
|         val endOfLine = text.indexOf('\n', startIndex = episodeLeftBracket) |  | ||||||
|         if (endOfLine == -1) |  | ||||||
|             return@flatMap emptyList<SChapter>() |  | ||||||
| 
 |  | ||||||
|         val episodeRightBracket = text.lastIndexOf(']', startIndex = endOfLine) |  | ||||||
|         if (episodeRightBracket == -1) |  | ||||||
|             return@flatMap emptyList<SChapter>() |  | ||||||
| 
 |  | ||||||
|         val episodeListText = text.substring(episodeLeftBracket..episodeRightBracket) |  | ||||||
| 
 |  | ||||||
|         jsonParser.parse(episodeListText).array.map { |  | ||||||
|             val json = it.asJsonObject |  | ||||||
|             //Ensure that the chapter is published (tapastic allows scheduling chapters) |  | ||||||
|             if (json["orgScene"].int != 0) |  | ||||||
|                     SChapter.create().apply { |                     SChapter.create().apply { | ||||||
|                         url = "/episode/${json["id"].string}" |                         url = "/episode/${json["id"].string}" | ||||||
| 
 | 
 | ||||||
|                     name = json["title"].string |                         name = (if (json["locked"].asBoolean) "\uD83D\uDD12" else "") + json["title"].string | ||||||
| 
 | 
 | ||||||
|                         date_upload = json["publishDate"].long |                         date_upload = json["publishDate"].long | ||||||
| 
 | 
 | ||||||
|                         chapter_number = json["scene"].float |                         chapter_number = json["scene"].float | ||||||
|                     } |                     } | ||||||
|             else null |                 }.reversed() | ||||||
|         }.filterNotNull().sortedByDescending(SChapter::chapter_number) |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     override fun chapterListSelector() |     override fun chapterListSelector() | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Mike
						Mike