Give addons download IDs like new a-c does so we can look them up from links

pull/274/head iceraven-1.6.0
Adam Novak 3 years ago
parent c384acf974
commit 8f9942196a

@ -239,13 +239,15 @@ internal fun JSONObject.getAddons(): List<Addon> {
internal fun JSONObject.toAddons(): Addon { internal fun JSONObject.toAddons(): Addon {
return with(getJSONObject("addon")) { return with(getJSONObject("addon")) {
val download = getDownload()
Addon( Addon(
id = getSafeString("guid"), id = getSafeString("guid"),
authors = getAuthors(), authors = getAuthors(),
categories = getCategories(), categories = getCategories(),
createdAt = getSafeString("created"), createdAt = getSafeString("created"),
updatedAt = getSafeString("last_updated"), updatedAt = getSafeString("last_updated"),
downloadUrl = getDownloadUrl(), downloadId = download?.getDownloadId() ?: "",
downloadUrl = download?.getDownloadUrl() ?: "",
version = getCurrentVersion(), version = getCurrentVersion(),
permissions = getPermissions(), permissions = getPermissions(),
translatableName = getSafeMap("name"), translatableName = getSafeMap("name"),
@ -298,11 +300,18 @@ internal fun JSONObject.getCurrentVersion(): String {
return optJSONObject("current_version")?.getSafeString("version") ?: "" return optJSONObject("current_version")?.getSafeString("version") ?: ""
} }
internal fun JSONObject.getDownloadUrl(): String { internal fun JSONObject.getDownload(): JSONObject? {
return (getJSONObject("current_version") return (getJSONObject("current_version")
.optJSONArray("files") .optJSONArray("files")
?.getJSONObject(0)) ?.getJSONObject(0))
?.getSafeString("url") ?: "" }
internal fun JSONObject.getDownloadId(): String {
return getSafeString("id")
}
internal fun JSONObject.getDownloadUrl(): String {
return getSafeString("url")
} }
internal fun JSONObject.getAuthors(): List<Addon.Author> { internal fun JSONObject.getAuthors(): List<Addon.Author> {

Loading…
Cancel
Save