MangaDistrict: fix date map (#4621)
This commit is contained in:
parent
7c8f692488
commit
b5df6c5788
|
@ -3,7 +3,7 @@ ext {
|
||||||
extClass = '.MangaDistrict'
|
extClass = '.MangaDistrict'
|
||||||
themePkg = 'madara'
|
themePkg = 'madara'
|
||||||
baseUrl = 'https://mangadistrict.com'
|
baseUrl = 'https://mangadistrict.com'
|
||||||
overrideVersionCode = 6
|
overrideVersionCode = 7
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.extension.en.mangadistrict
|
package eu.kanade.tachiyomi.extension.en.mangadistrict
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
|
@ -12,6 +13,7 @@ import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
@ -74,7 +76,8 @@ class MangaDistrict :
|
||||||
|
|
||||||
override fun chapterFromElement(element: Element): SChapter {
|
override fun chapterFromElement(element: Element): SChapter {
|
||||||
return super.chapterFromElement(element).apply {
|
return super.chapterFromElement(element).apply {
|
||||||
preferences.dates[url]?.also {
|
val urlKey = url.urlKey()
|
||||||
|
preferences.dates[urlKey]?.also {
|
||||||
date_upload = it
|
date_upload = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,15 +89,26 @@ class MangaDistrict :
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
try {
|
try {
|
||||||
preferences.dates[document.location()] = pageListDate.parse(
|
pageListDate.parse(
|
||||||
document.selectFirst("meta[property=og:updated_time]")!!
|
document.selectFirst("meta[property=og:updated_time]")!!
|
||||||
.attr("content").substringBeforeLast("+"),
|
.attr("content").substringBeforeLast("+"),
|
||||||
)!!.time
|
)!!.time.also {
|
||||||
|
val dates = preferences.dates
|
||||||
|
val urlKey = document.location().urlKey()
|
||||||
|
dates[urlKey] = it
|
||||||
|
preferences.dates = dates
|
||||||
|
}
|
||||||
} catch (_: Exception) {}
|
} catch (_: Exception) {}
|
||||||
|
|
||||||
return super.pageListParse(document)
|
return super.pageListParse(document)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun String.urlKey(): String {
|
||||||
|
return toHttpUrl().pathSegments.let { path ->
|
||||||
|
"${path[1]}/${path[2]}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun isRemoveTitleVersion() = preferences.getBoolean(REMOVE_TITLE_VERSION_PREF, false)
|
private fun isRemoveTitleVersion() = preferences.getBoolean(REMOVE_TITLE_VERSION_PREF, false)
|
||||||
private fun getImgRes() = preferences.getString(IMG_RES_PREF, IMG_RES_DEFAULT)!!
|
private fun getImgRes() = preferences.getString(IMG_RES_PREF, IMG_RES_DEFAULT)!!
|
||||||
|
|
||||||
|
@ -104,10 +118,10 @@ class MangaDistrict :
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
mutableMapOf()
|
mutableMapOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ApplySharedPref")
|
||||||
set(newVal) {
|
set(newVal) {
|
||||||
val currentMap = dates
|
edit().putString(DATE_MAP, json.encodeToString(newVal)).commit()
|
||||||
currentMap.putAll(newVal)
|
|
||||||
edit().putString(DATE_MAP, json.encodeToString(currentMap)).apply()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
|
|
Loading…
Reference in New Issue