📄 xspfparser.as
字号:
/**
* Parses ATOM feeds and returns an indexed array with all elements.
*
* @author Jeroen Wijering
* @version 1.0
**/
import com.jeroenwijering.feeds.AbstractParser;
import com.jeroenwijering.utils.StringMagic;
class com.jeroenwijering.feeds.XSPFParser extends AbstractParser {
/** Contructor **/
function XSPFParser(enc:Boolean,pre:String) { super(enc,pre); };
/** build an array with all regular elements **/
private function setElements() {
elements = new Object();
elements["title"] = "title";
elements["creator"] = "author";
elements["info"] = "link";
elements["image"] = "image";
elements["identifier"] = "id";
elements["album"] = "category";
};
/** Convert ATOM structure to array **/
private function parse(xml:XML):Array {
var arr = new Array();
var tpl = xml.firstChild.firstChild;
while(tpl != null) {
if (tpl.nodeName == 'trackList') {
for(var i=0; i<tpl.childNodes.length; i++) {
var obj = new Object();
for(var j=0; j<tpl.childNodes[i].childNodes.length; j++) {
var nod:XMLNode = tpl.childNodes[i].childNodes[j];
if(elements[nod.nodeName.toLowerCase()]!=undefined) {
obj[elements[nod.nodeName.toLowerCase()]] =
nod.firstChild.nodeValue;
} else if(nod.nodeName.toLowerCase() == "location") {
obj["file"] = prefix + nod.firstChild.nodeValue;
if(obj["file"].substr(0,4) == "rtmp") {
obj["type"] == "rtmp";
} else {
obj["type"] = obj["file"].substr(-3);
}
} else if(nod.nodeName.toLowerCase()=="annotation") {
obj["description"] = StringMagic.stripTagsBreaks(
nod.firstChild.nodeValue);
} else if(nod.nodeName.toLowerCase() == "link" &&
nod.attributes.rel == "captions") {
obj["captions"] = nod.firstChild.nodeValue;
} else if(nod.nodeName.toLowerCase() == "meta" &&
nod.attributes.rel == "start") {
obj["start"] = nod.firstChild.nodeValue;
} else if(nod.nodeName.toLowerCase() == "meta" &&
nod.attributes.rel == "type") {
obj["type"] = nod.firstChild.nodeValue;
}
}
if(obj["type"] != undefined || enclosures == false) {
arr.push(obj);
}
}
}
tpl = tpl.nextSibling;
}
return arr;
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -