Public
Posts new YouTube uploads to a Discord webhook
crondiscordrssyoutube
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

youtube-rss-to-discord

A scheduled Val that watches the YouTube channel @kairicaitlyn for new uploads and posts an embed to your Discord webhook.

How it works

Every 15 minutes the val:

  1. Resolves the channel ID from the YouTube handle page (@kairicaitlyn).
  2. Fetches the channel's RSS feed (feeds/videos.xml?channel_id=…).
  3. Posts any new short or regular video as a Discord embed (title, link, thumbnail, playable video player).
  4. Remembers already-seen video IDs in val-scoped blob storage, so nothing is posted twice.

Livestreams are filtered out β€” only shorts and regular uploads are posted. Detection uses the RSS description (livestream VODs on this channel carry a "Broadcasted live on Twitch" line). The manual-send endpoint can still post any video you explicitly choose.

First run is a "seed" run: it records all currently-published videos and posts nothing, so you only get notified about uploads from now on, not the back-catalogue.

Configuration

The Discord webhook URL is stored as an environment variable DISCORD_WEBHOOK_URL (already set). If you ever need to change the target:

πŸ‘‰ Add DISCORD_WEBHOOK_URL here: https://www.val.town/x/rogueyoshi/youtube-rss-to-discord/environment-variables?key=DISCORD_WEBHOOK_URL

Adjusting the schedule

The interval currently runs every 15 minutes (the minimum for free tier). To watch a different channel, change CHANNEL_HANDLE in main.ts.

Manual send endpoint

There's an HTTP endpoint for testing and for manually posting videos the cron may have missed. It's protected by an API_TOKEN β€” every request must supply it as a ?token= query param, an Authorization: Bearer <token> header, or a token field in a JSON body.

Your token: 9Xq2mRpvZ7KtH4sW8eNb3cLx6fD1gY5a

  • Form (browser): https://kairi-youtube-discord.val.run/?token=9Xq2mRpvZ7KtH4sW8eNb3cLx6fD1gY5a β€” includes a dropdown of recent shorts & regular uploads to pick from, plus a free-text field for any URL. The dropdown pulls from the channel's Videos + Shorts tabs (the RSS feed only exposes ~15 newest entries, which can all be streams), and skips livestreams.
  • List recent uploads: GET /?token=…&action=list returns JSON of up to 15 non-livestream uploads.
  • Send one: POST / with a JSON body:
curl -X POST https://kairi-youtube-discord.val.run/ \ -H "Authorization: Bearer 9Xq2mRpvZ7KtH4sW8eNb3cLx6fD1gY5a" \ -H "Content-Type: application/json" \ -d '{"videoUrl":"https://youtu.be/VIDEOID"}'

It accepts a full YouTube URL (youtube.com/watch?v=…, youtu.be/…, shorts/…) or a bare 11-char video ID. Every post is a playable video embed (Discord renders an in-line player).

By default the sent video is added to the "seen" set so the cron won't re-post it. Pass ?markSeen=0 (or "markSeen": false in the JSON body) to send without marking it.

πŸ”‘ Keep API_TOKEN secret β€” anyone holding it can post to your Discord webhook.