#!/bin/sh -e node -e 'const baseUrl = "https://www.nhc.noaa.gov/aboutrss.shtml"; require("node:https").get(baseUrl, res => { const chunks = []; res.on("data", chunk => chunks.push(chunk)); res.on("end", () => { process.stdout.write(JSON.stringify({ opml: { "@version": "2.0", head: { title: "National Hurricane Center and Central Pacific Hurricane Center RSS feeds", dateModified: new Date().toUTCString(), ownerName: "lucidiot", ownerEmail: "lucidiot@envs.net", ownerId: "https://tilde.town/~lucidiot/contact.html", docs: "http://dev.opml.org/spec2.html" }, body: { outline: Array.from( Buffer.concat(chunks).toString("latin1").matchAll(/]*href="[^"]+\.xml"[^>]*>\s*]*src="[^"]*gifs\/xml.gif"[^>]*>\s*<\/a>\s*(?[^<]+)]*href="(?[^"]+\.xml)"[^>]*>/gi), ({ groups: { name, url } }) => { const text = name.replace(/[:\s]*$/g, "").replace(/&#(\d+);/, (_, code) => String.fromCharCode(parseInt(code, 10))).replace(/&(amp|gt|lt|apos|quot);/, (_, name) => ({ amp: "&", gt: ">", lt: "<", apos: "'"'"'", quot: "\"" }[name])); return { "@type": "rss", "@text": text, "@xmlUrl": new URL(url, baseUrl).href, "@language": ["EspaƱol", "Atlantico", "Cartera"].some(word => text.includes(word)) ? "es" : "en-us" } }, ) } } }), "utf-8"); }); })' | oq -i json -o xml .