import{t as e}from"./config-BYRrjYC5.mjs";import{t}from"./cache-DUthuMSu.mjs";import{t as n}from"./parse-date-BdYTmLpo.mjs";import{t as r}from"./config-not-found-B9AOp828.mjs";import{l as i}from"./google-B_YlRFye.mjs";import a from"p-map";const o={path:`/subscriptions/:embed?`,categories:[`social-media`],example:`/youtube/subscriptions`,parameters:{embed:`Default to embed the video, set to any value to disable embedding`},features:{requireConfig:[{name:`YOUTUBE_KEY`,description:``},{name:`YOUTUBE_CLIENT_ID`,description:``},{name:`YOUTUBE_CLIENT_SECRET`,description:``},{name:`YOUTUBE_REFRESH_TOKEN`,description:``}]},radar:[{source:[`www.youtube.com/feed/subscriptions`,`www.youtube.com/feed/channels`],target:`/subscriptions`}],name:`Subscriptions`,maintainers:[`TonyRL`],handler:s,url:`www.youtube.com/feed/subscriptions`};async function s(o){if(!e.youtube||!e.youtube.key||!e.youtube.clientId||!e.youtube.clientSecret||!e.youtube.refreshToken)throw new r(`YouTube RSS is disabled due to the lack of <a href="https://docs.rsshub.app/deploy/config#route-specific-configurations">relevant config</a>`);let s=!o.req.param(`embed`),c=(await i.getSubscriptions(`snippet`,t)).data.items.map(e=>e.snippet.resourceId.channelId),l=await a(c,async e=>(await i.getChannelWithId(e,`contentDetails`,t)).data.items[0].contentDetails.relatedPlaylists.uploads,{concurrency:30}),u=await a(l,async e=>(await i.getPlaylistItems(e,`snippet`,t))?.data.items,{concurrency:30});u=u.flat(),u=u.filter(e=>e&&!e.error&&e.snippet.title!==`Private video`&&e.snippet.title!==`Deleted video`).map(e=>{let t=e.snippet,r=t.resourceId.videoId,a=i.getThumbnail(t.thumbnails);return{title:t.title,description:i.renderDescription(s,r,a,i.formatDescription(t.description)),pubDate:n(t.publishedAt),link:`https://www.youtube.com/watch?v=${r}`,author:t.videoOwnerChannelTitle,image:a.url}});let d={title:`Subscriptions - YouTube`,description:`YouTube Subscriptions`,link:`www.youtube.com/feed/subscriptions`,item:u};return o.set(`json`,{...d,channelIds:c,playlistIds:l}),d}export{o as route};