Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

Commit

Permalink
fix: update Track to API change - add version field
Browse files Browse the repository at this point in the history
fixes #68
  • Loading branch information
Xerus committed Jul 27, 2019
1 parent 2bbdd6c commit 49317b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/xerus/monstercat/api/Cache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import xerus.monstercat.downloader.CONNECTSID
import xerus.monstercat.globalDispatcher
import java.io.File

private const val cacheVersion = 4
private const val cacheVersion = 5

object Cache: Refresher() {
private val logger = KotlinLogging.logger { }
Expand Down
10 changes: 8 additions & 2 deletions src/main/xerus/monstercat/api/response/Track.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ open class Track: MusicItem() {
@Key
override var title: String = ""
@Key
var version: String = ""
@Key
var albums: List<Album> = emptyList()
@Key("artistRelationships")
var artists: List<ArtistRel> = emptyList()
Expand Down Expand Up @@ -55,7 +57,7 @@ open class Track: MusicItem() {

artistsTitle = formatArtists(artistsTitle)
artistsSplit = artistsTitle.splitArtists()
splitTitle = "$artistsTitle $title".splitTitleTrimmed()
splitTitle = "$artistsTitle $title $version".splitTitleTrimmed()

title.splitTitle().forEachIndexed { index, s ->
when {
Expand All @@ -74,7 +76,11 @@ open class Track: MusicItem() {
return super.toString(template, *additionalFields)
}

override fun toString(): String = artistsTitle.isEmpty().to("%2\$s", "%s - %s").format(artistsTitle, title)
override fun toString(): String = when {
artistsTitle.isEmpty() -> "%2\$s"
version.isEmpty() -> "%s - %s"
else -> "%s - %s (%s)"
}.format(artistsTitle, title, version)

override fun equals(other: Any?): Boolean =
this === other || (other is Track && id == other.id)
Expand Down

0 comments on commit 49317b6

Please sign in to comment.