Fix ScranTradUnion duplicate pages (#7694) (#7760)

This commit is contained in:
Aurélien Dussauge 2021-06-20 14:35:54 +02:00 committed by GitHub
parent 475279342d
commit f07c10737f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Scantrad Union' extName = 'Scantrad Union'
pkgNameSuffix = 'fr.scantradunion' pkgNameSuffix = 'fr.scantradunion'
extClass = '.ScantradUnion' extClass = '.ScantradUnion'
extVersionCode = 1 extVersionCode = 2
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -89,14 +89,20 @@ class ScantradUnion : ParsedHttpSource() {
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
return document.select("#webtoon a img") return document.select("#webtoon a img")
.mapIndexed { index: Int, imgElem: Element -> .map { imgElem: Element ->
// In webtoon mode, images have an src attribute only. // In webtoon mode, images have an src attribute only.
// In manga mode, images have a data-src attribute that contains the src // In manga mode, images have a data-src attribute that contains the src
val imgElemDataSrc = imgElem.attr("data-src") val imgElemDataSrc = imgElem.attr("data-src")
val imgElemSrc = imgElem.attr("src") val imgElemSrc = imgElem.attr("src")
val imgUrl = if (imgElemDataSrc.isNullOrBlank()) imgElemSrc else imgElemDataSrc if (imgElemDataSrc.isNullOrBlank()) imgElemSrc else imgElemDataSrc
}
// Since June 2021, webtoon html has both elements sometimes (data-src and src)
// So there are duplicates when fetching pages
// https://github.com/tachiyomiorg/tachiyomi-extensions/issues/7694
// The distinct() prevent this problem when it happens
.distinct()
.mapIndexed { index: Int, imgUrl: String ->
Page(index, "", imgUrl) Page(index, "", imgUrl)
} }
} }