Skip to content

Commit

Permalink
change rss saves to db
Browse files Browse the repository at this point in the history
  • Loading branch information
VovaStelmashchuk committed Jan 4, 2025
1 parent 73432c2 commit ed54a8c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ node_modules
.tmp
.DS_Store
.tmp
compose.yml
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# YourPod

The platform for build podcast from yourtube playlist.

## Development

```bash
npm run dev
```

## Deploy

```bash
docker stack deploy -c docker-compose.yml stack-your-pod
```
19 changes: 10 additions & 9 deletions src/core/generator.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { Podcast } from "podcast";

import {
buildObjectURL,
getFileSizeInByte,
uploadFile,
} from "../minio/utils.js";
import { buildObjectURL, getFileSizeInByte } from "../minio/utils.js";
import { getShowBySlug } from "../core/podcastRepo.js";

import { Database } from "./client.js";

import dotenv from "dotenv";

dotenv.config();

const startUrl = process.env.S3_START_URL;
const host = process.env.BASE_URL;
const rssFileName = process.env.PODCAST_RSS_FILE_NAME;

const currentYear = new Date().getFullYear();

export async function updateRss(showSlug) {
const showInfo = await getShowBySlug(showSlug);

const host = `https://${showInfo.mainDomain}`;

const logoUrl = `${startUrl}${showInfo.showLogoUrl}`;
const description = showInfo.about;

Expand All @@ -30,7 +28,7 @@ export async function updateRss(showSlug) {
const feed = new Podcast({
title: showInfo.showName,
description: description,
feedUrl: `${startUrl}/v2/${showSlug}/${rssFileName}`,
feedUrl: `${startUrl}/v2/${showSlug}/rss.xml`,
siteUrl: host,
webMaster: host,
generator: "YourPod",
Expand Down Expand Up @@ -109,5 +107,8 @@ export async function updateRss(showSlug) {

const xml = feed.buildXml();

await uploadFile(`v2/${showSlug}/${rssFileName}`, xml, "application/rss+xml");
await Database.collection("shows").updateOne(
{ slug: showSlug },
{ $set: { rss: xml } }
);
}
8 changes: 1 addition & 7 deletions src/routers/rss/rss.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { getShowInfo } from "../../core/podcastRepo.js";
import { getFileContent } from "../../minio/utils.js";
import dotenv from "dotenv";

dotenv.config();

const rssFileName = process.env.PODCAST_RSS_FILE_NAME;

async function rssHandler(request, h) {
const host = request.headers.host;
const showInfo = await getShowInfo(host);

const rss = await getFileContent(`v2/${showInfo.slug}/${rssFileName}`);
const rss = showInfo.rss;

return h.response(rss).type("application/rss+xml");
}
Expand Down

0 comments on commit ed54a8c

Please sign in to comment.