++ibanix, nice script!
Having recently had the opportunity to work with LJ::Simple, and being a fellow LJer myself, I enjoyed the timeliness of this post. Since LJ has the option for "Current Music" with every post, I thought of another way you could implement it, which might also solve the slow update problem.
Instead of posting a new entry with just your current musical selection, what if you modified the "Current Music" value of the most recent entry, keeping it current with whatever you are listening to? You could use the GetEntries() method with a $type of "one". Since the script is running continuously, you could store the $item_id and original "Current Music" value (which you entered manually when you first made the post), and if it detects a new post (the $item_id stored no longer matches the most recent post), it can reset the old post to the original music setting, store the new $item_id and current music, and off you go.
... After writing the first half of this post, I decided to go play with LJ::Simple for a bit and see if I could do what I was proposing. It turns out that the code I had in mind...
my $entries = {}; $lj->GetEntries($entries, undef, 'one', -1); for my $item_id (keys %{$entries}) { $lj->Setprop_current_music($entries->{$item_id}, $music); $lj->PostEntry($entries->{$item_id}); }
...doesn't work. Apparently the hash returned by GetEntries isn't compatible with PostEntry. It looks like instead you'd have to copy all the properties from the GetEntries hash into a new entry and post that after deleting the old one. This, of course, no longer solves the problem of a delay between deleting and reposting. It even introduces a more significant issue, since the post you're deleting is an actual entry, instead of just the current music. I'm sure it can be done, and I'd like to play with it some more, but it's getting late and I've got to work in the morning. Thanks again for the great idea, this happened to be very on-topic for me at the moment. :)
In reply to Re: Re: Winamp -> LiveJournal
by Bird
in thread Winamp -> LiveJournal
by ibanix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |