Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
Fixed bug where tracklist was not coming back from lastfm due to it s…
Browse files Browse the repository at this point in the history
…earch by mbid instead of artist and ablum names
  • Loading branch information
Mark Hunter committed Sep 7, 2011
1 parent a88adb7 commit 3359a1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Expand Up @@ -3,7 +3,7 @@ name := "music"

organization := "com.gu.arts"

version in ThisBuild := "0.1.8"
version in ThisBuild := "0.1.11"

publishTo <<= (version) { version: String =>
val publishType = if (version.endsWith("SNAPSHOT")) "snapshots" else "releases"
Expand Down
Expand Up @@ -5,8 +5,10 @@ import java.net.URLEncoder
import net.liftweb.json.JsonAST.JValue

case class Tracks(track: List[Track])

case class Track(title: String)
case class RankAttr(rank: String)
case class Track(name: String, attr: RankAttr) {
lazy val rank = attr.rank
}

case class ArtistProfile(name: String, url: String, bio: ArtistBiography, tags: ArtistTags, stats: ArtistStats, image: List[ArtistImage]) {
def getImage(imageSize: String, default: String) = {
Expand Down Expand Up @@ -85,19 +87,9 @@ object LastFmAlbumTracks extends ArtistApi {
override val searchToken = "artist"
override val searchToken2 = "album"

def apply(mbid: String)(implicit lastfmApiKey: LastfmApiKey): Option[Tracks] = {
val result = retrieve(mbid, lastfmApiKey)
val json = (parse(result) \ "tracks").extractOpt[Tracks]
json match {
case Some(j) => json
case None => {
val track = (parse(result) \ "tracks" \ "track").extractOpt[Track]
track match {
case None => None
case Some(track) => Some(Tracks(List(track)))
}
}
}
def apply(artistName: String, albumName: String)(implicit lastfmApiKey: LastfmApiKey): Option[Tracks] = {
val albumJson = retrieveWithMoreTokens(artistName, albumName, lastfmApiKey).replaceAll("@attr","attr")
(parse(albumJson) \ "album" \ "tracks").extractOpt[Tracks]
}
}

Expand Down

0 comments on commit 3359a1c

Please sign in to comment.