/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/patreon-mp3-downloader@1.0.3/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import Fs from"fs";import Https from"https";import{xml2js}from"xml-js";import fetch from"node-fetch";export async function downloadFile(t,e,o=""){return await new Promise(((r,s)=>{Https.get(t,(t=>{const i=t.statusCode??0;if(i>=400)return s(new Error(t.statusMessage));if(i>300&&i<400&&t.headers.location)return r(downloadFile(t.headers.location,e,o));const n=Fs.createWriteStream(`./${o}${e}`).on("finish",(()=>{r({})}));t.pipe(n)})).on("error",(t=>{s(t)}))}))}export class Item{constructor(t){this.link=t.enclosure._attributes.url;const e=`${t.title._text.split(" ").join("_")}`;this.fileName=e.replace(/[ &\/\\#,+()$~%.'":*?<>{}]/g,"")+".mp3"}async download(t=""){await downloadFile(this.link,this.fileName,t)}}export default async function(t){const e=await fetch(t),o=await e.text(),r=xml2js(o,{compact:!0,ignoreComment:!0,alwaysChildren:!0}),{rss:{channel:{item:s}}}=r;return s.filter((t=>"audio/mpeg"===t.enclosure._attributes.type)).map((t=>new Item(t)))}
//# sourceMappingURL=/sm/54d4641589f24f1264a7222c638f28df5249823c8f847a3788b4f3a855b30c6e.map