fixed bug with json for manga that were added pre id only url (#239)

This commit is contained in:
Carlos 2018-03-08 08:13:49 -05:00 committed by GitHub
parent b650471af6
commit 5583a68623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -5,8 +5,8 @@ ext {
appName = 'Tachiyomi: MangaDex'
pkgNameSuffix = "all.mangadex"
extClass = '.MangadexFactory'
extVersionCode = 12
extVersionSuffix = 12
extVersionCode = 13
extVersionSuffix = 13
libVersion = '1.2'
}

View File

@ -172,7 +172,16 @@ open class Mangadex(override val lang: String, private val internalLang: String,
return GET(baseUrl + URL + getMangaId(manga.url), headers)
}
private fun getMangaId(url: String) = url.trimEnd('/').substringAfterLast("/")
private fun getMangaId(url: String): String {
val lastSection = url.trimEnd('/').substringAfterLast("/")
return if (lastSection.toIntOrNull() != null) {
lastSection
} else {
//this occurs if person has manga from before that had the id/name/
url.trimEnd('/').substringBeforeLast("/").substringAfterLast("/")
}
}
override fun mangaDetailsParse(response: Response): SManga {
val manga = SManga.create()