1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { fetch } from "https://esm.town/v/std/fetch";
import { dataToRSS } from "https://esm.town/v/Glench/dataToRSS";
import process from "node:process";
export const tvshows = async function (req, res: express.Response) {
const TV_SHOWS_WATCHED = [
// Ted Lasso
97546,
// Reservation Dogs
95215,
// Survivor
14658,
// Great British Bake-off
87012,
// Wellington Paranormal
80475,
// What We Do in the Sahdows
83631,
// Kotaro Lives Alone
134581,
// Lord of the Rings: Rings of Power
84773,
// Laid-back Camp
76075,
];
const data = [];
for (var i = 0; i < TV_SHOWS_WATCHED.length; ++i) {
const show_id = TV_SHOWS_WATCHED[i];
const url =
`https://api.themoviedb.org/3/tv/${show_id}?api_key=${process.env.tmdb_api_key}`;
const resp = await fetch(url);
const show = await resp.json();
data.push(show);
}
data.sort(function (a, b) {
if (a.last_air_date > b.last_air_date)
return -1;
if (a.last_air_date < b.last_air_date)
return 1;
return 0;
});
res.send(dataToRSS(data, {
title: "My TV Shows",
link: "https://www.val.town/Glench.tvshows",
description: "Personal shows from tmdb api and val.town",
item: {
title: (x) =>
`${x.name} - ${x.last_episode_to_air.name} (${x.last_episode_to_air.season_number}x${x.last_episode_to_air.episode_number})`,
link: (x) => x.last_episode_to_air.id,
description: (x) => x.last_episode_to_air.overview,
pubDate: (x) => x.last_episode_to_air.air_date,
},
}));
};