ready4testing
This commit is contained in:
+132
@@ -0,0 +1,132 @@
|
||||
(function() {
|
||||
var DOMParser, find, parse;
|
||||
|
||||
DOMParser = (typeof window !== "undefined" && window !== null ? window.DOMParser : void 0) || (typeof require === "function" ? require('xmldom').DOMParser : void 0) || function() {};
|
||||
|
||||
find = function(node, list) {
|
||||
var attributes, childNode, childNodeName, childNodes, i, match, x, _i, _j, _ref, _ref1;
|
||||
if (node.hasChildNodes()) {
|
||||
childNodes = node.childNodes;
|
||||
for (i = _i = 0, _ref = childNodes.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
|
||||
childNode = childNodes[i];
|
||||
childNodeName = childNode.nodeName;
|
||||
if (/REF/i.test(childNodeName)) {
|
||||
attributes = childNode.attributes;
|
||||
for (x = _j = 0, _ref1 = attributes.length; 0 <= _ref1 ? _j < _ref1 : _j > _ref1; x = 0 <= _ref1 ? ++_j : --_j) {
|
||||
match = attributes[x].nodeName.match(/HREF/i);
|
||||
if (match) {
|
||||
list.push({
|
||||
file: childNode.getAttribute(match[0]).trim()
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (childNodeName !== '#text') {
|
||||
find(childNode, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
parse = function(playlist) {
|
||||
var doc, ret;
|
||||
ret = [];
|
||||
doc = (new DOMParser()).parseFromString(playlist, 'text/xml').documentElement;
|
||||
if (!doc) {
|
||||
return ret;
|
||||
}
|
||||
find(doc, ret);
|
||||
return ret;
|
||||
};
|
||||
|
||||
(typeof module !== "undefined" && module !== null ? module.exports : window).ASX = {
|
||||
name: 'asx',
|
||||
parse: parse
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
(function() {
|
||||
var COMMENT_RE, EXTENDED, comments, empty, extended, parse, simple;
|
||||
|
||||
EXTENDED = '#EXTM3U';
|
||||
|
||||
COMMENT_RE = /:(?:(-?\d+),(.+)\s*-\s*(.+)|(.+))\n(.+)/;
|
||||
|
||||
extended = function(line) {
|
||||
var match;
|
||||
match = line.match(COMMENT_RE);
|
||||
if (match && match.length === 6) {
|
||||
return {
|
||||
length: match[1] || 0,
|
||||
artist: match[2] || '',
|
||||
title: match[4] || match[3],
|
||||
file: match[5].trim()
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
simple = function(string) {
|
||||
return {
|
||||
file: string.trim()
|
||||
};
|
||||
};
|
||||
|
||||
empty = function(line) {
|
||||
return !!line.trim().length;
|
||||
};
|
||||
|
||||
comments = function(line) {
|
||||
return line[0] !== '#';
|
||||
};
|
||||
|
||||
parse = function(playlist) {
|
||||
var firstNewline;
|
||||
playlist = playlist.replace(/\r/g, '');
|
||||
firstNewline = playlist.search('\n');
|
||||
if (playlist.substr(0, firstNewline) === EXTENDED) {
|
||||
return playlist.substr(firstNewline).split('\n#').filter(empty).map(extended);
|
||||
} else {
|
||||
return playlist.split('\n').filter(empty).filter(comments).map(simple);
|
||||
}
|
||||
};
|
||||
|
||||
(typeof module !== "undefined" && module !== null ? module.exports : window).M3U = {
|
||||
name: 'm3u',
|
||||
parse: parse
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
(function() {
|
||||
var LISTING_RE, parse;
|
||||
|
||||
LISTING_RE = /(file|title|length)(\d+)=(.+)\r?/i;
|
||||
|
||||
parse = function(playlist) {
|
||||
var index, key, line, match, tracks, value, _, _i, _len, _ref;
|
||||
tracks = [];
|
||||
_ref = playlist.trim().split('\n');
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
line = _ref[_i];
|
||||
match = line.match(LISTING_RE);
|
||||
if (match && match.length === 4) {
|
||||
_ = match[0], key = match[1], index = match[2], value = match[3];
|
||||
if (!tracks[index]) {
|
||||
tracks[index] = {};
|
||||
}
|
||||
tracks[index][key.toLowerCase()] = value;
|
||||
}
|
||||
}
|
||||
return tracks.filter(function(track) {
|
||||
return track != null;
|
||||
});
|
||||
};
|
||||
|
||||
(typeof module !== "undefined" && module !== null ? module.exports : window).PLS = {
|
||||
name: 'pls',
|
||||
parse: parse
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
This software is dual licensed under the MIT and Beerware license.
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Nick Desaulniers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
"THE BEER-WARE LICENSE" (Revision 42):
|
||||
<nick@mozilla.com> wrote this file. As long as you retain this
|
||||
notice you can do whatever you want with this stuff. If we meet some day,
|
||||
and you think this stuff is worth it, you can buy me a beer in return.
|
||||
Nick Desaulniers
|
||||
|
||||
*/
|
||||
(function(){var a,b,c;a=("undefined"!=typeof window&&null!==window?window.DOMParser:void 0)||("function"==typeof require?require("xmldom").DOMParser:void 0)||function(){},b=function(a,c){var d,e,f,g,h,i,j,k,l,m,n;if(a.hasChildNodes())for(g=a.childNodes,h=k=0,m=g.length;m>=0?m>k:k>m;h=m>=0?++k:--k)if(e=g[h],f=e.nodeName,/REF/i.test(f)){for(d=e.attributes,j=l=0,n=d.length;n>=0?n>l:l>n;j=n>=0?++l:--l)if(i=d[j].nodeName.match(/HREF/i)){c.push({file:e.getAttribute(i[0]).trim()});break}}else"#text"!==f&&b(e,c);return null},c=function(c){var d,e;return e=[],(d=(new a).parseFromString(c,"text/xml").documentElement)?(b(d,e),e):e},("undefined"!=typeof module&&null!==module?module.exports:window).ASX={name:"asx",parse:c}}).call(this),function(){var a,b,c,d,e,f,g;b="#EXTM3U",a=/:(?:(-?\d+),(.+)\s*-\s*(.+)|(.+))\n(.+)/,e=function(b){var c;return c=b.match(a),c&&6===c.length?{length:c[1]||0,artist:c[2]||"",title:c[4]||c[3],file:c[5].trim()}:void 0},g=function(a){return{file:a.trim()}},d=function(a){return!!a.trim().length},c=function(a){return"#"!==a[0]},f=function(a){var f;return a=a.replace(/\r/g,""),f=a.search("\n"),a.substr(0,f)===b?a.substr(f).split("\n#").filter(d).map(e):a.split("\n").filter(d).filter(c).map(g)},("undefined"!=typeof module&&null!==module?module.exports:window).M3U={name:"m3u",parse:f}}.call(this),function(){var a,b;a=/(file|title|length)(\d+)=(.+)\r?/i,b=function(b){var c,d,e,f,g,h,i,j,k,l;for(g=[],l=b.trim().split("\n"),j=0,k=l.length;k>j;j++)e=l[j],f=e.match(a),f&&4===f.length&&(i=f[0],d=f[1],c=f[2],h=f[3],g[c]||(g[c]={}),g[c][d.toLowerCase()]=h);return g.filter(function(a){return null!=a})},("undefined"!=typeof module&&null!==module?module.exports:window).PLS={name:"pls",parse:b}}.call(this);
|
||||
Reference in New Issue
Block a user