diff --git a/frontend/server/index.js b/frontend/server/index.js
index 11fa51d..018ff18 100644
--- a/frontend/server/index.js
+++ b/frontend/server/index.js
@@ -4,7 +4,7 @@ const express = require("express");
const path = require("path");
const secrets = require("./config/secrets");
const configureExpress = require("./config/express");
-const { Podcast,Item,FeedOptions } = require('podcast');
+const { Podcast, Item, FeedOptions } = require('podcast');
// -------------------------------------------
@@ -53,8 +53,8 @@ function getCard(req, res, next) {
function (err, item) {
if (item) {
var time = new Date(item.time);
- var timeString = time.toLocaleTimeString('en-US', {timeZone: "America/New_York"});
- var dateString = time.toLocaleDateString('en-US', {timeZone: "America/New_York"});
+ var timeString = time.toLocaleTimeString('en-US', { timeZone: "America/New_York" });
+ var dateString = time.toLocaleDateString('en-US', { timeZone: "America/New_York" });
//console.log(item)
res.render('card.ejs', {
item: item,
@@ -108,58 +108,153 @@ exports.get_card = function(req, res) {
});
}
*/
+/*
+async function getPodcast(req, res, next) {
+ const now = new Date().toLocaleString();
+
+ const feedStart = `
+
+
+
+
+
+
+ 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. ]]>
+
+ https://openmhz.com
+ Podcast for Node
+ ${now}
+
+
+
+
+ ${now}
+
+
+
+
+
+
+ 60
+ OpenMHz
+ I am a sub title
+ 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.
+
+ Luke Berndt
+ luke@robotastic.com
+
+ false
+
+
+
+
+ `
+
+
+
+ const feedEnd = `
+
+
+`
+ 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 + `
+-
+
+
+
+
+
+
+${podcast.downloadUrl}
+
+
+
+${podcast.eventUrl}
+${podcast.startTime}
+
+OpenMHz
+${description}
+false
+
+`
+ }
+
+
+ xml = xml + feedEnd;
+ res.set('Content-Type', 'text/xml');
+ res.send(xml);
+ });
+
+ } catch (err) {
+ console.error(err);
+ return;
+ }
+}*/
async function getPodcast(req, res, next) {
const now = new Date();
try {
const podcastsCollection = db.get().collection('podcasts');
- podcastsCollection.find().toArray(function(err, podcasts) {
- const feed = new Podcast({
- title: 'OpenMHz',
- description: '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.',
- feedUrl: 'https://openmhz.com/rss.xml',
- siteUrl: 'https://openmhz.com',
- imageUrl: 'https://openmhz.com/podcast/cover.png',
- author: 'OpenMHz',
- copyright: '© 2022 Robotastic',
- language: 'en',
- pubDate: 'May 20, 2012 04:00:00 GMT',
- ttl: 60,
- itunesAuthor: 'OpenMHz',
- itunesSubtitle: 'I am a sub title',
- itunesSummary: '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.',
- itunesOwner: { name: 'Luke Berndt', email: 'luke@robotastic.com' },
- itunesExplicit: false,
- itunesCategory: [{
- text: 'Government'
- }, { text: "Daily News"}, {text: "True Crime"}],
- itunesImage: 'https://openmhz.com/podcast/cover.png'
+ podcastsCollection.find().toArray(function (err, podcasts) {
+ const feed = new Podcast({
+ title: 'OpenMHz',
+ description: '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.',
+ feedUrl: 'https://openmhz.com/rss.xml',
+ siteUrl: 'https://openmhz.com',
+ imageUrl: 'https://openmhz.com/podcast/cover.png',
+ author: 'OpenMHz',
+ copyright: '© 2022 Robotastic',
+ language: 'en',
+ pubDate: 'May 20, 2012 04:00:00 GMT',
+ ttl: 60,
+ itunesAuthor: 'OpenMHz',
+ itunesSubtitle: 'I am a sub title',
+ itunesSummary: '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.',
+ itunesOwner: { name: 'Luke Berndt', email: 'luke@robotastic.com' },
+ itunesExplicit: false,
+ itunesCategory: [{
+ text: 'Government'
+ }, { text: "Daily News" }, { text: "True Crime" }],
+ 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,
+ title: podcast.title,
description: description,
enclosure: {
url: podcast.downloadUrl, // link to the item
- },
+ },
author: 'OpenMHz', // optional - defaults to feed author property
url: podcast.eventUrl,
date: podcast.startTime, // any format that js Date can parse.
itunesAuthor: 'OpenMHz',
itunesExplicit: false,
- itunesSummary: podcast.description,
+ itunesSummary: description,
itunesDuration: podcast.len
});
}
const xml = feed.buildXml();
res.set('Content-Type', 'text/xml');
res.send(xml);
- });
+ });
} catch (err) {
console.error(err);
@@ -180,27 +275,27 @@ async function getCalls(req, res, next) {
}
try {
- db.get().collection('calls', function (err, transCollection) {
- transCollection.findOne({
- '_id': o_id
- },
- async function (err, item) {
- if (item) {
- var time = new Date(item.time);
- var timeString = time.toLocaleTimeString('en-US', {timeZone: "America/New_York"});
- var dateString = time.toDateString('en-US', {timeZone: "America/New_York"});
- //console.log(item)
- const tg_coll = db.get().collection('talkgroups');
- const tg = await tg_coll.findOne({ "num": item.talkgroupNum, 'shortName': req.params.shortName.toLowerCase()})
- var title = item.len + " second transmission"
+ db.get().collection('calls', function (err, transCollection) {
+ transCollection.findOne({
+ '_id': o_id
+ },
+ async function (err, item) {
+ if (item) {
+ var time = new Date(item.time);
+ var timeString = time.toLocaleTimeString('en-US', { timeZone: "America/New_York" });
+ var dateString = time.toDateString('en-US', { timeZone: "America/New_York" });
+ //console.log(item)
+ const tg_coll = db.get().collection('talkgroups');
+ const tg = await tg_coll.findOne({ "num": item.talkgroupNum, 'shortName': req.params.shortName.toLowerCase() })
+ var title = item.len + " second transmission"
- if (tg) {
- //console.log(tg)
- title = tg.description;
- }
- const callId = req.query["call-id"];
- const callUrl = "https://s3.us-west-1.wasabisys.com/openmhz-west/media/dcfd-1039-1613917169.m4a"
- const twitterMeta = `
+ if (tg) {
+ //console.log(tg)
+ title = tg.description;
+ }
+ const callId = req.query["call-id"];
+ const callUrl = "https://s3.us-west-1.wasabisys.com/openmhz-west/media/dcfd-1039-1613917169.m4a"
+ const twitterMeta = `
@@ -212,19 +307,19 @@ async function getCalls(req, res, next) {
`
- res.render("index.ejs", { TWITTER_META: twitterMeta })
- } else {
- console.warn("Error - /card/:id Could not find Item " + err);
- res.send(404, 'Sorry, we cannot find that!');
- }
- });
- });
-
- } catch (err) {
- console.error(err);
- next()
- return;
- }
+ res.render("index.ejs", { TWITTER_META: twitterMeta })
+ } else {
+ console.warn("Error - /card/:id Could not find Item " + err);
+ res.send(404, 'Sorry, we cannot find that!');
+ }
+ });
+ });
+
+ } catch (err) {
+ console.error(err);
+ next()
+ return;
+ }
} else {