++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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.