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"./got-BBDj7u1e.mjs";import{t as i}from"./config-not-found-B9AOp828.mjs";import{l as a}from"./google-B_YlRFye.mjs";import{load as o}from"cheerio";const s={path:`/c/:username/:embed?`,categories:[`social-media`],example:`/youtube/c/YouTubeCreators`,parameters:{username:`YouTube custom URL`,embed:`Default to embed the video, set to any value to disable embedding`},features:{requireConfig:[{name:`YOUTUBE_KEY`,description:" YouTube API Key, support multiple keys, split them with `,`, [API Key application](https://console.developers.google.com/)"}],requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`www.youtube.com/c/:id`],target:`/c/:id`}],name:`Custom URL`,maintainers:[`TonyRL`],handler:c};async function c(s){if(!e.youtube||!e.youtube.key)throw new i(`YouTube RSS is disabled due to the lack of <a href="https://docs.rsshub.app/deploy/config#route-specific-configurations">relevant config</a>`);let c=s.req.param(`username`),l=!s.req.param(`embed`),{data:u}=await r(`https://www.youtube.com/c/${c}`),d=o(u),f=JSON.parse(d(`script`).text().match(/ytInitialData = ({.*?});/)?.[1]||`{}`),p=f.metadata.channelMetadataRenderer.externalId,m=(await a.getChannelWithId(p,`contentDetails`,t)).data.items[0].contentDetails.relatedPlaylists.uploads,h=(await a.getPlaylistItems(m,`snippet`,t)).data.items;return{title:`${c} - YouTube`,link:`https://www.youtube.com/c/${c}`,description:f.metadata.channelMetadataRenderer.description,image:f.metadata.channelMetadataRenderer.avatar?.thumbnails?.[0]?.url,item:h.filter(e=>e.snippet.title!==`Private video`&&e.snippet.title!==`Deleted video`).map(e=>{let t=e.snippet,r=t.resourceId.videoId,i=a.getThumbnail(t.thumbnails);return{title:t.title,description:a.renderDescription(l,r,i,a.formatDescription(t.description)),pubDate:n(t.publishedAt),link:`https://www.youtube.com/watch?v=${r}`,author:t.videoOwnerChannelTitle,image:i.url}})}}export{s as route};