Something went wrong. Try again.
Small (but incredibly useful!) scripts and utilities that don't need their own repo.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546#!/usr/bin/env nu# SPDX-License-Identifier: AGPL-3.0-only# Copyright (c) 2025 MatrixFurry <matrix@matrixfurry.com>
use std assert
# Get an RSS feed for the specified YouTube channel.export def main [ channel_url: string --copy (-c)] { validate-url $channel_url
let rss_url = $"https://www.youtube.com/feeds/videos.xml?channel_id=(get-channel-id $channel_url)"
if $copy { wl-copy $rss_url } else { print $rss_url }}
def validate-url [channel_url: string] { assert ( ($channel_url | str starts-with "https://www.youtube.com/@") or ($channel_url | str starts-with "https://www.youtube.com/channel/") or ($channel_url | str starts-with "https://www.youtube.com/c/") ) --error-label { text: "This is not a valid YouTube channel URL.", span: (metadata $channel_url).span }}
def get-channel-id [channel_url: string]: nothing -> string { let path = ($channel_url | url parse).path
if ($path | str starts-with "/channel") { $path | str replace "/channel/" "" } else { http get -r $channel_url | parse -r '{"key":"browse_id","value":"(?P<channel_id>[^"]*)"}' | get channel_id.0 }}