import{t as e}from"./config-BYRrjYC5.mjs";import{t}from"./cache-DUthuMSu.mjs";import{i as n}from"./helpers-X4cpMMfY.mjs";import{t as r}from"./parse-date-BdYTmLpo.mjs";import{t as i}from"./got-BBDj7u1e.mjs";import{n as a,t as o}from"./readable-social-CL7r3QmK.mjs";import{n as s,r as c,t as l}from"./utils-Edy6dlJs.mjs";import{t as u}from"./cache-DCQ3KkFK.mjs";import{t as d}from"./captcha-C7eCqlow.mjs";import f from"json-bigint";const p={path:`/user/dynamic/:uid/:routeParams?`,categories:[`social-media`],view:1,example:`/bilibili/user/dynamic/2267573`,parameters:{uid:`用户 id, 可在 UP 主主页中找到`,routeParams:`
| 键         | 含义                              | 接受的值       | 默认值 |
| ---------- | --------------------------------- | -------------- | ------ |
| showEmoji  | 显示或隐藏表情图片                | 0/1/true/false | false  |
| embed      | 默认开启内嵌视频                  | 0/1/true/false |  true  |
| useAvid    | 视频链接使用 AV 号 (默认为 BV 号) | 0/1/true/false | false  |
| directLink | 使用内容直链                      | 0/1/true/false | false  |
| hideGoods  | 隐藏带货动态                      | 0/1/true/false | false  |
| offset     | 偏移状态                         | string         | ""  |

用例：\`/bilibili/user/dynamic/2267573/showEmoji=1&embed=0&useAvid=1\``},features:{requireConfig:[{name:`BILIBILI_COOKIE_*`,optional:!0,description:"如果没有此配置，那么必须开启 Playwright 支持；BILIBILI_COOKIE_{uid}: 用于用户关注动态系列路由，对应 uid 的 b 站用户登录后的 Cookie 值，`{uid}` 替换为 uid，如 `BILIBILI_COOKIE_2267573`，获取方式：\n1.  打开 [https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=0&type=8](https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=0&type=8)\n2.  打开控制台，切换到 Network 面板，刷新\n3.  点击 dynamic_new 请求，找到 Cookie\n4.  视频和专栏，UP 主粉丝及关注只要求 `SESSDATA` 字段，动态需复制整段 Cookie"}],requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`space.bilibili.com/:uid`],target:`/user/dynamic/:uid`}],name:`UP 主动态`,maintainers:[`DIYgod`,`zytomorrow`,`CaoMeiYouRen`,`JimenezLi`],handler:S},m=e=>{let t=e.module_dynamic?.major;return t?t.none?t.none.tips:t.courses?`${t.courses?.title} - ${t.courses?.sub_title}`:t.live_rcmd?.content?JSON.parse(t.live_rcmd.content)?.live_play_info?.title:t[t.type.replace(`MAJOR_TYPE_`,``).toLowerCase()]?.title:``},h=e=>{let t=``;e.module_dynamic?.desc?.text&&(t+=e.module_dynamic.desc.text);let n=e.module_dynamic?.major;if(!n)return t;if(n?.common?.desc)return t+=t?`<br>//转发自: ${n.common.desc}`:n.common.desc,t;if(n?.live)return`${n.live?.desc_first}<br>${n.live?.desc_second}`;if(n.live_rcmd?.content){let e=JSON.parse(n.live_rcmd.content)?.live_play_info;return`${e?.area_name}·${e?.watched_show?.text_large}`}return n?.opus?n?.opus?.summary?.text:n[n.type.replace(`MAJOR_TYPE_`,``).toLowerCase()]?.desc},g=e=>e&&m(e),_=e=>e&&h(e),v=e=>e?.module_author?.name,y=(e,t=!0)=>{if(!t)return``;let n=e?.module_dynamic?.major?.archive?.aid,r=e?.module_dynamic?.major?.archive?.bvid;return n===void 0&&r===void 0?``:c.renderUGCDescription(t,``,``,n,void 0,r)},b=e=>{let t=[],n=e?.module_dynamic?.major;if(!n)return``;n.opus?.pics?.length&&t.push(...n.opus.pics.map(e=>({url:e.url,width:e.width,height:e.height}))),n.article?.covers?.length&&t.push(...n.article.covers.map(e=>({url:e}))),n.draw?.items?.length&&t.push(...n.draw.items.map(e=>({url:e.src,width:e.width,height:e.height}))),n.live_rcmd?.content&&t.push({url:JSON.parse(n.live_rcmd.content)?.live_play_info?.cover});let r=n.type.replace(`MAJOR_TYPE_`,``).toLowerCase();return n[r]?.cover&&t.push({url:n[r]?.cover}),t.filter(Boolean).map(e=>`<img src="${e.url}" ${e.width?`width="${e.width}"`:``} ${e.height?`height="${e.height}"`:``}>`).join(``)},x=(e,t=!1)=>{let n=e?.modules;if(!n)return null;let r=``,i=``,a,o=n.module_dynamic?.major;if(!o)return null;switch(o?.type){case`MAJOR_TYPE_UGC_SEASON`:r=o?.ugc_season?.jump_url||``,i=`合集地址：<a href=${r}>${r}</a>`;break;case`MAJOR_TYPE_ARTICLE`:r=`https://www.bilibili.com/read/cv${o?.article?.id}`,i=`专栏地址：<a href=${r}>${r}</a>`;break;case`MAJOR_TYPE_ARCHIVE`:{let e=o?.archive;r=`https://www.bilibili.com/video/${t?`av${e?.aid}`:e?.bvid}`,i=`视频地址：<a href=${r}>${r}</a>`,a=s(e?.bvid);break}case`MAJOR_TYPE_COMMON`:r=o?.common?.jump_url||``,i=`地址：<a href=${r}>${r}</a>`;break;case`MAJOR_TYPE_OPUS`:e?.type===`DYNAMIC_TYPE_ARTICLE`?(r=`https:${o?.opus?.jump_url}`,i=`专栏地址：<a href=${r}>${r}</a>`):e?.type===`DYNAMIC_TYPE_DRAW`&&(r=`https:${o?.opus?.jump_url}`,i=`图文地址：<a href=${r}>${r}</a>`);break;case`MAJOR_TYPE_PGC`:{let e=o?.pgc;r=`https://www.bilibili.com/bangumi/play/ep${e?.epid}&season_id=${e?.season_id}`,i=`剧集地址：<a href=${r}>${r}</a>`;break}case`MAJOR_TYPE_COURSES`:r=`https://www.bilibili.com/cheese/play/ss${o?.courses?.id}`,i=`课程地址：<a href=${r}>${r}</a>`;break;case`MAJOR_TYPE_MUSIC`:r=`https://www.bilibili.com/audio/au${o?.music?.id}`,i=`音频地址：<a href=${r}>${r}</a>`;break;case`MAJOR_TYPE_LIVE`:r=`https://live.bilibili.com/${o?.live?.id}`,i=`直播间地址：<a href=${r}>${r}</a>`;break;case`MAJOR_TYPE_LIVE_RCMD`:{let e=JSON.parse(o.live_rcmd?.content||`{}`)?.live_play_info;r=`https://live.bilibili.com/${e?.room_id}`,a=l(e?.room_id),i=`直播间地址：<a href=${r}>${r}</a>`;break}default:return null}return{url:r,text:i,videoPageUrl:a}};async function S(s){let l=s.req.query(`format`)===`json`,p=s.req.param(`uid`),S=Object.fromEntries(new URLSearchParams(s.req.param(`routeParams`))),C=o(void 0,a(S.showEmoji),!1),w=o(void 0,a(S.embed),!1),T=s.req.query(`mode`)===`fulltext`,E=o(void 0,S.offset,``),D=o(void 0,a(S.useAvid),!1),O=o(void 0,a(S.directLink),!1),k=o(void 0,a(S.hideGoods),!1),A=async e=>{let t=await i(`https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space?${c.addDmVerifyInfo(`offset=${E}&host_mid=${p}&platform=web&features=itemOpusStyle,listOnlyfans,opusBigCover,onlyfansVote`,c.getDmImgList())}`,{headers:{Referer:`https://space.bilibili.com/${p}/`,Cookie:e}});return f.parse(t.body)},j;if(j=await A(await u.getCookie()),j?.code===-352&&(j=await A(await u.getCookie(!0)),j?.code===-352))throw t.set(`bili-cookie`,``),new d(`遇到源站风控校验，请稍后再试`);let M=j?.data?.items,N=M[0]?.modules?.module_author?.name,P=M[0]?.modules?.module_author?.face;if(!P||!N){let e=await u.getUsernameAndFaceFromUID(p);N=e[0]||M[0]?.modules?.module_author?.name,P=e[1]||M[0]?.modules?.module_author?.face}else t.set(`bili-username-from-uid-${p}`,N),t.set(`bili-userface-from-uid-${p}`,P);let F=await Promise.all(M.filter(e=>k?e.modules.module_dynamic?.additional?.type!==`ADDITIONAL_TYPE_GOODS`:!0).map(async t=>{let i=t.modules,a=t?.orig?.modules,o=i?.module_dynamic?.major?.archive?.bvid,s=``;t.id_str&&(s=`https://t.bilibili.com/${t.id_str}`);let c=h(i)||``,d=c,f=m(i),S=[];if(i.module_dynamic?.desc?.rich_text_nodes?.length){let e=i.module_dynamic.desc.rich_text_nodes;for(let t of e){if(C&&t?.emoji){let e=t.emoji;d=d.replaceAll(e.text,`<img alt="${e.text}" src="${e.icon_url}" style="margin: -1px 1px 0px; display: inline-block; width: 20px; height: 20px; vertical-align: text-bottom;" title="" referrerpolicy="no-referrer">`)}if(t?.pics?.length){let{pics:e,text:n}=t;d=d.replaceAll(n,e.map(e=>`<img alt="${n}" src="${e.src}" style="margin: 0px 0px 0px; display: inline-block; width: ${e.width}px; height: ${e.height}px; vertical-align: text-bottom;" title="" referrerpolicy="no-referrer">`).join(`<br>`))}t?.type===`RICH_TEXT_NODE_TYPE_TOPIC`&&S.push(t.text.match(/#(\S+)#/)?.[1]||``)}}if(i.module_dynamic?.major?.opus?.summary?.rich_text_nodes?.length){let e=i.module_dynamic.major.opus.summary.rich_text_nodes;for(let t of e)t?.type===`RICH_TEXT_NODE_TYPE_TOPIC`&&S.push(t.text.match(/#(\S+)#/)?.[1]||``)}if(i.module_dynamic?.topic?.name&&S.push(i.module_dynamic.topic.name),t.type===`DYNAMIC_TYPE_ARTICLE`&&T){let e=i.module_dynamic?.major?.opus?.jump_url?.match?.(/cv(\d+)/)?.[0];e&&(d=(await u.getArticleDataFromCvid(e,p)).description||``)}let E=x(t,D),k=E?.text;E&&O&&(s=E.url);let A=x(t?.orig,D),j=A?.text;A&&O&&(s=A.url);let M=``,P=v(a),F=g(a),I=_(a);P&&(M+=`//转发自: @${v(a)}: `),F&&(M+=F),I&&(M+=`<br>${I}`),d=d.replaceAll(`\r
`,`<br>`).replaceAll(`
`,`<br>`),M=M.replaceAll(`\r
`,`<br>`).replaceAll(`
`,`<br>`);let L=[f,d,y(i,w),b(i),k,M,y(a,w),b(a),j].map(e=>e?.trim()).filter(Boolean).join(`<br>`),R=l&&!e.bilibili.excludeSubtitles&&o?await u.getVideoSubtitleAttachment(o):[];return{title:f||c,description:L,pubDate:i.module_author?.pub_ts?r(i.module_author.pub_ts,`X`):void 0,link:s,author:N,category:S.length?[...new Set(S)]:void 0,attachments:E?.videoPageUrl||A?.videoPageUrl?[{url:E?.videoPageUrl||A?.videoPageUrl,mime_type:`text/html`,duration_in_seconds:i.module_dynamic?.major?.archive?.duration_text?n(i.module_dynamic.major.archive.duration_text):void 0},...R]:void 0}}));return{title:`${N} 的 bilibili 动态`,link:`https://space.bilibili.com/${p}/dynamic`,description:`${N} 的 bilibili 动态`,image:P,logo:P,icon:P,item:F}}export{p as route};