import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./logger-B0fjfmRH.mjs";import{t as n}from"./cache-DUthuMSu.mjs";import{t as r}from"./parse-date-BdYTmLpo.mjs";import{t as i}from"./timezone-keeL11Io.mjs";import{n as a}from"./playwright-1-2p8zlN.mjs";import{load as o}from"cheerio";const s={path:`/:category?`,categories:[`traditional-media`],example:`/chinatimes/realtimenews`,parameters:{category:"分類，見下表，留空為 `realtimenews`"},features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`www.chinatimes.com/:category/`,`www.chinatimes.com/`]}],name:`分類`,maintainers:[`KingJem`],handler:c,url:`www.chinatimes.com/`,description:`|     即時     |   熱門  |   政治  | 生活 | 娛樂 |  財經 |  國際 |   言論  |   兩岸  |   軍事   |   社會  |  健康  |  體育  |      科技      |   運勢  | 有影 |  寶島  |
| :----------: | :-----: | :-----: | :--: | :--: | :---: | :---: | :-----: | :-----: | :------: | :-----: | :----: | :----: | :------------: | :-----: | :--: | :----: |
| realtimenews | hotnews | politic | life | star | money | world | opinion | chinese | armament | society | health | sports | technologynews | fortune | tube | taiwan |`};async function c(s){let c=`https://www.chinatimes.com`,{category:l=`realtimenews`}=s.req.param(`category`),u=`${c}/${l}/?chdtv`,d=o(await e(u)),f=await a(),p=d(`.articlebox-compact`).toArray().slice(0,s.req.query(`limit`)?Number.parseInt(s.req.query(`limit`),10):20).map(e=>{let t=d(e),n=t.find(`.title a`);return{title:n.text().trim(),link:`${c}${n.attr(`href`)}?chdtv`,guid:`${c}${n.attr(`href`)}`,pubDate:i(r(t.find(`time`).attr(`datetime`)),8),category:t.find(`.category a`).toArray().map(e=>d(e).text().trim())}}),m=await Promise.all(p.map(e=>n.tryGet(e.link,async()=>{let n=await f.newPage();await n.setRequestInterception(!0),n.on(`request`,e=>{e.resourceType()===`document`?e.continue():e.abort()}),t.http(`Requesting ${e.link}`),await n.goto(e.link,{waitUntil:`domcontentloaded`});let r=await n.content();await n.close();let i=o(r);return e.category=[...new Set([...e.category,...i(`.article-hash-tag a`).toArray().map(e=>i(e).text().trim())])],i(`.ad, #donate-form-container, .promote-word, .google-news-promote, .article-hash-tag`).remove(),e.description=i(`.main-figure`).html()+i(`.article-body`).html(),e})));return await f.close(),{title:d(`head title`).text(),description:d(`head meta[name="description"]`).attr(`content`),link:u,language:d(`html`).attr(`lang`),image:`${c}/images/2020/apple-touch-icon.png`,item:m}}export{s as route};