Questionable Content - add chapter date (#3566)
This commit is contained in:
parent
4973dd6d61
commit
fba57fdcb3
@ -5,7 +5,7 @@ ext {
|
|||||||
appName = 'Tachiyomi: Questionable Content'
|
appName = 'Tachiyomi: Questionable Content'
|
||||||
pkgNameSuffix = 'en.questionablecontent'
|
pkgNameSuffix = 'en.questionablecontent'
|
||||||
extClass = '.QuestionableContent'
|
extClass = '.QuestionableContent'
|
||||||
extVersionCode = 5
|
extVersionCode = 6
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,21 @@
|
|||||||
package eu.kanade.tachiyomi.extension.en.questionablecontent
|
package eu.kanade.tachiyomi.extension.en.questionablecontent
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.SharedPreferences
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||||
|
import java.util.Date
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
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
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
class QuestionableContent : ParsedHttpSource() {
|
class QuestionableContent : ParsedHttpSource() {
|
||||||
|
|
||||||
@ -31,6 +36,7 @@ class QuestionableContent : ParsedHttpSource() {
|
|||||||
url = "/archive.php"
|
url = "/archive.php"
|
||||||
description = "An internet comic strip about romance and robots"
|
description = "An internet comic strip about romance and robots"
|
||||||
thumbnail_url = "https://i.ibb.co/ZVL9ncS/qc-teh.png"
|
thumbnail_url = "https://i.ibb.co/ZVL9ncS/qc-teh.png"
|
||||||
|
initialized = true
|
||||||
}
|
}
|
||||||
|
|
||||||
return Observable.just(MangasPage(arrayListOf(manga), false))
|
return Observable.just(MangasPage(arrayListOf(manga), false))
|
||||||
@ -38,10 +44,24 @@ class QuestionableContent : ParsedHttpSource() {
|
|||||||
|
|
||||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> = Observable.just(MangasPage(emptyList(), false))
|
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> = Observable.just(MangasPage(emptyList(), false))
|
||||||
|
|
||||||
override fun fetchMangaDetails(manga: SManga) = Observable.just(manga)
|
override fun fetchMangaDetails(manga: SManga) = fetchPopularManga(1).map { it.mangas.first() }
|
||||||
|
|
||||||
|
private val preferences: SharedPreferences by lazy {
|
||||||
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
|
}
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
return super.chapterListParse(response).distinct()
|
val chapters = super.chapterListParse(response).distinct()
|
||||||
|
// set date of most recent chapter to today, use SharedPreferences so that we aren't changing it needlessly on refreshes
|
||||||
|
if (chapters.first().url != preferences.getString(LAST_CHAPTER_URL, null)) {
|
||||||
|
val date = Date().time
|
||||||
|
chapters.first().date_upload = date
|
||||||
|
preferences.edit().putString(LAST_CHAPTER_URL, chapters.first().url).apply()
|
||||||
|
preferences.edit().putLong(LAST_CHAPTER_DATE, date).apply()
|
||||||
|
} else {
|
||||||
|
chapters.first().date_upload = preferences.getLong(LAST_CHAPTER_DATE, 0L)
|
||||||
|
}
|
||||||
|
return chapters
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListSelector() = """div#container a[href^="view.php?comic="]"""
|
override fun chapterListSelector() = """div#container a[href^="view.php?comic="]"""
|
||||||
@ -60,6 +80,11 @@ class QuestionableContent : ParsedHttpSource() {
|
|||||||
|
|
||||||
override fun pageListParse(document: Document) = document.select("#strip").mapIndexed { i, element -> Page(i, "", baseUrl + element.attr("src").substring(1)) }
|
override fun pageListParse(document: Document) = document.select("#strip").mapIndexed { i, element -> Page(i, "", baseUrl + element.attr("src").substring(1)) }
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val LAST_CHAPTER_URL = "QC_LAST_CHAPTER_URL"
|
||||||
|
private const val LAST_CHAPTER_DATE = "QC_LAST_CHAPTER_DATE"
|
||||||
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(document: Document) = throw Exception("Not used")
|
override fun imageUrlParse(document: Document) = throw Exception("Not used")
|
||||||
|
|
||||||
override fun popularMangaSelector(): String = throw Exception("Not used")
|
override fun popularMangaSelector(): String = throw Exception("Not used")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user