forum

What's your power level on Last.fm?

posted
Total Posts
45
Topic Starter
bagnz0r
I've been bored recently (yes, again) - so I've added a small section on my "uber amazing site" - Last.fm labs.
To be more precise, I've added plugin support in CMS (or rather blog script) of mine - and so, more things are now possible the easier way.
So uh yeah, post your level badges here.

Site:
http://z0r.pl/lastfm

Mine:
silmarilen


awsum

how does it work?
Topic Starter
bagnz0r

silmarilen wrote:



awsum

how does it work?
Site says everything.
It's picking up certain stats from your profile, counting stuff, producing averages and dividing by certain number.
Well, more to come. I have lots of more cool Last.fm related things scheduled.
OzzyOzrock
...what happens when someone manages to go past 9000?
dkun

well then
Topic Starter
bagnz0r

OzzyOzrock wrote:

...what happens when someone manages to go past 9000?
I didn't think about it... But I don't think that'll happen.

	public function parse_and_cook()
{
// Some api calls


// Cook data
$level = formula here;
if ($level < 1) $level = 1; if ($level > 99) $level = 99;

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

Fixed. You can't go above level 99 now.
OzzyOzrock
Topic Starter
bagnz0r

OzzyOzrock wrote:

Sure you aren't the guy that would go past 9000, haha.
silmarilen

bagnz0r wrote:

OzzyOzrock wrote:

Sure you aren't the guy that would go past 9000, haha.

who knows. goku was all tough when he went past 9000 and a couple of sagas later hes at 500mil.
IppE


bleh
NotShinta


Fair enough.
Mashley
Last.fm is for hobos
Topic Starter
bagnz0r

Mashley wrote:

Last.fm is for hobos
No it's not.
Backfire


I am the champion.
Mashley

bagnz0r wrote:

Mashley wrote:

Last.fm is for hobos
No it's not.
Yes it is.
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