Cubari QoL (#6746)

* Update Cubari.kt

* Update build.gradle

* Made a Oopsie.

* Oopsie fixing

* -_- Again I guess

* Update Cubari.kt
This commit is contained in:
FourTOne5 2021-04-29 20:16:14 +06:00 committed by GitHub
parent 8ce3cd65f1
commit a77f70473f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 2 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Cubari' extName = 'Cubari'
pkgNameSuffix = "all.cubari" pkgNameSuffix = "all.cubari"
extClass = '.CubariFactory' extClass = '.CubariFactory'
extVersionCode = 2 extVersionCode = 3
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.extension.all.cubari package eu.kanade.tachiyomi.extension.all.cubari
import android.app.Application
import android.os.Build import android.os.Build
import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
@ -16,6 +17,8 @@ import okhttp3.Response
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
import rx.Observable import rx.Observable
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
open class Cubari(override val lang: String) : HttpSource() { open class Cubari(override val lang: String) : HttpSource() {
@ -247,10 +250,15 @@ open class Cubari(override val lang: String) : HttpSource() {
val json = JSONObject(payload) val json = JSONObject(payload)
val groups = json.getJSONObject("groups") val groups = json.getJSONObject("groups")
val chapters = json.getJSONObject("chapters") val chapters = json.getJSONObject("chapters")
val seriesSlug = json.getJSONObject("slug")
val chapterList = ArrayList<SChapter>() val chapterList = ArrayList<SChapter>()
val iter = chapters.keys() val iter = chapters.keys()
val seriesPrefs = Injekt.get<Application>().getSharedPreferences("source_${id}_time_found:$seriesSlug", 0)
val seriesPrefsEditor = seriesPrefs.edit()
while (iter.hasNext()) { while (iter.hasNext()) {
val chapterNum = iter.next() val chapterNum = iter.next()
@ -263,11 +271,32 @@ open class Cubari(override val lang: String) : HttpSource() {
val chapter = SChapter.create() val chapter = SChapter.create()
chapter.scanlator = groups.getString(groupNum) chapter.scanlator = groups.getString(groupNum)
//Api for gist (and some others maybe) doesn't give a "release_date" so we will use the Manga update time.
//So when new chapter comes the manga will go on top if sortinf is set to "Last Updated"
//Code by ivaniskandar (Implemented on CatManga extension.)
if (chapterObj.has("release_date")) { if (chapterObj.has("release_date")) {
chapter.date_upload = chapter.date_upload =
chapterObj.getJSONObject("release_date").getLong(groupNum) * 1000 chapterObj.getJSONObject("release_date").getLong(groupNum) * 1000
} else {
val currentTimeMillis = System.currentTimeMillis()
if (!seriesPrefs.contains(chapterNum)) {
seriesPrefsEditor.putLong(chapterNum, currentTimeMillis)
}
chapter.date_upload = seriesPrefs.getLong(chapterNum, currentTimeMillis)
}
chapter.name = if (chapterObj.has("volume")) {
"Vol. " + chapterObj.getString("volume") + " Ch. " + chapterNum + " - " + chapterObj.getString("title")
//Output "Vol. 1 Ch. 1 - Chapter Name"
} else {
"Ch. " + chapterNum + " - " + chapterObj.getString("title")
//Output "Ch. 1 - Chapter Name"
} }
chapter.name = chapterNum + " - " + chapterObj.getString("title")
chapter.chapter_number = chapterNum.toFloat() chapter.chapter_number = chapterNum.toFloat()
chapter.url = chapter.url =
if (chapterGroups.optJSONArray(groupNum) != null) { if (chapterGroups.optJSONArray(groupNum) != null) {
@ -279,6 +308,7 @@ open class Cubari(override val lang: String) : HttpSource() {
} }
} }
seriesPrefsEditor.apply()
return chapterList.reversed() return chapterList.reversed()
} }