LANraragi: Safer tag parsing. (#5490)
It was possible to get a null into the function and the following split() did not like it.
This commit is contained in:
parent
bb884dfee1
commit
19adc29d1d
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'LANraragi'
|
extName = 'LANraragi'
|
||||||
pkgNameSuffix = 'all.lanraragi'
|
pkgNameSuffix = 'all.lanraragi'
|
||||||
extClass = '.LANraragi'
|
extClass = '.LANraragi'
|
||||||
extVersionCode = 3
|
extVersionCode = 4
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,26 +430,29 @@ open class LANraragi : ConfigurableSource, HttpSource() {
|
|||||||
return getTopResponse(response).request().url().queryParameter("start")!!.toInt()
|
return getTopResponse(response).request().url().queryParameter("start")!!.toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getArtist(tags: String): String {
|
private fun getNSTag(tags: String?, tag: String): List<String>? {
|
||||||
tags.split(',').forEach {
|
tags?.split(',')?.forEach {
|
||||||
if (it.contains(':')) {
|
if (it.contains(':')) {
|
||||||
val temp = it.trim().split(':')
|
val temp = it.trim().split(":", limit = 2)
|
||||||
|
if (temp[0].equals(tag, true)) return temp
|
||||||
if (temp[0].equals("artist", true)) return temp[1]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getArtist(tags: String?): String {
|
||||||
|
getNSTag(tags, "artist")?.let {
|
||||||
|
return it[1]
|
||||||
|
}
|
||||||
|
|
||||||
return "N/A"
|
return "N/A"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDateAdded(tags: String): String {
|
private fun getDateAdded(tags: String?): String {
|
||||||
tags.split(',').forEach {
|
getNSTag(tags, "date_added")?.let {
|
||||||
if (it.contains(':')) {
|
// Pad Date Added NS to milliseconds
|
||||||
val temp = it.trim().split(':')
|
return it[1].padEnd(13, '0')
|
||||||
|
|
||||||
// Pad Date Added LRR plugin (or user specified namespace) to milliseconds
|
|
||||||
if (temp[0].equals(latestNamespacePref, true)) return temp[1].padEnd(13, '0')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user