First pass at dinosaurwet rss
This commit is contained in:
108
src/dinosaurwet/dinosaurwet.controller.ts
Normal file
108
src/dinosaurwet/dinosaurwet.controller.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
import { Controller, Get, Res } from '@nestjs/common';
|
||||
import { Response } from 'express';
|
||||
import * as xml from 'xml';
|
||||
|
||||
const episodeFiles: [number, string][] = [
|
||||
[27544345, '01-Into-the-Big-Wet.mp3'],
|
||||
[30724178, '02-Ocean-Rumours.mp3'],
|
||||
[30752181, '03-Step-Two.mp3'],
|
||||
[28793207, '04-Red-Ladder-Revelations.mp3'],
|
||||
[29684714, '05-What-to-do-with-a-Problem-Like-Daveda.mp3'],
|
||||
[29387545, '06-Hair-Bussy.mp3'],
|
||||
[30789798, '07-Monkey-Monkey-Cock-a-Roach.mp3'],
|
||||
[29449403, '08-SS-Jungle-and-Blood.mp3'],
|
||||
[29554728, '09-A-Bad-Day-in-Sogland.mp3'],
|
||||
[31728952, '10-A-Loathed-Trip-Down-Memory-Lane.mp3'],
|
||||
[29711881, '11-Dog-Egg-Consumption.mp3'],
|
||||
[31212772, '12-Meg-and-Bobs-Wedding-Bussy.mp3'],
|
||||
[30951548, '13-100-Genuine-Pussy-Hound.mp3'],
|
||||
[33766503, '14-One-Perfect-Answer.mp3'],
|
||||
[29643754, '15-Succulent-Pig-Excitement.mp3'],
|
||||
[29797145, '16-Welcome-to-Jackson-Island.mp3'],
|
||||
[37926451, '17-Infinite-Meat.mp3'],
|
||||
[33863888, '18-The-Jackson-Triumvirate.mp3'],
|
||||
[30256482, '19-A-Lucky-Day-to-be-a-Jackson.mp3'],
|
||||
[40947042, '20-The-Joels-Triumphant.mp3'],
|
||||
];
|
||||
|
||||
const startDate = new Date('2023-10-02');
|
||||
|
||||
const episodes = episodeFiles.map((file, i) => {
|
||||
const [length, filename] = file;
|
||||
return {
|
||||
filename,
|
||||
length,
|
||||
url: `https://s3.apps.hnl.byoi.net/dinosaurpark/DinosaurWet/${filename}`,
|
||||
title: filename
|
||||
.replace(/^\d+/, '')
|
||||
.replace('.mp3', '')
|
||||
.replace(/-/g, ' ')
|
||||
.trim(),
|
||||
description:
|
||||
'A bootleg-ish of Dinosar Wet, making the downloaded files more like and RSS feed',
|
||||
fakeReleaseDate: new Date(startDate).setDate(startDate.getDate() + i * 7),
|
||||
};
|
||||
});
|
||||
|
||||
@Controller('dinosaurwet')
|
||||
export class DinosaurwetController {
|
||||
@Get('')
|
||||
getAllAtOnce(@Res() response: Response) {
|
||||
response.header('Content-Type', 'application/xml');
|
||||
const feedObject = {
|
||||
rss: [
|
||||
{
|
||||
_attr: {
|
||||
version: '2.0',
|
||||
'xmlns:atom': 'http://www.w3.org/2005/Atom',
|
||||
},
|
||||
},
|
||||
{
|
||||
channel: [
|
||||
{
|
||||
'atom:link': {
|
||||
_attr: {
|
||||
href: 'https://api.us.dev/dinosaurwet',
|
||||
rel: 'self',
|
||||
type: 'application/rss+xml',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Dinosaur Wet - All At Once',
|
||||
},
|
||||
{
|
||||
link: 'https://sanspantsradio.com',
|
||||
},
|
||||
{
|
||||
description:
|
||||
'A recreation of Dinosaur Wet as an RSS feed for listeners-with-licenses enjoyment.',
|
||||
},
|
||||
{ language: 'en-US' },
|
||||
...episodes.map(({ title, url, length }) => ({
|
||||
item: [
|
||||
{ title },
|
||||
{ guid: url },
|
||||
{ pubDate: startDate.toUTCString() },
|
||||
{
|
||||
enclosure: [
|
||||
{
|
||||
_attr: {
|
||||
url,
|
||||
type: 'audio/mpeg',
|
||||
length,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})),
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const feed = '<?xml version="1.0" encoding="UTF-8"?>' + xml(feedObject);
|
||||
return response.send(feed);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user