import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./parse-date-BdYTmLpo.mjs";import n from"node:crypto";const r=[24,13,4,19,6,0,8,21,25,7,28,1,15,31,10,9,17,18,22,11,27,23,2,26,12,5,29,14,20,30,16,3],i=e=>{let t=new Date().toISOString().slice(0,10).replaceAll(`-`,``),i=Object.keys(e).toSorted().map(t=>`${t}=${e[t]}`).join(`&`),a=`${i}evst${t}`,o=n.createHash(`md5`).update(a).digest(`hex`);return{m:t,n:r.map(e=>o[e]).join(``),queryStr:i}},a={path:`/channel/:channel`,categories:[`multimedia`],example:`/castbox/channel/Lemonade-Stand-id6776228`,parameters:{channel:`Channel`},features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!0,supportScihub:!1},radar:[{source:[`castbox.fm/channel/:channel`],target:`/channel/:channel`}],name:`Channels`,description:'Get the channel from the Castbox channel URL. For example, the URL of the channel "Lemonade Stand" is `https://castbox.fm/channel/Lemonade-Stand-id6776228`, where `Lemonade-Stand-id6776228` is the `channel` parameter.\n    \n    You can use the RSSHub global `limit` query parameter to specify the maximum number of episodes to fetch from the Castbox API (defaults to 50). For example: `/castbox/channel/Lemonade-Stand-id6776228?limit=100`.',maintainers:[`ananyatimalsina`],handler:async n=>{let{channel:r}=n.req.param(),a=r.split(`-id`)[1];if(!a)throw Error(`Invalid channel format. Missing -id`);let{m:o,n:s,queryStr:c}=i({cid:a,r:1,raw:1,web:1}),l=await e(`https://everest.castbox.fm/data/channel/v3?${c}&m=${o}&n=${s}`);if(!l?.data)throw Error(`Failed to fetch channel data from Castbox`);let u=l.data,{m:d,n:f,queryStr:p}=i({cid:a,limit:n.req.query(`limit`)?Number.parseInt(n.req.query(`limit`),10):50,r:1,raw:1,web:1}),m=await e(`https://everest.castbox.fm/data/episode_list/v2?${p}&m=${d}&n=${f}`);if(!m?.data?.episode_list)throw Error(`Failed to fetch episode list from Castbox`);let h=m.data.episode_list.map(e=>{let n=`audio/mpeg`;return e.video===1||e.url?.includes(`.mp4`)?n=`video/mp4`:e.url?.includes(`.m4a`)&&(n=`audio/mp4`),{title:e.title,description:e.description,pubDate:t(e.release_date),link:`https://castbox.fm/episode/${encodeURIComponent(e.title)}-id${a}-id${e.eid}`,enclosure_url:e.url,enclosure_type:n,enclosure_length:e.size,itunes_item_image:e.big_cover_url||e.cover_url,itunes_duration:e.duration?Math.round(e.duration/1e3):void 0}});return{title:u.title,link:`https://castbox.fm/channel/${r}`,description:u.description,image:u.big_cover_url||u.small_cover_url,language:u.language,itunes_author:u.author,item:h}}};export{a as route};