Add Author's Notes To QuestionableContent (#16924)

* Add Author's Notes To QuestionableContent

Signed-off-by: Theray Tharow <TharowT@Tharow.net>

* Update src/en/questionablecontent/src/eu/kanade/tachiyomi/extension/en/questionablecontent/QuestionableContent.kt

Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com>

---------

Signed-off-by: Theray Tharow <TharowT@Tharow.net>
Co-authored-by: Theray Tharow <tharowt@tharow.net>
Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com>
This commit is contained in:
Theray Tharow 2023-07-01 10:05:47 -04:00 committed by GitHub
parent 061d9f4fd2
commit abe6448516
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 7 deletions

View File

@ -5,7 +5,12 @@ ext {
extName = 'Questionable Content' extName = 'Questionable Content'
pkgNameSuffix = 'en.questionablecontent' pkgNameSuffix = 'en.questionablecontent'
extClass = '.QuestionableContent' extClass = '.QuestionableContent'
extVersionCode = 6 extVersionCode = 7
} }
dependencies {
implementation(project(':lib-textinterceptor'))
}
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -2,14 +2,21 @@ package eu.kanade.tachiyomi.extension.en.questionablecontent
import android.app.Application import android.app.Application
import android.content.SharedPreferences import android.content.SharedPreferences
import androidx.preference.PreferenceScreen
import androidx.preference.SwitchPreferenceCompat
import eu.kanade.tachiyomi.lib.textinterceptor.TextInterceptor
import eu.kanade.tachiyomi.lib.textinterceptor.TextInterceptorHelper
import eu.kanade.tachiyomi.source.ConfigurableSource
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 okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import okhttp3.internal.http.HTTP_UNAUTHORIZED
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
@ -17,21 +24,21 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import java.util.Date import java.util.Date
class QuestionableContent : ParsedHttpSource() { class QuestionableContent : ParsedHttpSource(), ConfigurableSource {
override val name = "Questionable Content" override val name = "Questionable Content"
override val baseUrl = "https://www.questionablecontent.net" override val baseUrl = "https://www.questionablecontent.net"
override val lang = "en" override val lang = "en"
override val supportsLatest = false override val supportsLatest = false
override val client: OkHttpClient = super.client.newBuilder().addInterceptor(TextInterceptor()).build()
override fun fetchPopularManga(page: Int): Observable<MangasPage> { override fun fetchPopularManga(page: Int): Observable<MangasPage> {
val manga = SManga.create().apply { val manga = SManga.create().apply {
title = "Questionable Content" title = name
artist = "Jeph Jacques" artist = AUTHOR
author = "Jeph Jacques" author = AUTHOR
status = SManga.ONGOING status = SManga.ONGOING
url = "/archive.php" url = "/archive.php"
description = "An internet comic strip about romance and robots" description = "An internet comic strip about romance and robots"
@ -80,11 +87,35 @@ class QuestionableContent : ParsedHttpSource() {
return chapter return chapter
} }
override fun pageListParse(document: Document) = document.select("#strip").mapIndexed { i, element -> Page(i, "", baseUrl + element.attr("src").substring(1)) } override fun pageListParse(document: Document): List<Page> {
val pages = document.select("#strip").mapIndexed { i, element -> Page(i, "", baseUrl + element.attr("src").substring(1)) }.toMutableList()
if (showAuthorsNotesPref()) {
val str = document.selectFirst("#newspost")?.html()
if (!str.isNullOrEmpty()) {
pages.add(Page(pages.size, "", TextInterceptorHelper.createUrl(AUTHOR, str)))
}
}
return pages
}
companion object { companion object {
private const val LAST_CHAPTER_URL = "QC_LAST_CHAPTER_URL" private const val LAST_CHAPTER_URL = "QC_LAST_CHAPTER_URL"
private const val LAST_CHAPTER_DATE = "QC_LAST_CHAPTER_DATE" private const val LAST_CHAPTER_DATE = "QC_LAST_CHAPTER_DATE"
private const val SHOW_AUTHORS_NOTES_KEY = "showAuthorsNotes"
private const val AUTHOR = "Jeph Jacques"
}
// Author's Notes, Based On Implementation In GrrlPower Extension
private fun showAuthorsNotesPref() = preferences.getBoolean(SHOW_AUTHORS_NOTES_KEY, false)
override fun setupPreferenceScreen(screen: PreferenceScreen) {
val authorsNotesPref = SwitchPreferenceCompat(screen.context).apply {
key = SHOW_AUTHORS_NOTES_KEY
title = "Show author's notes"
summary = "Enable to see the author's notes at the end of chapters (if they're there)."
setDefaultValue(false)
}
screen.addPreference(authorsNotesPref)
} }
override fun imageUrlParse(document: Document) = throw Exception("Not used") override fun imageUrlParse(document: Document) = throw Exception("Not used")