FlameScans: Fix permanent url logic (#14394)
* Update logic for deobfuscating series and chapter urls * Fix lint issue * Fix grammar in permanent chapter url preference summary
This commit is contained in:
parent
bd8a914a88
commit
7a4378c5df
|
@ -163,32 +163,21 @@ open class FlameScans(
|
||||||
val turnTempUrlToPerm = preferences.getBoolean(getPermanentMangaUrlPreferenceKey(), true)
|
val turnTempUrlToPerm = preferences.getBoolean(getPermanentMangaUrlPreferenceKey(), true)
|
||||||
if (!turnTempUrlToPerm) return this
|
if (!turnTempUrlToPerm) return this
|
||||||
|
|
||||||
val sMangaTitleFirstWord = this.title.split(" ")[0]
|
val path = this.url.removePrefix("/").removeSuffix("/").split("/")
|
||||||
if (!this.url.contains("/$sMangaTitleFirstWord", ignoreCase = true)) {
|
path.lastOrNull()?.let { slug -> this.url = "$mangaUrlDirectory/${deobfuscateSlug(slug)}/" }
|
||||||
this.url = this.url.replaceFirst(TEMP_TO_PERM_URL_REGEX, "$1")
|
|
||||||
}
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
override fun fetchChapterList(manga: SManga) = super.fetchChapterList(manga.tempUrlToPermIfNeeded())
|
||||||
val sManga = manga.tempUrlToPermIfNeeded()
|
.map { sChapterList -> sChapterList.map { it.tempUrlToPermIfNeeded() } }
|
||||||
return super.fetchChapterList(sManga).map { sChapterList ->
|
|
||||||
sChapterList.map { it.tempUrlToPermIfNeeded(sManga) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun SChapter.tempUrlToPermIfNeeded(manga: SManga): SChapter {
|
private fun SChapter.tempUrlToPermIfNeeded(): SChapter {
|
||||||
val turnTempUrlToPerm = preferences.getBoolean(getPermanentChapterUrlPreferenceKey(), true)
|
val turnTempUrlToPerm = preferences.getBoolean(getPermanentChapterUrlPreferenceKey(), true)
|
||||||
if (!turnTempUrlToPerm) return this
|
if (!turnTempUrlToPerm) return this
|
||||||
|
|
||||||
val sChapterNameFirstWord = this.name.split(" ")[0]
|
val path = this.url.removePrefix("/").removeSuffix("/").split("/")
|
||||||
val sMangaTitleFirstWord = manga.title.split(" ")[0]
|
path.lastOrNull()?.let { slug -> this.url = "/${deobfuscateSlug(slug)}/" }
|
||||||
if (
|
|
||||||
!this.url.contains("/$sChapterNameFirstWord", ignoreCase = true) &&
|
|
||||||
!this.url.contains("/$sMangaTitleFirstWord", ignoreCase = true)
|
|
||||||
) {
|
|
||||||
this.url = this.url.replaceFirst(TEMP_TO_PERM_URL_REGEX, "$1")
|
|
||||||
}
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,9 +230,20 @@ open class FlameScans(
|
||||||
|
|
||||||
private const val PREF_PERM_CHAPTER_URL_KEY_PREFIX = "pref_permanent_chapter_url"
|
private const val PREF_PERM_CHAPTER_URL_KEY_PREFIX = "pref_permanent_chapter_url"
|
||||||
private const val PREF_PERM_CHAPTER_URL_TITLE = "Permanent Chapter URL"
|
private const val PREF_PERM_CHAPTER_URL_TITLE = "Permanent Chapter URL"
|
||||||
private const val PREF_PERM_CHAPTER_URL_SUMMARY = "Turns all chapter urls into permanent one."
|
private const val PREF_PERM_CHAPTER_URL_SUMMARY = "Turns all chapter urls into permanent ones."
|
||||||
|
|
||||||
private val TEMP_TO_PERM_URL_REGEX = Regex("""(/)\d+-""")
|
/**
|
||||||
|
*
|
||||||
|
* De-obfuscates the slug of a series or chapter to the permanent slug
|
||||||
|
* * For a series: "12345678-this-is-a-series" -> "this-is-a-series"
|
||||||
|
* * For a chapter: "12345678-this-is-a-series-chapter-1" -> "this-is-a-series-chapter-1"
|
||||||
|
*
|
||||||
|
* @param obfuscated_slug the obfuscated slug of a series or chapter
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private fun deobfuscateSlug(obfuscated_slug: String) = obfuscated_slug
|
||||||
|
.replaceFirst(Regex("""^\d+-"""), "")
|
||||||
|
|
||||||
private val MEDIA_TYPE = "image/png".toMediaType()
|
private val MEDIA_TYPE = "image/png".toMediaType()
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ class MangaThemesiaGenerator : ThemeSourceGenerator {
|
||||||
|
|
||||||
override val sources = listOf(
|
override val sources = listOf(
|
||||||
MultiLang("Asura Scans", "https://asura.gg", listOf("en", "tr"), className = "AsuraScansFactory", pkgName = "asurascans", overrideVersionCode = 17),
|
MultiLang("Asura Scans", "https://asura.gg", listOf("en", "tr"), className = "AsuraScansFactory", pkgName = "asurascans", overrideVersionCode = 17),
|
||||||
MultiLang("Flame Scans", "https://flamescans.org", listOf("ar", "en"), className = "FlameScansFactory", pkgName = "flamescans", overrideVersionCode = 2),
|
MultiLang("Flame Scans", "https://flamescans.org", listOf("ar", "en"), className = "FlameScansFactory", pkgName = "flamescans", overrideVersionCode = 3),
|
||||||
MultiLang("Komik Lab", "https://komiklab.com", listOf("en", "id"), className = "KomikLabFactory", pkgName = "komiklab", overrideVersionCode = 1),
|
MultiLang("Komik Lab", "https://komiklab.com", listOf("en", "id"), className = "KomikLabFactory", pkgName = "komiklab", overrideVersionCode = 1),
|
||||||
MultiLang("Miau Scan", "https://miauscan.com", listOf("es", "pt-BR")),
|
MultiLang("Miau Scan", "https://miauscan.com", listOf("es", "pt-BR")),
|
||||||
SingleLang("Animated Glitched Scans", "https://anigliscans.com", "en"),
|
SingleLang("Animated Glitched Scans", "https://anigliscans.com", "en"),
|
||||||
|
|
Loading…
Reference in New Issue