1 (edited by samuel337 2008-06-05 22:35:48)

Topic: How to get last.fm on chumby without another PC

Finally gotten my chumby this week, and haven't been able to put it down smile I got it first and foremost as a replacement for my alarm clock, so the first thing I looked for were the internet radio streams of my fave radio stations. They were all WMA streams of course, so no go. I tried cross-compiling bluetune, but the WMA decoder was missing in the source (in a special BlueTuneExtras package apparently), so that was no option.

So plan B was to get last.fm working, at least until chumby releases the chumby radio addon (which is probably based on this from the src). The only solutions I saw were ones that involved another PC, and that's just not green smile

Poked around a bit more, and the result is a last.fm player on the chumby itself that's supported by the chumby control panel. Ok, I'm getting ahead of myself here - right now, you can tune into the desired streams and listen to them, but that's about it.

To use it, download this (UPDATED to 0.2 - see below), and extract it on to your USB drive's root folder.

NOTE - if you already have a debugchumby file, this will overwrite it; backup and merge the debugchumby files manually. The same goes for profile.xml.

Now, assuming your USB drive is E:, go to E:\lastfmproxy-1.3b and open up config.py in a text editor. Fill in the gaps with your last.fm username and password and save.

Plug the USB drive into your chumby and reboot it.

Once it's done loading, go to the control panel, then to Music, then My Streams, and New.

To add global tag streams, use the following URL:
http://localhost:1881/globaltags/metal.m3u where metal is the global tag name (use %20 to represent spaces in tag names).

To add similar artists streams, use:
http://localhost:1881/artist/Evermore/similarartists.m3u where Evermore is the artist name (use %20 to represent spaces in artist names).

Essentially, its the lastfm:// url without the lastfm:// bit, http://localhost:1881/ added to the start, and .m3u tacked on the end.

Alternatively, you can use the URL http://localhost:1881/lastfm.m3u to play your last listened to artist/tag and control what gets played via the web interface, accessible on port 1881 (i.e. http://<chumby ip address>:1881/). See here for more info on how to control the player over the web interface.

Choose m3u as the type, save, and click play. If its configured properly, you should start hearing last.fm music in a few secs.

And because it comes through as a stream, you can use it as an alarm wakeup stream as well.

Couple of warnings - I have deliberately made the web interface accessible to the entire network, so I can see what it is playing on my computer. Because of that though, it is a security risk you should be wary of - change it if you want in the config.py file.

Technical stuff
This works using the lastfmproxy project, and duane's chumby python files. I've packaged them up into one file for convenience.

I was originally going to implement the lastfm stuff in C++, using the chumbyradio code as a base (just release the damn device already!), but then came across the python binaries and lastfmproxy, and didn't see the point in rewriting what had already been written smile Thanks to both projects - I really didn't do much apart from slap it all together.

what next?
Well, I'm considering writing a frontend for last.fm as a widget, so you can control it directly on the chumby. However, with talk of chumby working with last.fm on a solution, I'm not really hot on doing something that the chumby guys can do better because they have access to the control panel code. Any news on that front, chumbians?

Let me know if there are any issues/bugs.

UPDATE (06/06/2008): I've tidied up the python code, strengthened it for chumby-specific cases (e.g. the chumby has no shutdown process, so when writing files to /mnt/usb, they can get corrupted, so lastfmproxy has been updated to better handle corruption), fixed the web interface, and... wrote a flash widget for it!

Yeh, couldn't wait. The flash widget just displays the current song, and skip/love/ban buttons. Nothing fancy, but enough to make it usable.

The flash widget is included in the download link above.

The flash source is available here.

Re: How to get last.fm on chumby without another PC

Nice... works great!

You can just ssh in and kick off the lastfmproxy by running the debugchumby script.

One error - tuning the proxy streamer, you need to use URLs like this:

http://<chumbyip>:1881/changestation/lastfm://artist/<artistname>/similarartists

For example this works for me...

http://10.0.0.40:1881/changestation/las … larartists

Yay, it's the beatles.

Very cool wink

Re: How to get last.fm on chumby without another PC

schettj:

Hmm... the URLs I used in my original post work as well. I assumed the URLs you are using are for changing the station if your chumby is tuned into http://<chumby>:1881/lastfm.m3u. I guess not - thanks for the feedback!

Re: How to get last.fm on chumby without another PC

Yep, that's what I was doing (I like the control from the web)

Thanks for the update. Any chance the flash widget could let you pick from (at least some of) the saved stations?

Re: How to get last.fm on chumby without another PC

Hmm... it's possible. On the todo list smile

6 (edited by schettj 2008-06-11 05:27:24)

Re: How to get last.fm on chumby without another PC

Ok, been using this myself for a bit, and I may have to give up on having the lastfmproxy run on the chumby, python sucks too much ram for me, seems to make mr chumby unstable.

Edit: more info.

Normal Chumby, no lastfmproxy:
chumby:/mnt/usb# free
              total         used         free       shared      buffers
  Mem:        61928        42144        19784            0         6136
Swap:            0            0            0
Total:        61928        42144        19784

Running lastfmproxy:
chumby:/mnt/usb# free
              total         used         free       shared      buffers
  Mem:        61928        46500        15428            0         6176
Swap:            0            0            0
Total:        61928        46500        15428

Streaming:
chumby:/mnt/usb# free
              total         used         free       shared      buffers
  Mem:        61928        51240        10688            0         6204
Swap:            0            0            0
Total:        61928        51240        10688

Unfortunately, memory consumption continues to degrade over time. Maybe I should restart the server before each session?

I've found that it just freezes up sometimes after streaming quite a bit of music....

Re: How to get last.fm on chumby without another PC

Hmm... there could well be some kind of memory leak in the lastfmproxy code, or in python itself (unlikely I would think).

Could you try playing another type of mp3 stream (e.g. shoutcast, radio free chumby) just to make sure it isn't the chumby btplay or other chumby code?

Re: How to get last.fm on chumby without another PC

samuel337 wrote:

Hmm... there could well be some kind of memory leak in the lastfmproxy code, or in python itself (unlikely I would think).

Could you try playing another type of mp3 stream (e.g. shoutcast, radio free chumby) just to make sure it isn't the chumby btplay or other chumby code?

I'm not sure now if its just the normal last.fm issues (if you stream last.fm a lot, you know that sometimes it just sorta freezes up)

I've changed my script to stop the lastfmproxy when not in use, and to restart it when I want to stream... since doing that, it's been pretty stable even streaming for hours on end.

It does suck up a fair bit of what little memory there is, but not much you can do there.

Re: How to get last.fm on chumby without another PC

Python probably takes up 4 MB or so, accounting for the starting loss.

The rest of it may be the proxy, or the media player in chumby. My net's close to being capped at the moment, so no excessive last.fm usage for me, at least this month anyway.

I've tried memory profiling lastfmproxy, but python really has crappy tools for doing that - couldn't get it working such that I could monitor it while it was running. So there's not much I could do about that.

With your script, does it stop and restart automatically, or is it you using SSH? Maybe there's some kind of workaround I could use...

Re: How to get last.fm on chumby without another PC

Sorry for the delay getting back to you...

It's also the darn flash widgets - they take a variable about of memory, some suck up an impressive amount when they run...

It's been mostly stable - I had to restart the chumby after about 4 days of being up and streaming a fair bit of that time...

I have hacked the acceld.sh script found elsewhere here, so when you smack the chumby it starts the proxy and then kicks off the streaming... smack it again to stop streaming, and also stop the lastfmproxy. Love that smacking GUI wink Also added tilt forward/back for screen on/off - retained the tilt left/right for volume control.

I should post the updated script

Re: How to get last.fm on chumby without another PC

Hahaha... that's great. Probably the best use of that accelerometer in it so far smile

It's been fairly stable for me so far - got about 12 widgets running. Not much streaming though. Haven't had to restart it for a few weeks. Maybe there'll be improvements in later versions of the firmware/control panel.

I'd be interested in trying out the smacking GUI though.

12 (edited by schettj 2008-06-27 06:52:52)

Re: How to get last.fm on chumby without another PC

Hey, quick off-topic question... how/where are you getting the info from the lastfmproxy to display in your flash widget? I'm trying to find the current song info.

Edit... nevermind, found it:

http://localhost:1881/np

Re: How to get last.fm on chumby without another PC

Works great for me!  Before I was trying to do it with a SlimServer which I hated.  Now I no longer need to have
another PC running!  Thanks again!  You rock!

Re: How to get last.fm on chumby without another PC

beau travail
félicitation et merci
Fonctionne parfaitement en France aussi

Re: How to get last.fm on chumby without another PC

Got this working today. Excellent addition to the Chumby bag of tricks - big thanks to the op for hooking it up!

Re: How to get last.fm on chumby without another PC

I've done a "now playing" widget and don't work in chumby, i'll try your hack..

17 (edited by bjarkebech 2008-11-21 15:51:19)

Re: How to get last.fm on chumby without another PC

Wow. What a fantastic guide, and great app. Exactly what i needed for my Chumby.
I've made my own new GUI, that you can grab if you want, just putting it out here so others can enjoy it too.

It's a simple iPhonesque clock, that kicks into Last.fm song viewing mode if playing a station.
Still based on the original code, but i added a night mode toggle, as i primarily use this as my alarm clock, so i need it to act as a black clock when i sleep. The only way i could get that working was if i modded the main.py file, which is available at http://bjarkebech.com/etc/main.py

Just replace that with the main.py file you have, and you should be up and running.

Oh, and here are some screenshots:
http://bjarkebech.com/etc/img/clockWhite.jpeg http://bjarkebech.com/etc/img/clockBlack.jpeg
http://bjarkebech.com/etc/img/lastFmWhite.jpeg http://bjarkebech.com/etc/img/lastFmBlack.jpeg

24h only for now, if there are any requests for 12h, then i'll probably make one eventually smile

Source .fla file available at: http://bjarkebech.com/etc/lastfmBjarke.fla

Grab it here: http://bjarkebech.com/etc/lastfm.swf

Thanks to samuel337 for making my chumby perfect smile

Feel free to comment, this is version 1 after all smile

Re: How to get last.fm on chumby without another PC

Sorry, me no speak techie. sad

Any chance this will ever see life as a dummie-proof widget?

Re: How to get last.fm on chumby without another PC

Very nice bjarkebech. How does it alternate between the clock and the last.fm screen?

I would try it out, but my chumby's not in a happy state in regards to wireless connections. And I'm stuck because switching it on to WPA only means the clock slows for some reason.

froyd:
It shouldn't be that hard - download, extract on to a USB drive, insert your last.fm details, and away you go. I'm not sure if you'll ever see it in-built, given chumby has added support for Pandora, a last.fm alternative. We can wish though, but in the mean time, if you get stuck, I'll see if I can help.

20 (edited by bjarkebech 2008-11-26 14:10:06)

Re: How to get last.fm on chumby without another PC

samuel337 wrote:

Very nice bjarkebech. How does it alternate between the clock and the last.fm screen?

I would try it out, but my chumby's not in a happy state in regards to wireless connections. And I'm stuck because switching it on to WPA only means the clock slows for some reason.

froyd:
It shouldn't be that hard - download, extract on to a USB drive, insert your last.fm details, and away you go. I'm not sure if you'll ever see it in-built, given chumby has added support for Pandora, a last.fm alternative. We can wish though, but in the mean time, if you get stuck, I'll see if I can help.

The way it alternates is it uses the timer movieClip that was in your .fla, and just uses the enable/disable_buttons function with a whole lot more commands:

function disable_buttons()
{
    trace("disabling buttons");
    this.btn_container._visible = false;
    this.cur_artist._visible = false;
    this.cur_title._visible = false;
    this.cur_album._visible = false;
    this.clock._visible = false;
    this.bigClock._visible = true;
}
function enable_buttons()
{
    trace("enabling buttons");
    this.btn_container._visible = true;
    this.cur_artist._visible = true;
    this.cur_title._visible = true;
    this.cur_album._visible = true;
    this.clock._visible = true;
    this.bigClock._visible = false;
}

Take a look in the .fla if you're interested smile

I also fixed the lagging problem by killing and relaunching the process every 24 hours via crontabs.

21 (edited by velkrosmaak 2008-12-10 11:22:56)

Re: How to get last.fm on chumby without another PC

To the original poster / creator - Wow, awesomeness! Thank you so much!

Edit: Actually; a quick question. Say I wanted to copy the files from my USB stick so I could have Last.fm running constantly whilst still being able to use my memory stick. Where would one copy these files? Would you suggest doing this over SSH?

22 (edited by samuel337 2008-12-10 21:06:57)

Re: How to get last.fm on chumby without another PC

velkrosmaak wrote:

Actually; a quick question. Say I wanted to copy the files from my USB stick so I could have Last.fm running constantly whilst still being able to use my memory stick. Where would one copy these files? Would you suggest doing this over SSH?

Are you saying you want to share the memory stick between the chumby and your computer? You can't do that - the chumby needs its own USB stick connected to it for this (and any other chumby hack) to work. I'd suggest just going out and getting a tiny 128MB USB stick for it - they're so cheap anyway.

If you're really curious, you might be able to copy the files to the chumby's in-memory file system, and start the lastfmproxy manually - not sure about the space available. Not something I've tried though.

Re: How to get last.fm on chumby without another PC

The last.fm proxy has recently stopped working for me, anyone else having this problem?

Re: How to get last.fm on chumby without another PC

Arachnid wrote:

The last.fm proxy has recently stopped working for me, anyone else having this problem?

Just tested it - works for me. Maybe it was periodic thing and last.fm was down? I haven't been using it much lately, so haven't noticed any downtime.

Re: How to get last.fm on chumby without another PC

@Arachnid: The reason LastFMProxy not be working for you might be because since the new 1.7 firmware, the chumby has switched toolchains, which means that python (which lastfmproxy is written in) needs to be recompiled using the new toolchain. I don't have a linux box to do that on at the moment, so I'm hoping someone will make a new build of python for 1.7.