Files
RSSHub/lib/v2/yoasobi-music/jsonpHelper.js
T
ri1kenandTony 381171e442 feat(route): add Yoasobi Official support (#10920)
* 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
2022-09-28 00:07:48 +08:00

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,
};