* add /yoasobi-music && ipl "news" and "bio" * update title * implement live rss * implement media rss * fix synax * edit doc * omit i Co-authored-by: Tony <TonyRL@users.noreply.github.com> * omit useless @ Co-authored-by: Tony <TonyRL@users.noreply.github.com> * specify category param Co-authored-by: Tony <TonyRL@users.noreply.github.com> * specify pubDate * specify guid
20 lines
550 B
JavaScript
20 lines
550 B
JavaScript
function parseJSONP(jsonpData) {
|
|
try {
|
|
const startPos = jsonpData.indexOf('({');
|
|
const endPos = jsonpData.lastIndexOf('})');
|
|
let jsonString = jsonpData.substring(startPos + 1, endPos + 1);
|
|
|
|
// remove escaped single quotes since they are not valid json
|
|
jsonString = jsonString.replace(/\\'/g, "'");
|
|
|
|
return JSON.parse(jsonString);
|
|
} catch (e) {
|
|
const error = new Error(`Failed to convert jsonp to json. ${e.message}`);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
parseJSONP,
|
|
};
|