forum

What's your power level on Last.fm?

posted
Total Posts
45
show more
Mianki


You'll have to be active so the level rises up? And if you're not, the level goes down?
eru


orz
IppE

Mashley wrote:

Yes it is.
No Mashley, you are the hobos
dkun

Mianki wrote:



You'll have to be active so the level rises up? And if you're not, the level goes down?
well, I have some inactivity time between my plays, so...
Corin
Inb4 over 9000
dNextGen
KRZY
Link tells me to install a certain WhiteSmoke and iLivid. Am I doing it right?
Athyrionjh
No one's OVER 9000!! ?
I'm disappointed from you guys :D
dkun

Athyrionjh wrote:

No one's OVER 9000!! ?
I'm disappointed from you guys :D
well my play count on last.fm is over 9000
:(
Topic Starter
bagnz0r

Mianki wrote:



You'll have to be active so the level rises up? And if you're not, the level goes down?
Nah, once you hit a level - you have it. Just like that.
More active on Last.fm you are, your level gets higher and higher.

Anyway... Code. Kohana Framework 3.0. Will work under sl33k though.
<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Lastfm extends Controller_Core {

// Model for fetching and processing data
protected $model;

// Actions
public function action_index()
{
// Spawn model
$this->model = new Model_Lastfm();

// See if we have username.
// If not, output the default view.
if ($this->model->username == null)
{
$this->template->title = 'Last.fm Labs';
$this->template->content = View::factory('lastfm/main');
}
else
{
// Cookin'!
$data = $this->cook();

// Output stuff in the view
$this->template->title = 'Last.fm Labs - '.$this->model->username;
$this->template->content = View::factory('lastfm/magic')->bind('level', $data)->bind('username', $this->model->username);
}
}

// Method stubs
private function cook()
{
// Get the cooked data!
$level = $this->model->parse_and_cook();
return $level;
}

<?php defined('SYSPATH') or die('No direct script access.');

class Model_Lastfm extends Model {

// Just username, no?
public $username = null;

// API key
protected $key = 'nope.avi';

// Constructor
public function __construct()
{
if (!isset($_POST['username'])) $this->username = null;
else $this->username = Enforcer::clean_str($_POST['username']);
}

// Cookin'!
public function parse_and_cook()
{
// First, see what is the overall user playcount
$playcount = $this->api_call('user.getInfo')->user->playcount;

// Now see how much loved tracks does he have
$loved = $this->api_call('user.getLovedTracks')->lovedtracks->track; $lovedcount = count($loved);

// Now get friends
$friends = $this->api_call('user.getFriends')->friends->user; $friendcount = count($friends);

// Cook data
$level = (($playcount + $loved + $friends) / 3) / 600;
if ($level < 1) $level = 1; if ($level > 99) $level = 99;

// Return stuff!
return round($level);
}

// Last.fm API call
private function api_call($method)
{
// Try to perform an API call and throw an exception if status is not "ok".
try
{
// Get a document from cache or new one
$fp = file_get_contents('http://ws.audioscrobbler.com/2.0/?method='.$method.'&user='.$this->username.'&api_key='.$this->key);

// Parse
$xml = new SimpleXMLElement($fp);
if ($xml->lfm['status'] == "ok") throw new Exception('Last.fm API failure'); else return $xml;
}
catch (Exception $e)
{
Sleek_ExceptionControl::exception($e->getMessage());
}
}
}

Views are simple to figure out yourselves.
dNextGen

KRZY wrote:

Link tells me to install a certain WhiteSmoke and iLivid. Am I doing it right?
nope
gat1toneku
intermu


I thought for a moment I was the highest here. Then I saw the previous page.
dkun

intermu wrote:



I thought for a moment I was the highest here. Then I saw the previous page.
\:D/
Topic Starter
bagnz0r
Updated some stuff.
Now for leveling up, you can gain ranks. :V
So, regenerate your images now.

http://adf.ly/1SNrw
dkun

wel then^2
Topic Starter
bagnz0r

dkun wrote:


wel then^2
Highest level so far, trololol.
Galkan


...what the shit ;f
Vext_old
Weeee



Does it factor in scrobbling from my phone? (while not actually using last.fm but rather last.fm showing what I am listening to.)
Powerdrone


hai.
boat


should have added 8999 ranks due to my nickname

it amazes me that they haven't banned me for racism yet
Topic Starter
bagnz0r
Service got updated. Check it out again.
intermu
Topic Starter
bagnz0r
You might want to check this out and regenerate your images to add stats to the database.
http://z0r.pl/lastfm/level/ranks
senaya


i blame osu! because look at my friend who doesn't play osu:



damn =\
Galkan
Mastah

With avg. level of: 30.3333333333

Shorten it, please :-P
Topic Starter
bagnz0r
dkun
that jrpgfan guy is just whahahahtahthathwhahwaht qq
Topic Starter
bagnz0r
I've fucked the DB up, therefore regenerate your images please.
HeadHunterX
Please sign in to reply.

New reply