jakeuk
Posts: 24
Joined: Thu Feb 21, 2008 5:56 pm

Postby jakeuk » Wed Nov 14, 2012 2:53 pm

Could somebody give a layman a little help here. I'm not particularly technically minded so apologies for not knowing something that is probably a breeze to do (here's hoping).

I am trying to get a regular update from an XML page that is from a radio station that I'm involved in. This is so I can get a regular listener count.

The XML that displays reads as follows:

<DATA>
<STREAMINGPLAYERS>8800</STREAMINGPLAYERS>
</DATA>

Basically I want the plugin to read the value of STREAMINGPLAYERS and give me the figure as an update. Actually the popup is all I need so basically I want to create a number of channels that have the same kind of layout as above and display them all in the popup balloon at a predefined interval.

Is this possible? I admit at this point that I tried to follow the channel plugin help suggestion and failed to understand it.

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Wed Nov 14, 2012 6:29 pm

If you are running the Pro Edition, you can use an XSLT.

Copy this text and save it in a file somewhere:

Code: Select all

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<rss>

<xsl:for-each select="/DATA">
<item>
    <link> PUT SOMETHING HERE </link>
    <title> Streaming Players Data </title>
    <description> <xsl:value-of select="STREAMINGPLAYERS" /> </description>
</item>
</xsl:for-each>

</rss>
</xsl:template>

</xsl:stylesheet>

Start the Channel Wizard in Awasu and enter the URL for the XML data you're getting from the radio station.

Click on the Processing button, click on the green plus button for XSLT's, browse to the file you just saved above. Go through the wizard to the end.

What's happening is Awasu downloads the XML data, then applies the XSLT, which contains instructions on how to convert the XML data into an RSS feed, which Awasu then processes as normal.

jakeuk
Posts: 24
Joined: Thu Feb 21, 2008 5:56 pm

Postby jakeuk » Wed Nov 14, 2012 9:21 pm

I'm using advanced. :(

User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Thu Nov 15, 2012 6:26 am

support wrote:If you are running the Pro Edition, you can use an XSLT.

Wow, I've written XSLT extensions for Awasu before, but I didn't realize that the initial XML source document doesn't have to be an Atom or RSS format.

So with the Pro Edition, you can basically subscribe to any XML document! That's cool! 8)

I always thought that you'd have to start with an Atom or RSS file and then alter it via XSLT, this has got me thinking... :idea:

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Thu Nov 15, 2012 6:34 am

Yep. I've used XSLT's to subscribe to web services and any other arbitrary XML data sources. It was a big reason for adding support for SOAP, since web services often use them for requests.

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Thu Nov 15, 2012 6:44 am

jakeuk wrote:I'm using advanced. :(

Here's a quick Python script that will get you started:

Code: Select all

import urllib2
import re

# get the data value
buf = urllib2.urlopen( "http://localhost/tmp/data.xml" ).read()
mo = re.search( "<STREAMINGPLAYERS>(.*)</STREAMINGPLAYERS>" , buf )
val = mo.group( 1 )

# geenrate the feed
print "<rss>"
print "<channel>"
print "<item>"
print "<link> PUT SOMETHING HERE </link>"
print "<title> Streaming Players Data </title>"
print "<description>" , val , "</description>"
print "</item>"
print "</channel>"
print "</rss>"

jakeuk
Posts: 24
Joined: Thu Feb 21, 2008 5:56 pm

Postby jakeuk » Thu Nov 15, 2012 11:48 am

Many thanks. Actually I managed to do it with the first script in the advanced version.

It accepted the channels and works fine if I update it manually, but it doesn't auto update. I had assumed that since the figure will almost certainly be different every time that Awasu would see it as new info.

Would the python script work any differently in this regard? That is, would I get a popup with the updated numbers at the specified intervals?

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Thu Nov 15, 2012 12:04 pm

jakeuk wrote:It accepted the channels and works fine if I update it manually, but it doesn't auto update.

You have to tell Awasu how often to update the channel (i.e. download the file and run the script). This is the case for any channel, not just plugins.

Open the channel's Properties and on the first tab, there is an Automatically update this channel setting.

jakeuk
Posts: 24
Joined: Thu Feb 21, 2008 5:56 pm

Postby jakeuk » Thu Nov 15, 2012 2:42 pm

Yes they are all set to update at 30 minute intervals but they don't. I can manually update (Ctrl +U) and that works fine, so I'm assuming that the channel is configured correctly.

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Thu Nov 15, 2012 6:04 pm

jakeuk wrote:Yes they are all set to update at 30 minute intervals but they don't. I can manually update (Ctrl +U) and that works fine, so I'm assuming that the channel is configured correctly.
If you open the Activity Log (in the View menu), you can see what Awasu is doing, in particular, when it updates channels. Also, if you open the channel, it will say in the top-right corner when it was last updated.

Note that a channel may update but not receive any new items, which might be what's causing you think that it's not updating.

jakeuk
Posts: 24
Joined: Thu Feb 21, 2008 5:56 pm

Postby jakeuk » Thu Nov 15, 2012 6:40 pm

Yes the activity log says it's updating, but I'm not getting a popup or an animated icon to say that there are updates.

However the figure would definitely change on every change as there a thousands of listeners. The odds on the same figure coming up 30 minutes later are so unlikely (especially as I have configured 4 different feeds) that the chnaces of no updates are millions to one.

Is it possible that it's not seeing the updating figure in STREAMINGPLAYERS as a change? Also is it perhaps because I'm using the advanced version of Awasu?

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Thu Nov 15, 2012 7:05 pm

jakeuk wrote:Yes the activity log says it's updating, but I'm not getting a popup or an animated icon to say that there are updates.

Ah, I know what's happening.

The sample script I gave you generates the same URL for the feed item. When Awasu receives an updated item (i.e. the value has changed), because the URL is the same, it thinks that it's a revised version of an existing story, so it doesn't show a popup or animation.

The way to work around this is to get Awasu to think that it's received a new item. Add the following line after the line in the script where it prints out <item>:

Code: Select all

print "<guid isPermalink=\"false\">" , val , "</guid>"

This gives each item an ID that is the same as the value in the XML. So if the first update, the value is 8800, the item will have an ID of 8800. If it changes to 8801 on the next update, the item will have a new ID of 8801, Awasu will think it's received a new item and show the balloon and animation.

The problem is if the value changes back to 8800 - Awasu will see an item with an ID of 8800, decide that it's already received this item and won't show you anything. If you want the balloon and animation on every update, get the script to generate a random number (or a GUID) for the <guid> tag - this way Awasu will get a unique ID for the item on every update, and hence show the balloon and animation on every update.

jakeuk
Posts: 24
Joined: Thu Feb 21, 2008 5:56 pm

Postby jakeuk » Mon Nov 19, 2012 11:05 am

I'm sorry. I must be very thick.

I assume that the new line of code that you gave was for the python script, but I have no idea how to create a channel using python. The Awasu help file is not clear.

It shows how to open a sample python script, so I started with that. All I get is "No application is registered for this file type: .py".

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Mon Nov 19, 2012 11:20 am

Sorry, my bad. I missed your comment where you said you managed to get the XSL going. There are ways to generate a random number in an XSL, but they're all pretty hairy and it's probably easier just to use Python instead.

You need to install Python (get the latest 2.x version), then the WIN32 extensions (get the one that corresponds to the version of Python you installed, run it with Administrator privileges).

jakeuk
Posts: 24
Joined: Thu Feb 21, 2008 5:56 pm

Postby jakeuk » Mon Nov 19, 2012 12:07 pm

OK did all that. The sample script seems to set up OK. When I tried my own I get a message saying "Can't determine the feed type."

This is the script:

import urllib2
import re

# get the data value
buf = urllib2.urlopen( "http://localhost/tmp/data.xml" ).read()
mo = re.search( "<STREAMINGPLAYERS>(.*)</STREAMINGPLAYERS>" , buf )
val = mo.group( 1 )

# geenrate the feed
print "<rss>"
print "<channel>"
print "<item>"
print "<link> link to feed.xml </link>"
print "<title> PUT SOMETHING HERE </title>"
print "<description>" , val , "</description>"
print "</item>"
print "<guid isPermalink=\"false\">" , val , "</guid>"
print "</channel>"
print "</rss>"


Return to “Awasu - Extensions”

Who is online

Users browsing this forum: No registered users and 3 guests