diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-08-06 04:22:19 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-08-06 04:22:19 +0000 |
commit | fe077220bf08ac7ad466e6fdfe88197c6d4ed56e (patch) | |
tree | 1e8d8eab876246fc57a1e6c414fe763570690bf6 /lib/class/metadata.class.php | |
parent | add90bc902ce762626fe72d408f42d705d3f9de7 (diff) | |
download | ampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.tar.gz ampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.tar.bz2 ampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.zip |
broke a ton of stuff, but added some hotness... yes that is an excuse
Diffstat (limited to 'lib/class/metadata.class.php')
-rw-r--r-- | lib/class/metadata.class.php | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/class/metadata.class.php b/lib/class/metadata.class.php index 01db6072..f5e80626 100644 --- a/lib/class/metadata.class.php +++ b/lib/class/metadata.class.php @@ -33,12 +33,49 @@ class metadata { * constructor * We don't use this, as its really a static class */ - private __construct() { + private function __construct() { // Rien a faire } // constructor + /** + * recommend_similar + * This takes the input and returns an array of objects construct_from_array()'d + */ + public static function recommend_similar($type,$id,$limit='') { + + // For now it's only mystrands + OpenStrands::set_auth_token(Config::get('mystrands_developer_key')); + $openstrands = new OpenStrands($GLOBALS['user']->prefs['mystrands_user'],$GLOBALS['user']->prefs['mystrands_pass']); + + // Make sure auth worked + if (!$openstrands) { return false; } + + switch ($type) { + case 'artist': + $artist = new Artist($id); + $seed = array('name'=>array($artist->name)); + $results = $openstrands->recommend_artists($seed,$limit); + break; + } + + foreach ($results as $item) { + switch ($type) { + case 'artist': + $data['name'] = $item['ArtistName']; + $data['uid'] = $item['__attributes']['ArtistID']; + $data['mystrands_url'] = $item['URI']; + $data['links'] = "<a target=\"_blank\" href=\"" . $item['URI'] . "\">" . get_user_icon('mystrands','','MyStrands Link') . "</a>"; + $objects[] = Artist::construct_from_array($data); + break; + } // end switch on type + } // end foreach + + return $objects; + + } // recommend_similar + } // metadata ?> |