Update dinosaurwet
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Controller, Get, Res } from '@nestjs/common';
|
||||
import { Response } from 'express';
|
||||
import { identity } from 'ramda';
|
||||
import * as xml from 'xml';
|
||||
|
||||
const episodeFiles: [number, string][] = [
|
||||
@@ -27,7 +28,16 @@ const episodeFiles: [number, string][] = [
|
||||
|
||||
const startDate = new Date('2023-10-02');
|
||||
|
||||
const episodes = episodeFiles.map((file, i) => {
|
||||
type Episode = {
|
||||
filename: string;
|
||||
length: number;
|
||||
url: string;
|
||||
title: string;
|
||||
description: string;
|
||||
fakeReleaseDate: Date;
|
||||
};
|
||||
|
||||
const episodes: Episode[] = episodeFiles.map((file, i) => {
|
||||
const [length, filename] = file;
|
||||
return {
|
||||
filename,
|
||||
@@ -40,15 +50,16 @@ const episodes = episodeFiles.map((file, i) => {
|
||||
.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),
|
||||
fakeReleaseDate: new Date(
|
||||
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 buildFeeds = (
|
||||
episodes: Episode[],
|
||||
dateFn: (date: Date) => Date = identity,
|
||||
) => {
|
||||
const feedObject = {
|
||||
rss: [
|
||||
{
|
||||
@@ -103,6 +114,15 @@ export class DinosaurwetController {
|
||||
};
|
||||
|
||||
const feed = '<?xml version="1.0" encoding="UTF-8"?>' + xml(feedObject);
|
||||
return feed;
|
||||
};
|
||||
|
||||
@Controller('dinosaurwet')
|
||||
export class DinosaurwetController {
|
||||
@Get('')
|
||||
getAllAtOnce(@Res() response: Response) {
|
||||
response.header('Content-Type', 'application/xml');
|
||||
const feed = buildFeeds(episodes);
|
||||
return response.send(feed);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user