Update Grrl Power Comic (#15717)

* Update Grrl Power Comic

* Let tachiyomi guess at chapter numbers as suggested by arkon

---------

Co-authored-by: Theray Tharow <TharowT@Tharow.net>
This commit is contained in:
Theray Tharow 2023-03-18 12:39:48 -08:00 committed by GitHub
parent 9132d5a361
commit 7a3125f084
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 79 additions and 19 deletions

View File

@ -6,7 +6,11 @@ ext {
extName = 'Grrl Power Comic' extName = 'Grrl Power Comic'
pkgNameSuffix = 'en.grrlpower' pkgNameSuffix = 'en.grrlpower'
extClass = '.GrrlPower' extClass = '.GrrlPower'
extVersionCode = 1 extVersionCode = 2
}
dependencies {
implementation(project(':lib-textinterceptor'))
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 351 KiB

View File

@ -1,7 +1,14 @@
package eu.kanade.tachiyomi.extension.en.grrlpower package eu.kanade.tachiyomi.extension.en.grrlpower
import android.app.Application
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.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.asObservableSuccess
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
@ -12,6 +19,8 @@ import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import rx.Observable import rx.Observable
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Calendar import java.util.Calendar
import java.util.Locale import java.util.Locale
@ -23,25 +32,28 @@ class GrrlPower(
override val lang: String = "en", override val lang: String = "en",
override val name: String = "Grrl Power Comic", override val name: String = "Grrl Power Comic",
override val supportsLatest: Boolean = false, override val supportsLatest: Boolean = false,
) : HttpSource() { ) : HttpSource(), ConfigurableSource {
private val comicAuthor = "David Barrack"
private val startingYear = 2010 private val startingYear = 2010
private val currentYear = Calendar.getInstance().get(Calendar.YEAR) private val currentYear = Calendar.getInstance().get(Calendar.YEAR)
private val dateFormat = SimpleDateFormat("MMM dd yyyy", Locale.US) private val dateFormat = SimpleDateFormat("MMM dd yyyy", Locale.US)
override val client = super.client.newBuilder().addInterceptor(TextInterceptor()).build()
override fun fetchPopularManga(page: Int): Observable<MangasPage> = Observable.just( override fun fetchPopularManga(page: Int): Observable<MangasPage> = Observable.just(
MangasPage( MangasPage(
listOf( listOf(
SManga.create().apply { SManga.create().apply {
artist = "David Barrack" artist = comicAuthor
author = "David Barrack" author = comicAuthor
description = "Grrl Power is a comic about a crazy nerdette that becomes a" + description = "Grrl Power is a comic about a crazy nerdette that becomes a" +
" superheroine. Humor, action, cheesecake, beefcake, 'splosions," + " superheroine. Humor, action, cheesecake, beefcake, 'splosions," +
" and maybe some drama. Possibly ninjas. " " and maybe some drama. Possibly ninjas. "
genre = "superhero, humor, action" genre = "superhero, humor, action"
initialized = true initialized = true
status = SManga.ONGOING status = SManga.ONGOING
// TODO: Find Proper Thumbnail and Extension Icon // Thumbnail Found On The TvTropes Page for the comic
thumbnail_url = "https://fakeimg.pl/550x780/cc3333/1b2a82/?font=museo&text=Grrl%0APower" thumbnail_url = "https://static.tvtropes.org/pmwiki/pub/images/rsz_grrl_power.png"
title = "Grrl Power" title = "Grrl Power"
url = "/archive" url = "/archive"
}, },
@ -67,43 +79,87 @@ class GrrlPower(
// observables active at once. error shown below for reference in case someone knows a fix. // observables active at once. error shown below for reference in case someone knows a fix.
// java.lang.IllegalArgumentException: Sequence contains too many elements // java.lang.IllegalArgumentException: Sequence contains too many elements
} }
// Sort By Date
ret.sortByDescending { it.date_upload }
return Observable.just(ret) return Observable.just(ret)
} }
override fun chapterListParse(response: Response): List<SChapter> { override fun chapterListParse(response: Response): List<SChapter> {
val year = response.request.url.toString().substringAfter('=').toInt() val year = response.request.url.toString().substringAfter('=').toInt()
var num = 0
return response.asJsoup().getElementsByClass("archive-date").map { return response.asJsoup().getElementsByClass("archive-date").map {
val date = dateFormat.parse("${it.text()} $year") val date = dateFormat.parse("${it.text()} $year")
val link = it.nextElementSibling()!!.child(0) val link = it.nextElementSibling()!!.child(0)
SChapter.create().apply { SChapter.create().apply {
name = link.text() name = link.text()
setUrlWithoutDomain(link.attr("href")) setUrlWithoutDomain(link.attr("href"))
chapter_number = num++.toFloat()
date_upload = date?.time ?: 0L date_upload = date?.time ?: 0L
// chapter_number isn't set as suggested by arkon
// https://github.com/tachiyomiorg/tachiyomi-extensions/pull/15717#discussion_r1138014748
} }
} }
} }
override fun pageListParse(response: Response): List<Page> { override fun pageListParse(response: Response): List<Page> {
return listOf( val url: String = response.request.url.toString()
val pages: ArrayList<Page> = ArrayList()
val soup = response.asJsoup()
pages.add(
Page( Page(
0, 0,
response.request.url.toString(), url,
response.asJsoup().selectFirst("div#comic img")!!.absUrl("src"), soup.selectFirst("div#comic img")!!.absUrl("src"),
), ),
) )
// The TextInterceptor handles html natively.
val text = soup.getElementsByClass("entry").html()
if (text.isNotEmpty() && showAuthorsNotesPref()) {
pages.add(Page(1, "", TextInterceptorHelper.createUrl(comicAuthor, text)))
}
return pages
} }
// Show Authors Notes Pref Copied from
// ProjectRoot/multisrc/overrides/webtoons/webtoons/src/WebtoonsSrc.kt
private val preferences: SharedPreferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
}
companion object {
private const val SHOW_AUTHORS_NOTES_KEY = "showAuthorsNotes"
}
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)
setOnPreferenceChangeListener { _, newValue ->
val checkValue = newValue as Boolean
preferences.edit().putBoolean(SHOW_AUTHORS_NOTES_KEY, checkValue).commit()
}
}
screen.addPreference(authorsNotesPref)
} // End of Preferences
// This can be called when the user refreshes the comic even if initialized is true // This can be called when the user refreshes the comic even if initialized is true
override fun fetchMangaDetails(manga: SManga): Observable<SManga> = Observable.just(manga) override fun fetchMangaDetails(manga: SManga): Observable<SManga> = Observable.just(manga)
override fun popularMangaRequest(page: Int): Request = throw UnsupportedOperationException("Not Used") override fun popularMangaRequest(page: Int): Request =
override fun searchMangaParse(response: Response): MangasPage = throw UnsupportedOperationException("Not Used") throw UnsupportedOperationException("Not Used")
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = throw UnsupportedOperationException("Not Used") override fun searchMangaParse(response: Response): MangasPage =
override fun imageUrlParse(response: Response): String = throw UnsupportedOperationException("Not Used") throw UnsupportedOperationException("Not Used")
override fun latestUpdatesParse(response: Response): MangasPage = throw UnsupportedOperationException("Not Used") override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request =
override fun latestUpdatesRequest(page: Int): Request = throw UnsupportedOperationException("Not Used") throw UnsupportedOperationException("Not Used")
override fun mangaDetailsParse(response: Response): SManga = throw UnsupportedOperationException("Not Used") override fun imageUrlParse(response: Response): String =
override fun popularMangaParse(response: Response): MangasPage = throw UnsupportedOperationException("Not Used") throw UnsupportedOperationException("Not Used")
override fun latestUpdatesParse(response: Response): MangasPage =
throw UnsupportedOperationException("Not Used")
override fun latestUpdatesRequest(page: Int): Request =
throw UnsupportedOperationException("Not Used")
override fun mangaDetailsParse(response: Response): SManga =
throw UnsupportedOperationException("Not Used")
override fun popularMangaParse(response: Response): MangasPage =
throw UnsupportedOperationException("Not Used")
} }