nicknux / scalarovi

A Simple Rovi API Client Library for Scala

Version Matrix

ScalaRovi

A Simple Rovi API Client Library for Scala. Currently only supports Music-related lookups.

API Key

You need to get your own API Key from http://developer.rovicorp.com and place it in resources/reference.conf.

Installation

libraryDependencies += "com.nickdsantos" % "scalarovi_2.11" % "0.0.1"

Importing

import com.nickdsantos.scalarovi._

Samples

More samples can be found in the unit tests located at /src/test/scala.

val metadataSearch: MetadataSearch = new MetadataSearch(
      configFactory.getString("secrets.rovi.key"),
      configFactory.getString("secrets.rovi.secret"))

val nameMetadata: NameMetadata = new NameMetadata(
      configFactory.getString("secrets.rovi.key"),
      configFactory.getString("secrets.rovi.secret"))

var albumMetadata: AlbumMetadata = new AlbumMetadata(
      configFactory.getString("secrets.rovi.key"),
      configFactory.getString("secrets.rovi.secret"))

/* Look up artist by name */
val searchResponse = metadataSearch.searchForArtist("Led Zeppelin")
println(s"Result Count = ${searchResponse.totalResultCounts}")
println(s"Ids = ${searchResponse.results(0).name.ids}")
println(s"Name = ${searchResponse.results(0).name.name}")

/* Get Artist By ID */
val nameData = nameMetadata.getArtistById("MN0000139026")
println(s"NameId = ${nameData.name.ids.get("nameId").get}")
println(s"Parameters = ${nameData.parameters}")
println(s"Name = ${nameData.name.name}")
println(s"Bio = ${nameData.name.headlineBio}")

/* Get Artist Discography */
val discographyData = nameMetadata.getArtistDiscographyById("MN0000139026")
val discography = discographyData.discography(0)

println(s"Album Count=${discographyData.discography.size}")
println(s"AlbumId=${discography.ids.get("albumId").get}")
println(s"Title=${discography.title}")
println(s"Label=${discography.label}")

/* Get Album Info */
val albumData = albumMetadata.getAlbumById("MW0002772028")
val album = albumData.album

println(s"AlbumId = ${album.ids.get("albumId").get}")
println(s"Title = ${album.title}")
println(s"PrimaryArtist = ${album.primaryArtists(0).name}")

/* Get Album Tracks */
val tracksData = albumMetadata.getTracksById("MW0002772028")
val track = tracksData.tracks(0)

println(s"Track Count=${trackData.tracks.size}")
println(s"Ids = ${track.ids}")
println(s"Title = ${track.title}")