I had another issue with my Last.fm module the other day, which is why it's currently turned off. I think it happens if the Last.fm feeds are unavailable; causing the module's HTTP requests to time out; which in turn causes the whole of Drupal to time out as it waits for the response; which means my whole site falls over.
I've been using the drupal_http_request() function to run my HTTP requests, but unfortunately you can't adjust its timeout setting. So I dug around in that code, and have submitted a feature request and patch which enables you to customise the timeout when using this function. I then rewrote my module with shorter timeouts when making requests to Last.fm, which seems to do the trick.
Hopefully, if this patch makes it into Drupal, I will be able to release the new version of my module, complete with timeouts, so it won't cripple my site or anyone else's. It also adds a Last.fm recent tracks listing to user profiles (if they've set up their username) and has a block (only for one user - I just put it in for myself, really). It still needs a bit of work, and only handles recent tracks, but it's coming along fine.
Comments
Nice Article!!
I must update that i have dropped my website. it was just becoming too much of a pain. almost a week of dealing with my last host, backing everything up, transferring, encountering this issue, and other little things, seems a bit of a waste of time for me. i loves drupal and everything it does, but it really sucked up a lot of time this week. instead, i'm going to use other sites which host photos and blogs, this way i can really concentrate on photos and material instead of database issues and php memory.
Commenters below, this
Commenters below, this plugin has been out for sometime on Drupal! (since Drupal 5).
If you could get this data,
If you could get this data, think of all the reports you could extrapolate from the playlists - most listened to bands from visitors to your site, most listened to songs etc.
Would be cool if this patch
Would be cool if this patch can be introduced to Drupal. I've discovered so much new music form other people's playlists.
Any progress on this?
Very interested in finding out whether theres been any progress on this? Had the patch made it onto drupal? Thanks
I think something similar is
I think something similar is being considered for Drupal 7.
Drupal is working on a major
Drupal is working on a major update soon, so maybe will be fixed then. For the time being I will use your module.
Thanks for the work. Also I couldn't install the module from the reply method.
Locke.
Content management
Would be nice if it could be
Would be nice if it could be fixed. I've handed the module over to someone else now, but hopefully they'll benefit from the fix.
an official last.fm module
A lot of people are interested in a last.fm module. So I think it's a good idea to host your work on drupal.org. It will be easier for people to find it and watch the evolution of the project. If you already posted it on drupal.org, please send me the link.
Thanks and keep up the good work!
Bugfix revision 0.6 of Brian's code.
...is here: http://bria.nwood.org/system/files/lastfmdev5.x-0.6.tar.gz
BUG: If click Save Configuration on the admin form you will get a blank page...
Fixed. Silly... My debugging output was thwarting the header() in includes/common.inc line 311. I have implemented simple debugging output in the bottom of the block for developer convenience.
BUG: Track times: They are probably incorrect for you.
Fixed. _lastfmdev_adjust_server_time() now calculates the offset between the Last.fm server's timezone and the date_default_timezone set in the Drupal installation.
Since it is possible that Last.fm could decide to host this service on servers in another timezone, the module's Admin Settings now includes a timezone select menu to change the Last.fm server timezone. The default is the server's present location (USA Eastern Time).
BUG: Updated timestamp (showing the "freshness" of the Last.fm data) was poorly implemented.
Fixed. Now using format_date($update_timestamp, 'small')
Fixed. $table was not set for db_lock(). Presently hard-coded to 'cache' - probably should be flexible.
Do a diff against the old file (lastfmdev.tgz) to see other minor stuff. I will use revision numbers going forward.
Hi Brian. As I currently
Hi Brian. As I currently don't have too much time to work on this, would you be interested in becoming its custodian? If you want to maintain the project, I'd be happy with a quick mention as one of the originators of the code. The licence was never mentioned (I don't think), but I'd be happy with the GPL. It would be good to get it onto the official Drupal CVS server if you're so inclined.
Sure
I'll see if I can get it into drupal's cvs.
Could you send me the most recent version of your code. It sounds like you've implemented some good features that I don't have.
By all means I'll list you in the credits. Email me your full name and any other info you'd like in there. GPL is fine.
It may take me two weeks to get to this, but I'll follow through.
I've been working with your code
Hi Elliot,
I've been playing with your code for a few weeks. Since I see that you are working on it again, I wanted to make my modifications available to you... I had this dream of squashing all the bugs and sharing some pristine code with you, but here's an alpha version so you can see what I've done. If you would like to work together on this, let's talk. Here's the status:
Implemented:
Bugs:
Ideas/Plans:
Installation:
I renamed "lastfm" to "lastfmdev" so that this module could be installed along side your file-based-caching version. Right now I have your file-based block available to all users and this dev block available only to the administrator.
(You'll notice some broken stuff on my site. Style sheets broken in IE. Some images need to be fixed too.)
Hope this work and dreaming is helpful. I'll probably have some time to get back to this on the weekend.
Brian, that looks very
Brian, that looks very interesting. As I'm in the throes of rewriting it (again), would it be OK if I folded your changes into what I've been doing? I particularly like how you've done caching: I'd been using it, but my approach was less elegant by far. The other thing I want to do is make it possible to retrieve data from other parts of the API, so I want to refactor the code (e.g. to give _lastfm_fetch(), _lastfm_parse(), _lastfm_render(), _lastfm_cache() functions). I've also changed my approach slightly, so that I'm using theming properly for HTML generation, and am showing Last.fm recent tracks on a person's profile (which requires a new database table), as well as providing a block to do the recent tracks for a particular individual.
But I could definitely do with some help, and also liked the idea of being able to show the time when the track was played. As mentioned in my blog entry, my main issue is with timeouts wrecking my site: so I may redo the fetch functionality to use raw sockets rather than drupal_http_request() (which I'm using currently) or CURL; and I may redo the parser to use the Drupal approach, compatible with PHP 4 (the DOM stuff isn't). I'm quite enjoying messing with it at the moment, as you can probably tell :) Someone else suggested committing it to the Drupal project properly and getting it into CVS, which would perhaps be a good idea now there's some interest.
Yes, the cron thing. I never particularly liked the idea of Drupal cron. Seems a bit nasty, though I suppose it's essential. I guess my thought was that the data might need to be updated more frequently than cron to be relevant (if you have long gaps between cron calls). Perhaps an option to use cron would be useful, though I think it's over-complicated for now.
So, to summarise my rambling, I'd be happy to collaborate, but at the moment I feel I need to rewrite the core properly so I can use it across the whole Last.fm API, and want to sort out this HTTP business too.
What is the status of this
Hello, I am keen to see some files, but nothing is available. Can you fill me in on the status of this project as it sounds great. I am more than happy to lend some code time as well if necessary.
Use the activity stream module
http://drupal.org/project/activitystream
Hello again Brian. Thanks
Hello again Brian. Thanks for pointing that out to me: I hadn't come across it before.
Alternative to Activity Stream
And I just came accross this:
http://drupal.org/project/lastfm
Excellent!
By all means. Incorporate any of my code that you like. I'd be really happy if my efforts help to push this along.
Yeah lets get this into CVS so that we can get the latest versions of each other's work. Or if you're pressed for time, email me your latest code and I'll try to get it in there.
I'd be excited about collaborating...we can divide and conquor on some of the features... I've can also test on XP/Ubuntu Feisty/MacOS 10.4 and corresponding browsers. I'll try to watch here, but feel free to email me directly too.
testing
I don't think you need to do rigorous testing for any new release/plug-in from Drupal. Most of these improvements are platform and browser-independent. What you need to test against is security...
Site5
Hey, I happen to be on Site5 too. Just noticed the sidebar ad.