Skip to content

Instantly share code, notes, and snippets.

@OleTraveler
Created April 30, 2011 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OleTraveler/950073 to your computer and use it in GitHub Desktop.
Save OleTraveler/950073 to your computer and use it in GitHub Desktop.
/*
* Created by IntelliJ IDEA.
* User: tstevens
* Date: 4/30/11
* Time: 3:50 PM
*/
package com.oletraveler.bmapz
import xml.{NodeSeq, Elem}
case class User
case class Band(name: String, owner: User, pages: List[Page])
trait Page {
def url: String
def songs: List[Song]
}
sealed trait Song {
def name: String
def htmlEmbed: NodeSeq
}
trait DirectMp3 {
def url: String
def htmlEmbed = <div><a href={url}>Download</a></div>
}
case class HomePageDirect(name: String, url: String) extends DirectMp3
case class HomePage(url:String, songs: List[Song]) extends Page
case class Myspace(path: String, songs: List[Song]) extends Page {
val url = "http://www.myspace.com"
}
case class MyspaceSong(name: String, songId: String) extends Song {
def htmlEmbed = {
val albumLink = "http://www.myspace.com/mutton/music/albums?ap=1&songid=" + songId
<div><embed style="display:inline;" quality="high" wmode="transparent" id="FlashDiv"
FlashVars="songId={songId}&amp;pid=5089392930409755761" AllowScriptAccess='always'
src="http://www.myspace.com/music/song-embed?songid={songId}&amp;getSwf=true"
width='400' height='77'/>
<p>Find more artists like
<a target="_blank" href="{albumLink}">{name}</a> at
<a target='_blank' href='http://www.myspace.com/music'> Myspace Music </a></p>
</div>
}
}
case class SoundCloud(userName: String, songs: List[Song]) extends Page {
val url = "http://www.soundcloud.com"
}
case class SoundCloudSong(name: String, userName: String, songId: String) extends Song {
def htmlEmbed = {
<object height="81" width="100%">
<param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F{songId}"></param>
<param name="allowscriptaccess" value="always"></param>
<embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F{songId}" type="application/x-shockwave-flash" width="100%"></embed>
</object>
<span><a href="http://soundcloud.com/travispunch/006-blury-picture-n">006-blury picture-n</a> by <a href="http://soundcloud.com/travispunch">{userName}</a></span>
}
}
trait Search[T <: Page] {
def search(band: Band) : List[T]
}
class MySpaceSearch extends Search[Myspace] {
def search(band: Band) : List[Myspace] = {
List.empty
}
}
class GoogleSearch extends Search[HomePage] {
def search(band: Band) : List[HomePage] = {
List.empty
}
}
class SoundCloudSearch extends Search[SoundCloud] {
val clientId = "123"
def queryString(band: Band) = "http://api.soundcloud.com/users.json?client_id=" + clientId + "&q=" + band.name + "&limit=25"
def doSearch(restUrl: String)
def parseResult(jsonString: String) = {
}
def search(band: Band) : List[SoundCloud] = {
List.empty
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment