Add title text as a page to Swords Comic source (#8022)

* Add title text as a page to Swords Comic source

* Bumb version number for Swords Comic source
This commit is contained in:
lord-ne 2021-07-09 06:40:49 -04:00 committed by GitHub
parent b495e6013a
commit c29b61cada
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Swords Comic'
pkgNameSuffix = 'en.swordscomic'
extClass = '.SwordsComic'
extVersionCode = 1
extVersionCode = 2
libVersion = '1.2'
}

View File

@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.extension.en.swordscomic
import android.net.Uri
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.source.model.Page
@ -87,7 +88,25 @@ class SwordsComic : HttpSource() {
// Pages
override fun pageListParse(response: Response): List<Page> {
return listOf(Page(0, "", response.asJsoup().select("img#comic-image").attr("abs:src")))
val imageElement = response.asJsoup().select("img#comic-image")
if (!imageElement.hasAttr("title")) {
return listOf(Page(0, "", imageElement.attr("abs:src")))
}
val builder = StringBuilder()
var charCount = 0
for (word in imageElement.attr("title").splitToSequence(" ")) {
if (charCount + word.length > 45) {
builder.append("%0A")
charCount = 0
}
charCount += word.length + 1
builder.append(Uri.encode(word.toUpperCase()))
builder.append("+")
}
return listOf(Page(0, "", imageElement.attr("abs:src")), Page(1, "", "https://fakeimg.pl/1800x2252/978B65/000000/?text=$builder&font_size=60&font=comic+sans"))
}
override fun imageUrlParse(response: Response): String = throw UnsupportedOperationException("Not used")