Use the new rss that does not need expanding
This commit is contained in:
parent
73d0c9d79d
commit
e91e0e4488
64
index.ts
64
index.ts
@ -11,69 +11,9 @@ function trim(str: string, length: number): string {
|
|||||||
app.use(async (ctx) => {
|
app.use(async (ctx) => {
|
||||||
try {
|
try {
|
||||||
const { data } = await Axios.get(
|
const { data } = await Axios.get(
|
||||||
"https://podcast.midline.pl/api/v1/channels/Midline/rss"
|
"https://podcast.internet-czas-dzialac.pl/@icd/feed.xml"
|
||||||
);
|
);
|
||||||
const builder = new xml2js.Builder({ cdata: true });
|
ctx.body = data;
|
||||||
const parsed_data = await xml2js.parseStringPromise(data);
|
|
||||||
|
|
||||||
parsed_data.rss.channel[0]["itunes:explicit"] = "false";
|
|
||||||
parsed_data.rss.channel[0]["itunes:author"] =
|
|
||||||
"Agnieszka Rapcewicz, Arkadiusz Wieczorek, Kuba Orlik";
|
|
||||||
parsed_data.rss.channel[0]["itunes:owner"][0]["itunes:email"] =
|
|
||||||
"kontakt@internet-czas-dzialac.pl";
|
|
||||||
parsed_data.rss.channel[0]["itunes:owner"][0]["itunes:name"] =
|
|
||||||
"Agnieszka Rapcewicz, Arkadiusz Wieczorek, Kuba Orlik";
|
|
||||||
parsed_data.rss.channel[0]["link"] =
|
|
||||||
"https://www.internet-czas-dzialac.pl";
|
|
||||||
parsed_data.rss.channel[0]["itunes:keywords"][0] =
|
|
||||||
parsed_data.rss.channel[0]["itunes:keywords"][0]
|
|
||||||
.split(" ")
|
|
||||||
.toString();
|
|
||||||
parsed_data.rss.channel[0]["itunes:summary"][0] =
|
|
||||||
parsed_data.rss.channel[0]["itunes:summary"][0].replace(
|
|
||||||
/(<([^>]+)>)/gi,
|
|
||||||
""
|
|
||||||
);
|
|
||||||
|
|
||||||
parsed_data.rss.channel[0]["itunes:subtitle"][0] = trim(
|
|
||||||
parsed_data.rss.channel[0]["itunes:subtitle"][0],
|
|
||||||
255
|
|
||||||
);
|
|
||||||
|
|
||||||
for (
|
|
||||||
let i = 0;
|
|
||||||
i < parsed_data.rss.channel[0]["atom:link"].length;
|
|
||||||
i++
|
|
||||||
) {
|
|
||||||
const atomLink = parsed_data.rss.channel[0]["atom:link"][i];
|
|
||||||
|
|
||||||
if (atomLink.$.rel === "self") {
|
|
||||||
atomLink.$.href = "https://podcast.midline.pl/feed.xml";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let last_index = 1;
|
|
||||||
for (let i = 0; i < parsed_data.rss.channel[0]["item"].length; i++) {
|
|
||||||
const item = parsed_data.rss.channel[0]["item"][i];
|
|
||||||
|
|
||||||
item["guid"][0].$.isPermaLink = item["guid"][0].$.isPermalink;
|
|
||||||
delete item["guid"][0].$.isPermalink;
|
|
||||||
item["itunes:subtitle"][0] = trim(item["itunes:subtitle"][0], 255);
|
|
||||||
item["itunes:explicit"][0] = "false";
|
|
||||||
item["itunes:summary"][0] = item["itunes:summary"][0];
|
|
||||||
if (item["title"][0].match(/#[0-9]*/)[0].substring(1) !== "0") {
|
|
||||||
try {
|
|
||||||
last_index = item["title"][0]
|
|
||||||
.match(/#[1-9][0-9]*/)[0]
|
|
||||||
.substring(1);
|
|
||||||
} catch (e) {
|
|
||||||
last_index = last_index + 1;
|
|
||||||
}
|
|
||||||
item["itunes:episode"] = [last_index];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.body = builder.buildObject(parsed_data);
|
|
||||||
ctx.type = "application/rss+xml";
|
ctx.type = "application/rss+xml";
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user