// Action script...
// [Initial MovieClip Action of sprite 86]
#initclip 2
class com.jeroenwijering.utils.FeedParser
{
var parseURL, parseArray, parseXML, firstChild;
function FeedParser()
{
RSS_TAGS.itunes:author = "author";
RSS_TAGS.geo:lat = "latitude";
RSS_TAGS.geo:long = "longitude";
ATOM_TAGS.geo:lat = "latitude";
ATOM_TAGS.geo:long = "longitude";
} // End of the function
function parse(url)
{
var ref = this;
parseURL = url;
parseArray = new Array();
parseXML = new XML();
parseXML.ignoreWhite = true;
parseXML.onLoad = function (success)
{
if (success)
{
var _loc2 = firstChild.nodeName.toLowerCase();
if (_loc2 == "rss")
{
ref.parseRSS();
}
else if (_loc2 == "feed")
{
ref.parseASF();
}
else if (_loc2 == "playlist")
{
ref.parseXSPF();
}
else
{
parseArray.push({title: "Feed not understood: " + ref.parseURL});
} // end else if
}
else
{
parseArray.push({title: "Feed not found: " + ref.parseURL});
} // end else if
parseArray.length == 0 ? (parseArray.push({title: "Empty feed: " + ref.parseURL})) : (null);
delete ref.parseXML;
ref.onParseComplete();
};
if (_root._url.indexOf("file://") > -1)
{
parseXML.load(parseURL);
}
else if (parseURL.indexOf("?") > -1)
{
parseXML.load(parseURL + "&" + random(999));
}
else
{
parseXML.load(parseURL + "?" + random(999));
} // end else if
} // End of the function
function parseRSS()
{
for (var _loc5 = parseXML.firstChild.firstChild.firstChild; _loc5 != null; _loc5 = _loc5.nextSibling)
{
if (_loc5.nodeName.toLowerCase() == "item")
{
var _loc3 = new Object();
for (var _loc6 = 0; _loc6 < _loc5.childNodes.length; ++_loc6)
{
var _loc2 = _loc5.childNodes[_loc6];
if (RSS_TAGS[_loc2.nodeName.toLowerCase()] != undefined)
{
_loc3[RSS_TAGS[_loc2.nodeName.toLowerCase()]] = _loc2.firstChild.nodeValue;
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "description")
{
_loc3.description = com.jeroenwijering.utils.StringMagic.stripTagsBreaks(_loc2.firstChild.nodeValue);
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "pubdate")
{
_loc3.date = com.jeroenwijering.utils.StringMagic.rfc2Date(_loc2.firstChild.nodeValue);
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "dc:date")
{
_loc3.date = com.jeroenwijering.utils.StringMagic.iso2Date(_loc2.firstChild.nodeValue);
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "media:thumbnail")
{
_loc3.image = _loc2.attributes.url;
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "itunes:image")
{
_loc3.image = _loc2.attributes.href;
continue;
} // end if
if ((_loc2.nodeName.toLowerCase() == "enclosure" || _loc2.nodeName.toLowerCase() == "media:content") && (_loc2.attributes.type == "audio/mpeg" || _loc2.attributes.type == "video/x-flv" || _loc2.attributes.type == "image/jpeg" || _loc2.attributes.type == "image/png" || _loc2.attributes.type == "image/gif"))
{
_loc3.file = _loc2.attributes.url;
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "media:group")
{
for (var _loc4 = 0; _loc4 < _loc2.childNodes.length; ++_loc4)
{
_loc2.childNodes[_loc4].attributes.type == "video/x-flv" ? (_loc3.file = _loc2.childNodes[_loc4].attributes.url) : (null);
_loc2.childNodes[_loc4].nodeName.toLowerCase() == "media:thumbnail" ? (_loc3.image = _loc2.childNodes[_loc4].attributes.url) : (null);
} // end of for
} // end if
} // end of for
if (_loc3.latitude == undefined && lat != undefined)
{
_loc3.latitude = lat;
_loc3.longitude = lng;
} // end if
_loc3.image == undefined && _loc3.file.indexOf(".jpg") > 0 ? (_loc3.image = _loc3.file) : (null);
_loc3.author == undefined ? (_loc3.author = ttl) : (null);
parseArray.push(_loc3);
continue;
} // end if
if (_loc5.nodeName == "title")
{
var ttl = _loc5.firstChild.nodeValue;
continue;
} // end if
if (_loc5.nodeName == "geo:lat")
{
var lat = _loc5.firstChild.nodeValue;
continue;
} // end if
if (_loc5.nodeName == "geo:long")
{
var lng = _loc5.firstChild.nodeValue;
} // end if
} // end of for
} // End of the function
function parseASF()
{
for (var _loc5 = parseXML.firstChild.firstChild; _loc5 != null; _loc5 = _loc5.nextSibling)
{
if (_loc5.nodeName.toLowerCase() == "entry")
{
var _loc3 = new Object();
for (var _loc6 = 0; _loc6 < _loc5.childNodes.length; ++_loc6)
{
var _loc2 = _loc5.childNodes[_loc6];
if (ATOM_TAGS[_loc2.nodeName.toLowerCase()] != undefined)
{
_loc3[ATOM_TAGS[_loc2.nodeName.toLowerCase()]] = _loc2.firstChild.nodeValue;
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "link" && _loc2.attributes.rel == "alternate")
{
_loc3.link = _loc2.attributes.href;
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "summary")
{
_loc3.description = com.jeroenwijering.utils.StringMagic.stripTagsBreaks(_loc2.firstChild.nodeValue);
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "published")
{
_loc3.date = com.jeroenwijering.utils.StringMagic.iso2Date(_loc2.firstChild.nodeValue);
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "updated")
{
_loc3.date = com.jeroenwijering.utils.StringMagic.iso2Date(_loc2.firstChild.nodeValue);
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "modified")
{
_loc3.date = com.jeroenwijering.utils.StringMagic.iso2Date(_loc2.firstChild.nodeValue);
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "category")
{
_loc3.category = _loc2.attributes.term;
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "author")
{
for (var _loc4 = 0; _loc4 < _loc2.childNodes.length; ++_loc4)
{
_loc2.childNodes[_loc4].nodeName.toLowerCase() == "name" ? (_loc3.author = _loc2.childNodes[_loc4].firstChild.nodeValue) : (null);
} // end of for
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "link" && _loc2.attributes.rel == "enclosure" && (_loc2.attributes.type == "audio/mpeg" || _loc2.attributes.type == "video/x-flv" || _loc2.attributes.type == "image/jpeg" || _loc2.attributes.type == "image/png" || _loc2.attributes.type == "image/gif"))
{
_loc3.file = _loc2.attributes.href;
} // end if
} // end of for
_loc3.author == undefined ? (_loc3.author = ttl) : (null);
parseArray.push(_loc3);
continue;
} // end if
if (_loc5.nodeName == "title")
{
var ttl = _loc5.firstChild.nodeValue;
} // end if
} // end of for
} // End of the function
function parseXSPF()
{
for (var _loc6 = parseXML.firstChild.firstChild; _loc6 != null; _loc6 = _loc6.nextSibling)
{
if (_loc6.nodeName == "trackList")
{
for (var _loc5 = 0; _loc5 < _loc6.childNodes.length; ++_loc5)
{
var _loc3 = new Object();
for (var _loc4 = 0; _loc4 < _loc6.childNodes[_loc5].childNodes.length; ++_loc4)
{
var _loc2 = _loc6.childNodes[_loc5].childNodes[_loc4];
if (XSPF_TAGS[_loc2.nodeName.toLowerCase()] != undefined)
{
_loc3[XSPF_TAGS[_loc2.nodeName.toLowerCase()]] = _loc2.firstChild.nodeValue;
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "meta" && _loc2.attributes.rel == "http://www.jeroenwijering.com/start")
{
_loc3.start = _loc2.firstChild.nodeValue;
continue;
} // end if
if (_loc2.nodeName.toLowerCase() == "annotation")
{
_loc3.description = com.jeroenwijering.utils.StringMagic.stripTagsBreaks(_loc2.firstChild.nodeValue);
} // end if
} // end of for
parseArray.push(_loc3);
} // end of for
} // end if
} // end of for
} // End of the function
function onParseComplete()
{
} // End of the function
var RSS_TAGS = {title: "title", author: "author", link: "link", guid: "id", category: "category"};
var ATOM_TAGS = {title: "title", id: "id"};
var XSPF_TAGS = {title: "title", creator: "author", info: "link", location: "file", image: "image", identifier: "id", album: "category"};
} // End of Class
#endinitclip