Shoutbox

[REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed (/showthread.php?tid=81594)

[REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed by webbo04 on 02-11-2008 at 04:17 PM

Hey All,

I found this which is basically a rss feed of what BBC Radio 1 Is Now Playing! All I want is this on my PM. Before you ask/say I've already tried the RSSreader but it takes AGES to phase and eventually i have to cancel. Anybody help?

All I'd want it to do is say

Radio 1 Is Now Playing: [LATEST RSS ITEM HERE]

Thanks!

EDIT: Updated To A Better RSS Feed


RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed by Spunky on 02-11-2008 at 04:29 PM

The last update is 20 minutes behind :s Might have abash after jobs though


RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed by webbo04 on 02-11-2008 at 04:35 PM

Yeah, I'll try and find a better feed!

EDIT: Here's A Better One


RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed by MeEtc on 02-11-2008 at 05:06 PM

They're the same feed, as far as I can see


RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed by Stigmata on 02-11-2008 at 06:07 PM

the rss feed seems to be an hour behind...

I dont think it would be worth it honestly :/


RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed by Spunky on 02-11-2008 at 06:32 PM

http://www.bbc.co.uk/radio1/wm_asx/aod/radio1.asx

Use that link to play it in WMP and see if the artist/song show up in your PSM through the built in WLM function :p


RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed by matty on 02-11-2008 at 06:38 PM

code:
/*
*
*    BBC song from RSS
*    matty
*
*/

var sPsm;

function OnEvent_Initialize() {
    if (Messenger.MyStatus < STATUS_INVISIBLE) return false;
    MsgPlus.AddTimer('grabSong', 60000); // one minute
}


function createXml(url) {
    Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', url);
    xml = new ActiveXObject('Microsoft.XMLDOM');
    xml.async = true;
   
    xml.load(url);
    return xml;
}

function OnEvent_Timer() {
    var xml = createXml('http://bbc-hackday.dyndns.org/tracks/radio1.rss');
   
    xml.onreadystatechange=function() {
        if (xml.readyState === 4)
            var newPsm = xml.selectSingleNode('//rss/channel/item/dc:creator').text+' - '+xml.selectSingleNode('//rss/channel/item/dc:title').text;
            Debug.Trace(newPsm);
            if (sPsm !== newPsm) {
                Messenger.MyPersonalMessage = newPsm;
                sPsm = newPsm;
            }
        xml = null;
    }
    MsgPlus.AddTimer('grabSong', 60000); // one minute
}

RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed by webbo04 on 02-11-2008 at 07:06 PM

Oh Great!

How Do I Put Radio 1 Playing: infront of it?


RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed by matty on 02-11-2008 at 07:40 PM

quote:
Originally posted by matty
var newPsm = 'Radio 1 Playing: '+xml.selectSingleNode('//rss/channel/item/dc:creator').text+' - '+xml.selectSingleNode('//rss/channel/item/dc:title').text;

RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed by Matti on 02-11-2008 at 08:32 PM

Matty, you should be aware that you have to declare your onreadystatechange event BEFORE you call xml.load(). So, either you simply place the contents of the createXml function in the timer event, or you add the callback function as a parameter to the createXml function and assign it to onreadystatechange in the createXml function.

I already explained this in Mattike's reply to XMLHTTP Not Loading After Save. The thing is that if you declare it after the load() function, there's a (small) chance that the asynchronous XML loading is faster than the process of the script.

code:
...

function createXml(url, funcReadyStateChange) {
    Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', url);
    xml = new ActiveXObject('Microsoft.XMLDOM');
    xml.async = true;
    xml.onreadystatechange = funcReadyStateChange;
   
    xml.load(url);
    return xml;
}

function OnEvent_Timer() {
    var xml = createXml('http://bbc-hackday.dyndns.org/tracks/radio1.rss', function() {
        if (xml.readyState === 4)
            var newPsm = xml.selectSingleNode('//rss/channel/item/dc:creator').text+' - '+xml.selectSingleNode('//rss/channel/item/dc:title').text;
            Debug.Trace(newPsm);
            if (sPsm !== newPsm) {
                Messenger.MyPersonalMessage = newPsm;
                sPsm = newPsm;
            }
        xml = null;
    });

    MsgPlus.AddTimer('grabSong', 60000); // one minute
}
Also, I don't really know for the XMLDOM but I think you should also check the xml.status to see if it equals 200 (xml.status === 200) in the event. I don't really know if it functions like the XMLHTTP, but the xml.readyState documentation says:
quote:
Originally posted by DevGuru XML DOM :: readyState
  • ...
  • COMPLETED(4)
    the document has been completely loaded, successfully or unsuccessfully.