Stellar Attraction Discussion Forum
https://www.stellar-attraction.com/cgi-bin/yabb2/YaBB.pl
Site Information >> Ask The Admin >> Scrobbling to last.fm
https://www.stellar-attraction.com/cgi-bin/yabb2/YaBB.pl?num=1235692919

Message started by m_gol on 27th Feb, 2009 at 12:01am

Title: Scrobbling to last.fm
Post by m_gol on 27th Feb, 2009 at 12:01am
Hi!

Is there any way to scrobble names of songs listened in S.A. to last.fm? I use Amarok 1.4 under Ubuntu 8.04 (Linux) - it has an included mechanism to scrobble songs to last.fm, but it doesn't work for radio stations like S.A.

Title: Re: Scrobbling to last.fm
Post by ProgMaster on 28th Feb, 2009 at 5:15pm
Hi Michał,

I have to confess, I've no idea ... I'll look into this though as I appeciate that last.fm is proving to be increasingly popular these days.

D

Title: Re: Scrobbling to last.fm
Post by fdmartin on 11th Aug, 2009 at 4:01pm
I've coded a little Python script for this, I hope it's useful:

Code:
import urllib

def scrobble(new_song):
    artist, song = new_song.split(' - ',1)
    params = urllib.urlencode({'submissionType':'track','username':'XXXX', 'password':'XXXXX', 'artist':artist, 'album':'', 'track':song, 'number':1, 'duration':200})
    site = urllib.urlopen('http://lastfmstats.livefrombmore.com/universalscrobbler/scrobble.php?',params)
    site.close()

if __name__ == '__main__':
    while True:
        raw_input()
        site = urllib.urlopen('http://www.stellar-attraction.com/playing.php')
        site_contents = site.read()
        start_index = site_contents.index('href="http://s1.viastreaming.net:7170/listen.pls">')+50
        new_song = site_contents[start_index:site_contents.index('</a>',start_index)]
        print 'Scrobbled %s'%(new_song)
        scrobble(new_song)
        site.close()


It uses the Universal Scrobbler Site (http://lastfmstats.livefrombmore.com/universalscrobbler/) to manually scrobble the tracks.
You have to replace the XXXXs with username and password. That's it.

Title: Re: Scrobbling to last.fm
Post by ProgMaster on 11th Aug, 2009 at 6:59pm
Wow - a Python coder - very impressive stuff !! 8-)

Welcome to S.A. fdmartin. :)

Title: Re: Scrobbling to last.fm
Post by huntr_22 on 11th Aug, 2009 at 7:08pm
Welcome to SA fdmartin! :)

Title: Re: Scrobbling to last.fm
Post by fdmartin on 11th Aug, 2009 at 7:19pm
Haha, you're welcome. Thanks for the attention, and I hope the script is useful to all of you. I found the station recently and it's great! Thank you for this fantastic station.

Title: Re: Scrobbling to last.fm
Post by ProgMaster on 11th Aug, 2009 at 7:25pm
No problem, fdmartin. Glad that you were tuned-in to hear the 'shout-out'.

Thanks again for the script. 8-)

Title: Re: Scrobbling to last.fm
Post by m_gol on 11th Aug, 2009 at 7:32pm
I'm a bit afraid of how it deals with some texts that are displayed in SA title field apart from song names - sth like "You're not allowed to record..." etc.

What should I expect?

Title: Re: Scrobbling to last.fm
Post by ProgMaster on 11th Aug, 2009 at 7:40pm

m_gol wrote on 11th Aug, 2009 at 7:32pm:
I'm a bit afraid of how it deals with some texts that are displayed in SA title field apart from song names - sth like "You're not allowed to record..." etc.

What should I expect?


Looking at this script at face-value (and not being familiar with Python at all ...) I don't think that this should be a problem, m_gol. It appears to be opening the site / song information from the playing.php script which itself doesn't display any of the (very occasional ...) messages. Basically, the occasional 'message' is only displayed in the listener's media player and never on the S.A. website. Although, I'm sure that fdmartin will be able to provide a full answer.

PS The 'You're not allowed to record ...' message has been removed. ;)

Title: Re: Scrobbling to last.fm
Post by fdmartin on 11th Aug, 2009 at 7:59pm
I've taken that into account when coding the script, so the song names are taken from the playing.php script, as ProgMaster said. Also notice scrobbles are done manually: you have to press enter in order to get the song scrobbled. I thought it would be more comfortable to do it automatically, but that would mean refreshing the site a considerable amount of times a minute, and I didn't want to put pressure (although low) on the server. After all, it's just pushing a button after the song ends.
Here's a screenshot of the script working:

Title: Re: Scrobbling to last.fm
Post by ProgMaster on 11th Aug, 2009 at 8:44pm
Thanks for the update, fdmartin. It certainly looks impressive. 8-)

Title: Re: Scrobbling to last.fm
Post by Yes Phreak on 11th Aug, 2009 at 9:30pm
welcome to SA martin. [smiley=thumbsup.gif]

Title: Re: Scrobbling to last.fm
Post by matejn on 25th Jan, 2010 at 11:35am
Hello, I'm sorry for this question but I would like to know where should I copy this code to make it work..  :-[

Title: Re: Scrobbling to last.fm
Post by ProgMaster on 25th Jan, 2010 at 7:15pm

matejn wrote on 25th Jan, 2010 at 11:35am:
Hello, I'm sorry for this question but I would like to know where should I copy this code to make it work..  :-[


Hi there matejn and welcome to S.A. !!

This script will have to be run on a PC, Server etc. that has a Python interpreter. Again, I haven't used Python at all myself, however, doing a quick Google search it returned a few results as to how to run Python scripts on a Windows PC (I'm sure most *Nix flavours will inherently have Python bundled with them).

http://www.python.org/doc/faq/windows/

http://docs.python.org/using/windows.html

Title: Re: Scrobbling to last.fm
Post by matejn on 25th Jan, 2010 at 9:38pm
thanks a lot:)

Title: Re: Scrobbling to last.fm
Post by ProgMaster on 25th Jan, 2010 at 9:44pm
No problem, matejn. :)

Title: Re: Scrobbling to last.fm
Post by Macros the Black on 26th Jan, 2010 at 7:29pm
Intresting will look at it later ....

Stellar Attraction Discussion Forum » Powered by YaBB 2.5 AE!
YaBB Forum Software © 2000-2010. All Rights Reserved.