mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-21 13:15:51 -05:00
Update index.js
This commit is contained in:
@@ -108,6 +108,98 @@ exports.get_card = function(req, res) {
|
||||
});
|
||||
}
|
||||
*/
|
||||
/*
|
||||
async function getPodcast(req, res, next) {
|
||||
const now = new Date().toLocaleString();
|
||||
|
||||
const feedStart = `
|
||||
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:psc="http://podlove.org/simple-chapters" xmlns:podcast="https://podcastindex.org/namespace/1.0" version="2.0">
|
||||
<channel>
|
||||
<title>
|
||||
<![CDATA[ OpenMHz ]]>
|
||||
</title>
|
||||
<description>
|
||||
<![CDATA[ Real public safety radio recordings, from across the country. <a href="hhtps://openmhz.com">OpenMHz</a> is a website that makes it easy to share recordings of public safety radio system. This podcast is a collection of interesting events that has been curated by the OpenMHz community. ]]>
|
||||
</description>
|
||||
<link>https://openmhz.com</link>
|
||||
<generator>Podcast for Node</generator>
|
||||
<lastBuildDate>${now}</lastBuildDate>
|
||||
<atom:link href="https://openmhz.com/rss.xml" rel="self" type="application/rss+xml"/>
|
||||
<author>
|
||||
<![CDATA[ OpenMHz ]]>
|
||||
</author>
|
||||
<pubDate>${now}</pubDate>
|
||||
<copyright>
|
||||
<![CDATA[ © 2023 Robotastic ]]>
|
||||
</copyright>
|
||||
<language>
|
||||
<![CDATA[ en ]]>
|
||||
</language>
|
||||
<ttl>60</ttl>
|
||||
<itunes:author>OpenMHz</itunes:author>
|
||||
<itunes:subtitle>I am a sub title</itunes:subtitle>
|
||||
<itunes:summary>Real public safety radio recordings, from across the country. OpenMHz is a website that makes it easy to share recordings of public safety radio system. This podcast is a collection of interesting events that has been curated by the OpenMHz community.</itunes:summary>
|
||||
<itunes:owner>
|
||||
<itunes:name>Luke Berndt</itunes:name>
|
||||
<itunes:email>luke@robotastic.com</itunes:email>
|
||||
</itunes:owner>
|
||||
<itunes:explicit>false</itunes:explicit>
|
||||
<itunes:category text="Government"/>
|
||||
<itunes:category text="Daily News"/>
|
||||
<itunes:category text="True Crime"/>
|
||||
<itunes:image href="https://openmhz.com/podcast/cover.png"/>
|
||||
`
|
||||
|
||||
|
||||
|
||||
const feedEnd = `
|
||||
</channel>
|
||||
</rss>
|
||||
`
|
||||
let xml = feedStart;
|
||||
try {
|
||||
const podcastsCollection = db.get().collection('podcasts');
|
||||
podcastsCollection.find().toArray(function (err, podcasts) {
|
||||
|
||||
|
||||
for (const podcast of podcasts) {
|
||||
let description = podcast.description + "\n\nRadio Systems: \n";
|
||||
for (const system of podcast.systems) {
|
||||
description = description + " - " + system + "\n";
|
||||
}
|
||||
xml = xml + `
|
||||
<item>
|
||||
<title>
|
||||
<![CDATA[ ${podcast.title} ]]>
|
||||
</title>
|
||||
<description>
|
||||
<![CDATA[ ${description} ]]>
|
||||
</description>
|
||||
<guid isPermaLink="false">${podcast.downloadUrl}</guid>
|
||||
<dc:creator>
|
||||
<![CDATA[ OpenMHz ]]>
|
||||
</dc:creator>
|
||||
<url>${podcast.eventUrl}</url>
|
||||
<pubDate>${podcast.startTime}</pubDate>
|
||||
<enclosure url="${podcast.downloadUrl}" length="0" type="audio/mp4"/>
|
||||
<itunes:author>OpenMHz</itunes:author>
|
||||
<itunes:summary>${description}</itunes:summary>
|
||||
<itunes:explicit>false</itunes:explicit>
|
||||
</item>
|
||||
`
|
||||
}
|
||||
|
||||
|
||||
xml = xml + feedEnd;
|
||||
res.set('Content-Type', 'text/xml');
|
||||
res.send(xml);
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
async function getPodcast(req, res, next) {
|
||||
@@ -137,9 +229,12 @@ async function getPodcast(req, res, next) {
|
||||
itunesImage: 'https://openmhz.com/podcast/cover.png'
|
||||
});
|
||||
for (const podcast of podcasts) {
|
||||
let description = podcast.description +"\\n\\nRadio Systems:\\n";
|
||||
let description = podcast.description + `
|
||||
|
||||
Radio Systems:
|
||||
`;
|
||||
for (const system of podcast.systems) {
|
||||
description = description + " - " + system + "\\n"
|
||||
description = description + " - " + system + "\n"
|
||||
}
|
||||
feed.addItem({
|
||||
title: podcast.title,
|
||||
@@ -152,7 +247,7 @@ async function getPodcast(req, res, next) {
|
||||
date: podcast.startTime, // any format that js Date can parse.
|
||||
itunesAuthor: 'OpenMHz',
|
||||
itunesExplicit: false,
|
||||
itunesSummary: podcast.description,
|
||||
itunesSummary: description,
|
||||
itunesDuration: podcast.len
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user