publishport-opencli 1.0.68 → 1.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli-manifest.json
CHANGED
|
@@ -52701,6 +52701,13 @@
|
|
|
52701
52701
|
"default": false,
|
|
52702
52702
|
"required": false,
|
|
52703
52703
|
"help": "Include nested replies (楼中楼)"
|
|
52704
|
+
},
|
|
52705
|
+
{
|
|
52706
|
+
"name": "replies-limit",
|
|
52707
|
+
"type": "int",
|
|
52708
|
+
"default": 3,
|
|
52709
|
+
"required": false,
|
|
52710
|
+
"help": "With --with-replies: max nested replies per top-level comment (default 3, 0 = all). Capped threads show replies_complete=false; read a whole thread with `replies <url> <root-id>`"
|
|
52704
52711
|
}
|
|
52705
52712
|
],
|
|
52706
52713
|
"columns": [
|
|
@@ -53394,13 +53401,13 @@
|
|
|
53394
53401
|
"name": "card-text",
|
|
53395
53402
|
"type": "str",
|
|
53396
53403
|
"required": false,
|
|
53397
|
-
"help": "文字配图卡片文字,多张卡片用 ||| 分隔,卡内换行用 \\n"
|
|
53404
|
+
"help": "文字配图卡片文字,多张卡片用 ||| 分隔,卡内换行用 \\n。全部卡片写在同一个参数里并整体加引号,如 --card-text '第一张|||第二张';分隔符两侧不要断开成多个参数"
|
|
53398
53405
|
},
|
|
53399
53406
|
{
|
|
53400
53407
|
"name": "card-style",
|
|
53401
53408
|
"type": "str",
|
|
53402
53409
|
"required": false,
|
|
53403
|
-
"help": "
|
|
53410
|
+
"help": "文字配图卡片样式。省略时使用基础。小红书按正文内容只开放下列样式中的一部分,不是每次都全有;所选样式当次不可用时会在提交前失败并列出当次可选项,按报错改选即可。样式参考: 基础(默认兜底,万能) 边框(金句/要点卡) 备忘(提醒/随手记) 清新(日常/清单贴士) 涂写(随笔/碎碎念) 便签(笔记/提醒) 光影(情绪/文艺) 涂鸦(趣味/童话) 简约(干货/观点) 手写(日记/情感) 插图(生活方式/轻松话题) 美漫(活力/趣味/故事感) 弥散(弥散光氛围) 柔和(柔和/温柔金句) 印刷(印刷海报/排版) 科技(科技/产品) 贺卡(节日祝福) 札记(艺术/水彩氛围) 书摘(书摘/引用) 手帐(手帐拼贴) 几何(醒目/有力主张)"
|
|
53404
53411
|
},
|
|
53405
53412
|
{
|
|
53406
53413
|
"name": "topics",
|
package/clis/nowcoder/utils.js
CHANGED
|
@@ -57,4 +57,4 @@ import{ArgumentError as f,AuthRequiredError as S,CliError as w,CommandExecutionE
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
`),n=requireOk(e?.unread,"登录态"),o=requireOk(e?.user,"当前用户").data??{};if(!/^[1-9]\d*$/.test(String(o.userId??"")))throw new d("牛客登录态接口确认已登录,但当前用户接口没有给出 uid","多为接口暂时异常,可稍后重试;不要把这当成未登录。");return{uid:String(o.userId),nickname:String(o.nickname??""),unread:n.data??{}}}export async function getSelfUid(t){return(await getSession(t)).uid}export function noteTrustedEmpty(t,e){process.stderr.write(`nowcoder ${t}: ${e}空列表是真实结果,不是取数失败。
|
|
60
|
-
`);return[]}export function postUrl({entityType:t,id:e,uuid:n}){if(Number(t)===74)return n?`${WWW_BASE}/feed/main/detail/${n}`:null;if(Number(t)===250)return/^\d{15,}$/.test(String(e??""))?`${WWW_BASE}/discuss/${e}`:null;return null}export function toIso(t){const e=Number(t);return Number.isFinite(e)&&e>0?new Date(e).toISOString():""}export function plainText(t){return decodeHtmlEntities(String(t??"").replace(/<[^>]+>/g,"")).trim()}export function feedRecordToPost(t){const e=Number(t?.contentType),n=t?.momentData,o=t?.contentData,i=n??o??{},r=t?.frequencyData??null,s=t?.userBrief??{},a=n?String(n.id??""):String(o?.id??""),u=String(i.uuid??"");return{writeId:a,uuid:u,entityType:Number.isFinite(e)?e:null,url:postUrl({entityType:e,id:a,uuid:u}),title:plainText(i.title??i.newTitle),content:plainText(i.content??i.newContent),author:String(s.nickname??""),userId:String(s.userId??i.userId??i.authorId??""),school:String(s.educationInfo??""),likes:r?Number(r.likeCnt??0):null,comments:r?Number(r.totalCommentCnt??r.commentCnt??0):null,views:r?Number(r.viewCnt??0):null,liked:r&&typeof r.isLike==="boolean"?r.isLike:null,time:toIso(n?n.createdAt:o?.createTime)}}function h(t,e){return new NowcoderError("NOT_VISIBLE",`牛客帖子 ${t} 不可见${e?`: ${e}`:""}`,"帖子存在但当前账号看不到:多为仅作者可见、审核中或已删除。不是 id 抄错,也不是登录问题,重试无用。",l.EMPTY_RESULT)}export function parsePostRef(t){if(typeof t==="number"&&!Number.isSafeInteger(t))throw new f("牛客帖子 ID 已丢失精度,请传推荐结果中的原始字符串 ID");const e=String(t??"").trim(),n=e.match(/detail\/([0-9a-fA-F]{20,})/)?.[1]??e.match(/\/discuss\/(\d+)/)?.[1]??e;if(/^\d+$/.test(n))return{ref:n,form:BigInt(n)>BigInt(Number.MAX_SAFE_INTEGER)?"snowflake":"short"};if(/^[0-9a-fA-F]{20,}$/.test(n))return{ref:n,form:"uuid"};throw new f(`无法从输入解析牛客帖子 id: ${t}`,"可传 18 位讨论帖 id、32 位动态 uuid、7 位 momentId 或帖子链接。")}export async function resolvePostTarget(t,e){const{ref:n,form:o}=parsePostRef(e);if(o==="short")return{id:n,entityType:74,authorId:"",uuid:"",url:null,detail:null,liked:null,likeCount:null,totalComments:null,legacy:null};if(o==="snowflake"){const c=requireOk(await getJson(t,`${GW_BASE}/detail/content-data/detail/${n}`),"讨论帖解析",{id:e}).data;if(typeof c?.id==="number")throw new d("牛客讨论帖详情未返回匹配的原始字符串 ID");if(!c||c.id!==n)throw h(e,c?.showMessage?.message);const y=String(c.authorId??c.userBrief?.userId??"");if(!/^[1-9]\d*$/.test(y))throw new d("牛客讨论帖详情缺少作者 ID");const m=c.frequencyData??{};return{id:n,entityType:250,authorId:y,uuid:String(c.uuid??""),url:postUrl({entityType:250,id:n}),detail:c,liked:typeof m.isLike==="boolean"?m.isLike:null,likeCount:m.likeCnt??null,totalComments:m.totalCommentCnt??m.commentCnt??null,legacy:c.entityId&&c.entityType?{id:String(c.entityId),entityType:Number(c.entityType)}:null}}const r=requireOk(await getJson(t,`${GW_BASE}/detail/moment-data/detail/${n}`),"帖子解析",{id:e}).data;if(!r?.id)throw h(e,r?.showMessage?.message);const s=r.frequencyData??{},a=String(r.uuid??n);return{id:String(r.id),entityType:74,authorId:String(r.userId??""),uuid:a,url:postUrl({entityType:74,uuid:a}),detail:r,liked:typeof s.isLike==="boolean"?s.isLike:null,likeCount:s.likeCnt??null,totalComments:s.totalCommentCnt??s.commentCnt??null,legacy:null}}export async function readLikeState(t,e){const n=await resolvePostTarget(t,e);if(n.liked===null)throw new f(`读不到帖子 ${e} 当前是否已赞`,"7 位 momentId 没有可查询点赞状态的接口。请改传该动态的 uuid 或 /feed/main/detail/<uuid> 链接"+"(recommend / search / experience / my 的 uuid、url 列)。");return n}export async function resolveMomentId(t,e){const{ref:n,form:o}=parsePostRef(e);if(o!=="uuid")return n;return(await resolvePostTarget(t,e)).id}export async function resolveReplyTarget(t,e,n,o){if(!/^\d+$/.test(n))throw new f("--to-comment 必须是评论 ID");const r=requireOk(await getJson(t,`${GW_BASE}/detail/comment-terminal/${n}`),"回复目标").data;if(!r||String(r.id)!==n||!r.authorId)throw new d("牛客回复目标缺少评论 ID 或作者信息");const s=String(r.rootLongId??r.rootId??r.entryId??""),a=Number(r.rootType??r.entryType);if(s!==e.id||a!==e.entityType)throw new f("目标评论不属于指定帖子,已停止回复");const u=String(r.authorId);if(o!=="0"&&o!==u)throw new f("--to-user 与目标评论的实际作者不一致");const c=Number(r.entryType)===2?String(r.entryId):n;if(!/^\d+$/.test(c))throw new d("牛客回复目标缺少父评论 ID");return{id:c,entityType:2,authorId:u}}export function peerUidFromConversationId(t,e){const n=String(t??"").split("_");if(n.length!==2||!n.every((o)=>/^\d+$/.test(o)))return"";if(n[0]===n[1])return n[0];return n.find((o)=>o!==String(e))??""}export async function resolveConversation(t,e,n){const o=String(e??"").trim();if(!o)throw new d("缺少会话标识");if(o.includes("_")){const i=peerUidFromConversationId(o,n);if(!i)throw new d(`无法解析牛客会话 id: ${e}(应形如 <uidA>_<uidB>)`);return{conversationId:o,peerUid:i}}if(!/^\d+$/.test(o))throw new d(`无法解析牛客私信标识: ${e}(应为对方 userId 或 dm-list 的 conversation_id)`);for(let i=1;i<=5;i+=1){const s=requireOk(await getJson(t,`${WWW_BASE}/sns/message/${n}/get-conversation-list?page=${i}&_=${Date.now()}`),"私信会话列表").data?.conversations??[];if(!s.length)break;const a=s.find((u)=>String(u?.targetUserId??"")===o);if(a?.conversationId)return{conversationId:String(a.conversationId),peerUid:o}}throw new d(`在前 5 页会话列表里没找到与用户 ${o} 的会话(对方从未与你私信过时会话尚不存在,先用 dm-send 发起)`)}export function decodeHtmlEntities(t){return String(t??"").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/g,"'").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/&#(\d+);/g,(e,n)=>String.fromCodePoint(Number(n))).replace(/&/g,"&")}
|
|
60
|
+
`);return[]}export function postUrl({entityType:t,id:e,uuid:n}){if(Number(t)===74)return n?`${WWW_BASE}/feed/main/detail/${n}`:null;if(Number(t)===250)return/^\d{15,}$/.test(String(e??""))?`${WWW_BASE}/discuss/${e}`:null;return null}export function toIso(t){const e=Number(t);return Number.isFinite(e)&&e>0?new Date(e).toISOString():""}export function plainText(t){return decodeHtmlEntities(String(t??"").replace(/<img\b[^>]*?\bdata-card-emoji\s*=\s*(["'])(.*?)\1[^>]*>/gi,"$2").replace(/<[^>]+>/g,"")).trim()}export function feedRecordToPost(t){const e=Number(t?.contentType),n=t?.momentData,o=t?.contentData,i=n??o??{},r=t?.frequencyData??null,s=t?.userBrief??{},a=n?String(n.id??""):String(o?.id??""),u=String(i.uuid??"");return{writeId:a,uuid:u,entityType:Number.isFinite(e)?e:null,url:postUrl({entityType:e,id:a,uuid:u}),title:plainText(i.title??i.newTitle),content:plainText(i.content??i.newContent),author:String(s.nickname??""),userId:String(s.userId??i.userId??i.authorId??""),school:String(s.educationInfo??""),likes:r?Number(r.likeCnt??0):null,comments:r?Number(r.totalCommentCnt??r.commentCnt??0):null,views:r?Number(r.viewCnt??0):null,liked:r&&typeof r.isLike==="boolean"?r.isLike:null,time:toIso(n?n.createdAt:o?.createTime)}}function h(t,e){return new NowcoderError("NOT_VISIBLE",`牛客帖子 ${t} 不可见${e?`: ${e}`:""}`,"帖子存在但当前账号看不到:多为仅作者可见、审核中或已删除。不是 id 抄错,也不是登录问题,重试无用。",l.EMPTY_RESULT)}export function parsePostRef(t){if(typeof t==="number"&&!Number.isSafeInteger(t))throw new f("牛客帖子 ID 已丢失精度,请传推荐结果中的原始字符串 ID");const e=String(t??"").trim(),n=e.match(/detail\/([0-9a-fA-F]{20,})/)?.[1]??e.match(/\/discuss\/(\d+)/)?.[1]??e;if(/^\d+$/.test(n))return{ref:n,form:BigInt(n)>BigInt(Number.MAX_SAFE_INTEGER)?"snowflake":"short"};if(/^[0-9a-fA-F]{20,}$/.test(n))return{ref:n,form:"uuid"};throw new f(`无法从输入解析牛客帖子 id: ${t}`,"可传 18 位讨论帖 id、32 位动态 uuid、7 位 momentId 或帖子链接。")}export async function resolvePostTarget(t,e){const{ref:n,form:o}=parsePostRef(e);if(o==="short")return{id:n,entityType:74,authorId:"",uuid:"",url:null,detail:null,liked:null,likeCount:null,totalComments:null,legacy:null};if(o==="snowflake"){const c=requireOk(await getJson(t,`${GW_BASE}/detail/content-data/detail/${n}`),"讨论帖解析",{id:e}).data;if(typeof c?.id==="number")throw new d("牛客讨论帖详情未返回匹配的原始字符串 ID");if(!c||c.id!==n)throw h(e,c?.showMessage?.message);const y=String(c.authorId??c.userBrief?.userId??"");if(!/^[1-9]\d*$/.test(y))throw new d("牛客讨论帖详情缺少作者 ID");const m=c.frequencyData??{};return{id:n,entityType:250,authorId:y,uuid:String(c.uuid??""),url:postUrl({entityType:250,id:n}),detail:c,liked:typeof m.isLike==="boolean"?m.isLike:null,likeCount:m.likeCnt??null,totalComments:m.totalCommentCnt??m.commentCnt??null,legacy:c.entityId&&c.entityType?{id:String(c.entityId),entityType:Number(c.entityType)}:null}}const r=requireOk(await getJson(t,`${GW_BASE}/detail/moment-data/detail/${n}`),"帖子解析",{id:e}).data;if(!r?.id)throw h(e,r?.showMessage?.message);const s=r.frequencyData??{},a=String(r.uuid??n);return{id:String(r.id),entityType:74,authorId:String(r.userId??""),uuid:a,url:postUrl({entityType:74,uuid:a}),detail:r,liked:typeof s.isLike==="boolean"?s.isLike:null,likeCount:s.likeCnt??null,totalComments:s.totalCommentCnt??s.commentCnt??null,legacy:null}}export async function readLikeState(t,e){const n=await resolvePostTarget(t,e);if(n.liked===null)throw new f(`读不到帖子 ${e} 当前是否已赞`,"7 位 momentId 没有可查询点赞状态的接口。请改传该动态的 uuid 或 /feed/main/detail/<uuid> 链接"+"(recommend / search / experience / my 的 uuid、url 列)。");return n}export async function resolveMomentId(t,e){const{ref:n,form:o}=parsePostRef(e);if(o!=="uuid")return n;return(await resolvePostTarget(t,e)).id}export async function resolveReplyTarget(t,e,n,o){if(!/^\d+$/.test(n))throw new f("--to-comment 必须是评论 ID");const r=requireOk(await getJson(t,`${GW_BASE}/detail/comment-terminal/${n}`),"回复目标").data;if(!r||String(r.id)!==n||!r.authorId)throw new d("牛客回复目标缺少评论 ID 或作者信息");const s=String(r.rootLongId??r.rootId??r.entryId??""),a=Number(r.rootType??r.entryType);if(s!==e.id||a!==e.entityType)throw new f("目标评论不属于指定帖子,已停止回复");const u=String(r.authorId);if(o!=="0"&&o!==u)throw new f("--to-user 与目标评论的实际作者不一致");const c=Number(r.entryType)===2?String(r.entryId):n;if(!/^\d+$/.test(c))throw new d("牛客回复目标缺少父评论 ID");return{id:c,entityType:2,authorId:u}}export function peerUidFromConversationId(t,e){const n=String(t??"").split("_");if(n.length!==2||!n.every((o)=>/^\d+$/.test(o)))return"";if(n[0]===n[1])return n[0];return n.find((o)=>o!==String(e))??""}export async function resolveConversation(t,e,n){const o=String(e??"").trim();if(!o)throw new d("缺少会话标识");if(o.includes("_")){const i=peerUidFromConversationId(o,n);if(!i)throw new d(`无法解析牛客会话 id: ${e}(应形如 <uidA>_<uidB>)`);return{conversationId:o,peerUid:i}}if(!/^\d+$/.test(o))throw new d(`无法解析牛客私信标识: ${e}(应为对方 userId 或 dm-list 的 conversation_id)`);for(let i=1;i<=5;i+=1){const s=requireOk(await getJson(t,`${WWW_BASE}/sns/message/${n}/get-conversation-list?page=${i}&_=${Date.now()}`),"私信会话列表").data?.conversations??[];if(!s.length)break;const a=s.find((u)=>String(u?.targetUserId??"")===o);if(a?.conversationId)return{conversationId:String(a.conversationId),peerUid:o}}throw new d(`在前 5 页会话列表里没找到与用户 ${o} 的会话(对方从未与你私信过时会话尚不存在,先用 dm-send 发起)`)}export function decodeHtmlEntities(t){return String(t??"").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/g,"'").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/&#(\d+);/g,(e,n)=>String.fromCodePoint(Number(n))).replace(/&/g,"&")}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{ArgumentError as
|
|
2
|
-
const state = (${
|
|
1
|
+
import{ArgumentError as E,CommandExecutionError as u}from"@jackwener/opencli/errors";import{commentId as _,commentNote as g,commentSnapshot as h,locateComment as k,openCommentPage as S,readCommentPage as q,reloadCommentPage as A}from"./comment-state.js";const P="#content-textarea",R=".engage-bar.active button.submit",O=".engage-bar.active button.cancel",v="/api/sns/web/v1/comment/post",N="The action may already have succeeded. Read comments/replies to verify before retrying; this command did not resubmit.";async function b(t,n,a){if(await t.evaluate(`(() => {
|
|
2
|
+
const state = (${q.toString()})(${JSON.stringify(n)});
|
|
3
3
|
if (state.error) return false;
|
|
4
4
|
const controls = document.querySelectorAll(${JSON.stringify(a)});
|
|
5
5
|
if (controls.length !== 1 || controls[0].disabled || !controls[0].getClientRects().length) return false;
|
|
6
6
|
controls[0].click();
|
|
7
7
|
return true;
|
|
8
|
-
})()`)!==!0)throw new
|
|
9
|
-
`).replace(/\u00a0/g," ").trim()}function
|
|
8
|
+
})()`)!==!0)throw new u("Exact comment control is unavailable, disabled, or the note changed")}function f(t){return String(t).replace(/\r\n/g,`
|
|
9
|
+
`).replace(/\u00a0/g," ").trim()}function T(t,n,a){const e=t.editor;if(!e?.active||!e.canSend||f(e.text)!==f(a))throw new u("Comment draft did not retain the exact text or the send button is disabled");if(n?e.replyAuthor!==`回复 ${n.author}`||f(e.replyText)!==f(n.text):e.replyAuthor!==""||e.replyText!=="")throw new u("Reply target in the composer does not match the requested comment")}async function D(t,n){if(n)return`platform response not captured (${n})`;let a;try{a=await t.getInterceptedRequests()}catch(r){return`platform response not captured (${r instanceof Error?r.message:String(r)})`}if(!Array.isArray(a)||a.length===0)return`no ${v} request was observed after clicking send (the click did not reach the platform)`;const e=a.slice(-3).map((r)=>{const c=r?.code??"n/a",l=r?.success??"n/a",i=String(r?.msg??r?.message??"").slice(0,120);return`code=${c} success=${l}${i?` msg=${i}`:""}`});return`platform response to ${v}: ${e.join("; ")}`}export const writeArgs=[{name:"root-id",help:"Top-level root_id from comments; use when targeting a nested reply"},{name:"execute",type:"boolean",default:!1,help:"Submit after verification (default: dry-run only)"}],writeColumns=["status","note_id","id","root_id","parent_id","text","url"];export async function runComment(t,n){const{url:a,noteId:e}=g(n["note-id"]),r=n.text;if(typeof r!=="string"||!r.trim())throw new E("Comment text must not be empty");const c=n["reply-to"]==null?null:_(n["reply-to"],"reply-to"),l=n["root-id"]==null?null:_(n["root-id"],"root-id");if(l&&!c)throw new E("--root-id requires --reply-to (or the reply command)");let i=await S(t,a,e);if(i.editor?.text?.trim())throw new u("Existing comment draft is not empty; refusing to overwrite it");let d=null;if(c)({state:i,target:d}=await k(t,e,c,l));if(!i.selfId)throw new u("Cannot identify the current account for comment verification");const y=i.rows.filter((o)=>o.userId===i.selfId&&o.parent_id===c&&f(o.text)===f(r));if(y.length){const o=y[0];return[{status:"already-present",note_id:e,id:o.id,root_id:o.root_id,parent_id:o.parent_id,text:o.text,url:a}]}const C=new Set(i.rows.map((o)=>o.id));if(d)await b(t,e,`#comment-${d.id} .reply`);else if(!i.editor?.active)await t.click(".engage-bar:has(#content-textarea) .not-active");let p=!1;for(let o=0;o<10;o++){await t.wait({time:0.2});if((await h(t,e)).editor?.active){p=!0;break}}if(!p)throw new u("Comment composer did not open");await t.typeText(P,r);await t.wait({time:0.2});i=await h(t,e);T(i,d,r);if(!n.execute){await b(t,e,O);let o=!1;for(let s=0;s<10;s++){await t.wait({time:0.3});const w=await h(t,e);if(w.editor?.text===""&&!w.editor.active){o=!0;break}}if(!o)throw new u("Dry-run draft was verified but could not be cleared");return[{status:"dry-run",note_id:e,id:null,root_id:d?.root_id??null,parent_id:c,text:r,url:a}]}T(await h(t,e),d,r);let m=null;try{await t.installInterceptor(v)}catch(o){m=o instanceof Error?o.message:String(o)}try{await b(t,e,R);let o;for(let w=0;w<15;w++){await t.wait({time:0.5});o=(await h(t,e)).rows.find((x)=>!C.has(x.id)&&x.userId===i.selfId&&x.parent_id===c&&(!d||x.root_id===d.root_id)&&f(x.text)===f(r));if(o)break}if(!o){const w=await D(t,m);throw Error(`No new matching comment appeared; ${w}`)}await A(t,e);const{target:s}=await k(t,e,o.id,d?.root_id??null);if(s.userId!==i.selfId||s.parent_id!==c||f(s.text)!==f(r))throw Error("Persisted comment does not match the requested author, text and reply target");return[{status:"posted",note_id:e,id:s.id,root_id:s.root_id,parent_id:s.parent_id,text:s.text,url:a}]}catch(o){throw new u(`Comment submission could not be confirmed: ${o.message}`,N)}}export async function runCommentLike(t,n){const{url:a,noteId:e}=g(n["note-id"]),r=_(n["comment-id"]),c=n["root-id"]==null?null:_(n["root-id"],"root-id"),l=!n.undo;await S(t,a,e);const{target:i}=await k(t,e,r,c),d=(m)=>[{status:m,note_id:e,id:r,root_id:i.root_id,liked:l,url:a}];if(i.liked===l)return d(l?"already-liked":"already-unliked");const y=`#comment-${r} .like-wrapper`;if(await t.evaluate(`document.querySelectorAll(${JSON.stringify(y)}).length`)!==1)throw new u("Exact comment like control is unavailable or ambiguous");if(!n.execute)return[{status:"dry-run",note_id:e,id:r,root_id:i.root_id,liked:i.liked,url:a}];const p=(await h(t,e)).rows.find((m)=>m.id===r);if(!p||p.liked!==i.liked)throw new u("Comment like state changed before the click; stopped");try{await b(t,e,y);let m=!1;for(let s=0;s<10;s++){await t.wait({time:0.5});if((await h(t,e)).rows.find((I)=>I.id===r)?.liked===l){m=!0;break}}if(!m)throw Error("Like state did not change");await A(t,e);const{target:o}=await k(t,e,r,i.root_id);if(o.liked!==l)throw Error("Like state did not persist after reload");return d(l?"liked":"unliked")}catch(m){throw new u(`Comment like could not be confirmed: ${m.message}`,N)}}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import{cli as
|
|
1
|
+
import{cli as g,Strategy as w}from"@jackwener/opencli/registry";import{AuthRequiredError as x,CommandExecutionError as l,EmptyResultError as b}from"@jackwener/opencli/errors";import{parseNoteId as _,buildNoteUrl as k}from"./note-helpers.js";import{readXhsDetailPage as S}from"./risk-control.js";import{readCommentPage as R}from"./_shared/comment-state.js";const C='.author-wrapper a[href*="/user/profile/"], a.name[href*="/user/profile/"], a.user-name[href*="/user/profile/"], a[href*="/user/profile/"]';export function parseXhsProfileHref(r,t="www.xiaohongshu.com"){const e=typeof r==="string"?r.trim():"";if(!e)return"";const o=String(t||"www.xiaohongshu.com").toLowerCase();let n;try{n=new URL(e,`https://${o}`)}catch{return""}if(n.protocol!=="https:")return"";if(n.hostname.toLowerCase()!==o)return"";return n.pathname.match(/^\/user\/profile\/([a-zA-Z0-9]+)\/?$/)?.[1]??""}export function buildXhsProfileUrl(r,t="www.xiaohongshu.com"){const e=parseXhsProfileHref(r,t);if(!e)return"";return`https://${t}/user/profile/${e}`}export function parseCommentLimit(r,t=20){const e=Number(r);if(!Number.isFinite(e))return t;return Math.max(1,Math.min(Math.floor(e),50))}export function parseRepliesLimit(r,t=3){if(r===void 0||r===null||r==="")return t;const e=Number(r);if(!Number.isFinite(e)||e<0)return t;return Math.floor(e)}export function parseXhsLikeCountText(r){const t=/^(?:\d+|\d{1,3}(?:[,,]\d{3})+)\+?$/u,e=/^((?:\d+|\d{1,3}(?:[,,]\d{3})+)(?:\.\d+)?)([wWkK万千])\+?$/u,o=String(r??"").replace(/\s+/g,"");if(!o)return 0;if(t.test(o))return Number(o.replace(/[,+,]/g,""));const n=o.match(e);if(!n)return 0;const s=Number(n[1].replace(/[,,]/g,""));if(!Number.isFinite(s))return 0;const a=n[2].toLowerCase();return Math.round(s*(a==="w"||a==="万"?1e4:1000))}function u(r,t,e){if(r==null)return"";if(typeof r!=="string")throw new l(`${e}: malformed comment row ${t}`);return r}export function normalizeCommentImages(r,t){if(r==null)return[];if(!Array.isArray(r))throw new l(`${t}: malformed comment row images`);const e=[];for(const o of r){if(typeof o!=="string")throw new l(`${t}: malformed comment row image URL`);const n=o.trim();let s;try{s=new URL(n)}catch{throw new l(`${t}: malformed comment row image URL`)}if(s.protocol!=="https:"&&s.protocol!=="http:"||s.username||s.password)throw new l(`${t}: malformed comment row image URL`);const a=s.toString();if(!e.includes(a))e.push(a)}return e}export function normalizeCommentRows(r,t="xiaohongshu/comments"){if(r==null)return[];if(!Array.isArray(r))throw new l(`${t}: malformed comments payload`);return r.map((e,o)=>{if(!e||typeof e!=="object"||Array.isArray(e))throw new l(`${t}: malformed comment row at index ${o}`);const n=u(e.text,"text",t);if(!n)throw new l(`${t}: malformed comment row text`);const s=Number(e.likes);if(!Number.isInteger(s)||s<0)throw new l(`${t}: malformed comment row likes`);if(typeof e.is_reply!=="boolean")throw new l(`${t}: malformed comment row is_reply`);return{id:e.id??null,root_id:e.root_id??null,parent_id:e.parent_id??null,liked:e.liked??null,reply_count:e.reply_count??null,replies_complete:e.replies_complete??null,author:u(e.author,"author",t),authorHrefRaw:u(e.authorHrefRaw,"authorHrefRaw",t),text:n,likes:s,time:u(e.time,"time",t),is_reply:e.is_reply,reply_to:u(e.reply_to,"reply_to",t),images:normalizeCommentImages(e.images,t)}})}export function compactCommentRow(r){const t={};for(const[e,o]of Object.entries(r)){if(o===null||o===void 0||o==="")continue;if(Array.isArray(o)&&o.length===0)continue;if(e==="root_id"&&o===r.id)continue;t[e]=o}return t}export function buildCommentsExtractJs(r,t=20,e=null,o=0){const n=parseXhsLikeCountText.toString();return`
|
|
2
2
|
(async () => {
|
|
3
3
|
const wait = (ms) => new Promise(r => setTimeout(r, ms))
|
|
4
4
|
const withReplies = ${r}
|
|
5
5
|
const targetCount = ${Number(t)||20}
|
|
6
|
+
const repliesCap = ${Math.max(0,Math.floor(Number(o)||0))}
|
|
6
7
|
|
|
7
8
|
// Check login state
|
|
8
9
|
const bodyText = document.body?.innerText || ''
|
|
@@ -48,11 +49,11 @@ import{cli as h,Strategy as d}from"@jackwener/opencli/registry";import{AuthRequi
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const clean = (el) => (el?.textContent || '').replace(/\\s+/g, ' ').trim()
|
|
51
|
-
const parseLikeCountText = ${
|
|
52
|
+
const parseLikeCountText = ${n}
|
|
52
53
|
const parseLikes = (el) => {
|
|
53
54
|
return parseLikeCountText(clean(el))
|
|
54
55
|
}
|
|
55
|
-
const HREF_SELECTOR = ${JSON.stringify(
|
|
56
|
+
const HREF_SELECTOR = ${JSON.stringify(C)}
|
|
56
57
|
const extractAuthorHref = (el) => {
|
|
57
58
|
if (!el) return ''
|
|
58
59
|
const anchor = el.querySelector(HREF_SELECTOR)
|
|
@@ -80,6 +81,7 @@ import{cli as h,Strategy as d}from"@jackwener/opencli/registry";import{AuthRequi
|
|
|
80
81
|
const el = root.querySelector('.show-more')
|
|
81
82
|
if (!el) break
|
|
82
83
|
const before = root.querySelectorAll('.comment-item-sub').length
|
|
84
|
+
if (repliesCap > 0 && before >= repliesCap) break
|
|
83
85
|
el.click()
|
|
84
86
|
let progressed = false
|
|
85
87
|
for (let attempt = 0; attempt < 10; attempt++) {
|
|
@@ -146,7 +148,7 @@ import{cli as h,Strategy as d}from"@jackwener/opencli/registry";import{AuthRequi
|
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
if (${JSON.stringify(e)} !== null && !loginWall && !securityBlock) {
|
|
149
|
-
const state = (${
|
|
151
|
+
const state = (${R.toString()})(${JSON.stringify(e)})
|
|
150
152
|
if (state.error) return { pageUrl: location.href, securityBlock, loginWall, identityError: state.error }
|
|
151
153
|
for (const row of results) {
|
|
152
154
|
const entry = state.rows.find(c => c.id === row.id)
|
|
@@ -157,4 +159,4 @@ import{cli as h,Strategy as d}from"@jackwener/opencli/registry";import{AuthRequi
|
|
|
157
159
|
}
|
|
158
160
|
return { pageUrl: location.href, securityBlock, loginWall, results }
|
|
159
161
|
})()
|
|
160
|
-
`}export const command=
|
|
162
|
+
`}export const command=g({site:"xiaohongshu",name:"comments",access:"read",description:"获取小红书笔记评论(支持楼中楼子回复)",domain:"www.xiaohongshu.com",strategy:w.COOKIE,navigateBefore:!1,args:[{name:"note-id",required:!0,positional:!0,help:"Full Xiaohongshu note URL with xsec_token"},{name:"limit",type:"int",default:20,help:"Number of top-level comments (max 50)"},{name:"with-replies",type:"boolean",default:!1,help:"Include nested replies (楼中楼)"},{name:"replies-limit",type:"int",default:3,help:"With --with-replies: max nested replies per top-level comment (default 3, 0 = all). Capped threads show replies_complete=false; read a whole thread with `replies <url> <root-id>`"}],columns:["rank","id","root_id","parent_id","author","userId","text","likes","liked","time","is_reply","reply_to","reply_count","replies_complete","images"],func:async(r,t)=>{const e=parseCommentLimit(t.limit),o=Boolean(t["with-replies"]),n=parseRepliesLimit(t["replies-limit"]),s=String(t["note-id"]),a=_(s),c=await S(r,{url:k(s,{commandName:"xiaohongshu comments"}),extractJs:buildCommentsExtractJs(o,e,a,n),securityHelp:/^https?:\/\//.test(s)?"The page may be temporarily restricted. Try again later or from a different session.":"Try using a full URL from search results (with xsec_token) instead of a bare note ID."});if(!c||typeof c!=="object")throw new b("xiaohongshu/comments","Unexpected evaluate response");if(c.loginWall)throw new x("www.xiaohongshu.com","Note comments require login");if(c.identityError)throw new l(`xiaohongshu/comments: ${c.identityError}`);const d=normalizeCommentRows(c.results,"xiaohongshu/comments"),y=(i,m)=>compactCommentRow({rank:m+1,id:i.id,root_id:i.root_id,parent_id:i.parent_id,author:i.author,userId:i.authorHrefRaw?parseXhsProfileHref(i.authorHrefRaw):"",text:i.text,likes:i.likes,liked:i.liked,time:i.time,is_reply:i.is_reply,reply_to:i.reply_to,reply_count:i.reply_count,replies_complete:i.replies_complete,images:i.images??[]});if(o){const i=[];let m=0,p=null,f=0;for(const h of d){if(!h.is_reply){m++;if(m>e)break;p={...h};f=0;i.push(p);continue}if(n>0&&f>=n){if(p)p.replies_complete=!1;continue}f++;i.push(h)}return i.map(y)}return d.slice(0,e).map(y)}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/topics.js";import{XHS_PUBLISH_ARGS as wt,validateXhsSettings as gt,setXhsPublishSettings as _t}from"./_shared/publish-settings.js";import*as O from"node:fs";import*as N from"node:path";import{CommandExecutionError as u,ArgumentError as b}from"@jackwener/opencli/errors";import{cli as xt,Strategy as yt}from"@jackwener/opencli/registry";import{assertLiteralContent as vt}from"../_shared/content-guard.js";import{setInputFiles as St}from"../_shared/file-inject.js";import{humanType as
|
|
1
|
+
import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/topics.js";import{XHS_PUBLISH_ARGS as wt,validateXhsSettings as gt,setXhsPublishSettings as _t}from"./_shared/publish-settings.js";import*as O from"node:fs";import*as N from"node:path";import{CommandExecutionError as u,ArgumentError as b}from"@jackwener/opencli/errors";import{cli as xt,Strategy as yt}from"@jackwener/opencli/registry";import{assertLiteralContent as vt}from"../_shared/content-guard.js";import{setInputFiles as St}from"../_shared/file-inject.js";import{humanType as H,humanWait as I,humanMoveTo as Tt,elementViewportCenter as kt}from"./human.js";import{loadNoteManagerNotes as $t}from"./_shared/note-manager.js";const At="https://creator.xiaohongshu.com/publish/publish?from=menu_left&target=image",F=18,X=20,G=3000,B="|||",k="基础",Y=[["基础","默认兜底,万能"],["边框","金句/要点卡"],["备忘","提醒/随手记"],["清新","日常/清单贴士"],["涂写","随笔/碎碎念"],["便签","笔记/提醒"],["光影","情绪/文艺"],["涂鸦","趣味/童话"],["简约","干货/观点"],["手写","日记/情感"],["插图","生活方式/轻松话题"],["美漫","活力/趣味/故事感"],["弥散","弥散光氛围"],["柔和","柔和/温柔金句"],["印刷","印刷海报/排版"],["科技","科技/产品"],["贺卡","节日祝福"],["札记","艺术/水彩氛围"],["书摘","书摘/引用"],["手帐","手帐拼贴"],["几何","醒目/有力主张"]],ae=Y.map(([t])=>t),U="文字配图",K="再写一张",W="生成图片",Q="下一步",j=".tiptap.ProseMirror",Et=["_onPublish","onPublish","_onSubmit","_handlePublish"],Ct=["_onSave","_onSaveDraft","_onDraft"],Z=['[contenteditable="true"][placeholder*="标题"]','[contenteditable="true"][placeholder*="赞"]','input[placeholder*="标题"]','input[placeholder*="title" i]','[contenteditable="true"][class*="title"]','input[maxlength="20"]','input[class*="title"]',".title-input input",".note-title input","input[maxlength]"],tt=['[contenteditable="true"][class*="content"]','[contenteditable="true"][class*="editor"]','[contenteditable="true"][placeholder*="描述"]','[contenteditable="true"][placeholder*="正文"]','[contenteditable="true"][placeholder*="内容"]','.note-content [contenteditable="true"]','.editor-content [contenteditable="true"]','[contenteditable="true"]:not([placeholder*="标题"]):not([placeholder*="赞"]):not([placeholder*="title" i])'],Mt={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp"};function _(t){if(t&&typeof t==="object"&&typeof t.session==="string"&&Object.prototype.hasOwnProperty.call(t,"data"))return t.data;return t}function Nt(t){return t.map((e)=>{const r=N.resolve(e);if(!O.existsSync(r))throw new b(`Image file not found: ${r}`);const n=N.extname(r).toLowerCase();if(!Mt[n])throw new b(`Unsupported image format "${n}". Supported: jpg, png, gif, webp`);return r})}const et='input[type="file"][accept*="image"],input[type="file"][accept*=".jpg"],input[type="file"][accept*=".jpeg"],input[type="file"][accept*=".png"],input[type="file"][accept*=".gif"],input[type="file"][accept*=".webp"]';async function It(t,e=15000){const r=500,n=Math.max(1,Math.ceil(e/r));for(let o=0;o<n;o++){if(await t.evaluate(`
|
|
2
2
|
(() => {
|
|
3
3
|
const sels = ${JSON.stringify(et)};
|
|
4
4
|
return !!document.querySelector(sels);
|
|
@@ -117,7 +117,7 @@ import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/to
|
|
|
117
117
|
return { ok: true };
|
|
118
118
|
})(${JSON.stringify(o.sel)})
|
|
119
119
|
`))?.ok){await t.screenshot({path:`/tmp/xhs_publish_${n}_debug.png`});throw Error(`Could not prepare ${n} input. Debug screenshot: /tmp/xhs_publish_${n}_debug.png`)}await t.wait({time:0.35});try{const s=String(r).split(`
|
|
120
|
-
`);for(let d=0;d<s.length;d++){if(d>0)await Pt(t,o.sel,d);if(s[d])await
|
|
120
|
+
`);for(let d=0;d<s.length;d++){if(d>0)await Pt(t,o.sel,d);if(s[d])await H(t,s[d])}a=await t.evaluate(`
|
|
121
121
|
((selector, expectedText) => {
|
|
122
122
|
const __opencli_xhs_fill_phase = "verify";
|
|
123
123
|
const normalize = (value) => (value || '').replace(/\\s+/g, ' ').trim();
|
|
@@ -230,7 +230,7 @@ import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/to
|
|
|
230
230
|
`));if(i?.ok)return i;await t.wait({time:n/1000})}return i}async function Rt(t){const e=await t.evaluate(`
|
|
231
231
|
(() => {
|
|
232
232
|
const __opencli_xhs_focus_card = true;
|
|
233
|
-
const sel = ${JSON.stringify(
|
|
233
|
+
const sel = ${JSON.stringify(j)};
|
|
234
234
|
const editors = Array.from(document.querySelectorAll(sel)).filter((el) => el.offsetParent !== null);
|
|
235
235
|
// Prefer the editor inside the active swiper slide if present.
|
|
236
236
|
const active = editors.find((el) => el.closest('.swiper-slide-active')) || editors[editors.length - 1];
|
|
@@ -247,7 +247,7 @@ import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/to
|
|
|
247
247
|
`);return _(e)}async function qt(t){const e=await t.evaluate(`
|
|
248
248
|
(() => {
|
|
249
249
|
const __opencli_xhs_card_text = true;
|
|
250
|
-
const sel = ${JSON.stringify(
|
|
250
|
+
const sel = ${JSON.stringify(j)};
|
|
251
251
|
const editors = Array.from(document.querySelectorAll(sel)).filter((el) => el.offsetParent !== null);
|
|
252
252
|
const active = editors.find((el) => el.closest('.swiper-slide-active')) || editors[editors.length - 1];
|
|
253
253
|
const text = active ? (active.innerText || active.textContent || '').trim() : '';
|
|
@@ -256,7 +256,7 @@ import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/to
|
|
|
256
256
|
`);return _(e)}async function it(t){const e=await t.evaluate(`
|
|
257
257
|
(() => {
|
|
258
258
|
const __opencli_xhs_card_count = true;
|
|
259
|
-
const sel = ${JSON.stringify(
|
|
259
|
+
const sel = ${JSON.stringify(j)};
|
|
260
260
|
const editors = Array.from(document.querySelectorAll(sel)).filter((el) => el.offsetParent !== null);
|
|
261
261
|
const active = editors.find((el) => el.closest('.swiper-slide-active')) || editors[editors.length - 1];
|
|
262
262
|
const activeText = active ? (active.innerText || active.textContent || '').trim() : '';
|
|
@@ -271,7 +271,7 @@ import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/to
|
|
|
271
271
|
})()
|
|
272
272
|
`);return _(e)}async function Ut(t,e=6){const r=400,n=Math.ceil(3000/r);for(let o=0;o<e;o++){if(!(await A(t,W))?.ok&&o===0)return!1;for(let a=0;a<n;a++){if((await Bt(t))?.ok)return!0;await t.wait({time:r/1000})}}return!1}async function jt(t,e,r){e=String(e).replace(/\\n/g,`
|
|
273
273
|
`);if(!(await Rt(t))?.ok)throw new u(`文字配图: could not focus card editor #${r+1}`);if(typeof t.insertText==="function"){const i=e.split(`
|
|
274
|
-
`);for(let a=0;a<i.length;a++){if(a>0&&typeof t.pressKey==="function")await t.pressKey("Enter");if(i[a])await
|
|
274
|
+
`);for(let a=0;a<i.length;a++){if(a>0&&typeof t.pressKey==="function")await t.pressKey("Enter");if(i[a])await H(t,i[a])}}else await t.evaluate(`(t => document.execCommand('insertText', false, t))(${JSON.stringify(e)})`);await t.wait({time:0.4});if(!(await qt(t))?.ok)throw new u(`文字配图: card editor #${r+1} is empty after typing`)}async function Jt(t,e){if(!e||e===k)return k;const r=_(await t.evaluate(`
|
|
275
275
|
(async () => {
|
|
276
276
|
const __opencli_xhs_card_styles = true;
|
|
277
277
|
const want = ${JSON.stringify(e)};
|
|
@@ -313,7 +313,7 @@ import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/to
|
|
|
313
313
|
.length;
|
|
314
314
|
return { ok: true, count };
|
|
315
315
|
})()
|
|
316
|
-
`);return _(e)}async function st(t,e,r){const n=await at(t);if(!n||typeof n.count!=="number")throw new u(`${r}: could not verify current composer media count`);if(n.count<e){await t.screenshot({path:"/tmp/xhs_publish_media_debug.png"});throw new u(`${r}: expected at least ${e} visible media item(s), got ${n.count}. Debug screenshot: /tmp/xhs_publish_media_debug.png`)}}async function Vt(t,e,r){if(!(await A(t,
|
|
316
|
+
`);return _(e)}async function st(t,e,r){const n=await at(t);if(!n||typeof n.count!=="number")throw new u(`${r}: could not verify current composer media count`);if(n.count<e){await t.screenshot({path:"/tmp/xhs_publish_media_debug.png"});throw new u(`${r}: expected at least ${e} visible media item(s), got ${n.count}. Debug screenshot: /tmp/xhs_publish_media_debug.png`)}}async function Vt(t,e,r){if(!(await A(t,U))?.ok){await t.screenshot({path:"/tmp/xhs_publish_textimage_debug.png"});throw new u(`文字配图: could not click "${U}" entry. Debug: /tmp/xhs_publish_textimage_debug.png`)}if(!await Lt(t)){await t.screenshot({path:"/tmp/xhs_publish_textimage_debug.png"});throw new u(`文字配图: 写文字 card editor did not appear after clicking "${U}". Debug: /tmp/xhs_publish_textimage_debug.png`)}for(let l=0;l<e.length;l++){if(l>0){if(!await Ft(t,l+1)){await t.screenshot({path:"/tmp/xhs_publish_addcard_debug.png"});throw new u(`文字配图: new card editor #${l+1} did not render after "${K}". Debug: /tmp/xhs_publish_addcard_debug.png`)}}await jt(t,e[l],l)}if(!await Ut(t)){await t.screenshot({path:"/tmp/xhs_publish_generate_debug.png"});throw new u(`文字配图: "${W}" did not advance to the 预览图片 step. `+"Debug: /tmp/xhs_publish_generate_debug.png")}const i=await Jt(t,r);if(!(await A(t,Q))?.ok){await t.screenshot({path:"/tmp/xhs_publish_next_debug.png"});throw new u(`文字配图: could not click "${Q}". Debug: /tmp/xhs_publish_next_debug.png`)}await t.wait({time:2});return i}async function lt(t){return t.evaluate(`
|
|
317
317
|
() => {
|
|
318
318
|
const text = (document.body?.innerText || '').replace(/s+/g, ' ').trim();
|
|
319
319
|
const hasTitleInput = !!Array.from(document.querySelectorAll('input, textarea')).find((el) => {
|
|
@@ -389,7 +389,7 @@ import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/to
|
|
|
389
389
|
}
|
|
390
390
|
return removed;
|
|
391
391
|
})(${JSON.stringify(e)})
|
|
392
|
-
`));return Number(r)||0}function Gt(t){const e=String(t&&(t.url||t.key)||""),r=String(t&&t.method||"").toUpperCase(),n=Number(t&&t.status||0);if(r!=="PUT")return null;if(!/ros-upload[^/]*\/spectrum\//.test(e))return null;if(n<200||n>=300)return null;const o=e.match(/\/spectrum\/([^?#]+)/);return o?o[1]:e}function ut(t){return Math.min(45,6+t*4)}async function dt(t,e,r,n=90000){if(e<=0)return{ok:!0,completed:0};if(!r||typeof t.readNetworkCapture!=="function"){await t.wait({time:ut(e)});return{ok:!0,completed:null,viaFallback:!0}}const o=1500,a=Math.ceil(9000/o),l=Math.ceil(n/o),s=new Set;for(let d=0;d<l;d++){const w=await t.readNetworkCapture().catch(()=>[]);for(const v of Array.isArray(w)?w:[]){const m=Gt(v);if(m)s.add(m)}if(s.size>=e)return{ok:!0,completed:s.size};if(d>=a&&s.size===0){await t.wait({time:ut(e)});return{ok:!0,completed:null,viaFallback:!0}}await t.wait({time:o/1000})}return{ok:!1,completed:s.size}}const
|
|
392
|
+
`));return Number(r)||0}function Gt(t){const e=String(t&&(t.url||t.key)||""),r=String(t&&t.method||"").toUpperCase(),n=Number(t&&t.status||0);if(r!=="PUT")return null;if(!/ros-upload[^/]*\/spectrum\//.test(e))return null;if(n<200||n>=300)return null;const o=e.match(/\/spectrum\/([^?#]+)/);return o?o[1]:e}function ut(t){return Math.min(45,6+t*4)}async function dt(t,e,r,n=90000){if(e<=0)return{ok:!0,completed:0};if(!r||typeof t.readNetworkCapture!=="function"){await t.wait({time:ut(e)});return{ok:!0,completed:null,viaFallback:!0}}const o=1500,a=Math.ceil(9000/o),l=Math.ceil(n/o),s=new Set;for(let d=0;d<l;d++){const w=await t.readNetworkCapture().catch(()=>[]);for(const v of Array.isArray(w)?w:[]){const m=Gt(v);if(m)s.add(m)}if(s.size>=e)return{ok:!0,completed:s.size};if(d>=a&&s.size===0){await t.wait({time:ut(e)});return{ok:!0,completed:null,viaFallback:!0}}await t.wait({time:o/1000})}return{ok:!1,completed:s.size}}const J=3;export function pickPublishedNote(t,e,r=Date.now()){const n=String(e||"").trim();return(Array.isArray(t)?t:[]).filter((i)=>!i.sticky).slice(0,J).find((i)=>{const a=String(i.title||"").trim();if(!a||!(a===n||a.startsWith(n)||n.startsWith(a)))return!1;const l=String(i.time||"").match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})$/);if(!l)return!0;const s=Date.UTC(Number(l[1]),Number(l[2])-1,Number(l[3]),Number(l[4]),Number(l[5]))-28800000;return Math.abs(r-s)<=93600000})??null}async function Yt(t,e,r){let n="";for(let o=0;o<r;o++){if(o>0)await t.wait({time:3});let i;try{i=await $t(t,{tab:"all",limit:J+5})}catch(l){return{note:null,reason:`创作者后台笔记列表读取出错:${l?.message??String(l)}`}}const a=pickPublishedNote(i.notes,e);if(a)return{note:a,reason:""};n=i.notes.length===0?"创作者后台笔记列表为空":`创作者后台最新 ${Math.min(i.notes.length,J)} 条笔记里没有同标题笔记`}return{note:null,reason:n}}xt({site:"xiaohongshu",name:"publish",access:"write",description:"小红书发布图文笔记 (creator center UI automation)",domain:"creator.xiaohongshu.com",strategy:yt.COOKIE,browser:!0,navigateBefore:!1,args:[{name:"content",required:!1,positional:!0,help:"笔记正文(字面文本,不会展开 @文件 引用;长正文建议用 --file)"},{name:"file",required:!1,help:"从本机文件读取笔记正文(UTF-8),与位置参数 <content> 二选一"},{name:"title",required:!0,help:"笔记标题 (最多20字)"},{name:"images",required:!1,help:`图片路径,逗号分隔,最多${F}张 (jpg/png/gif/webp)`},{name:"card-text",required:!1,help:`文字配图卡片文字,多张卡片用 ${B} 分隔,卡内换行用 \\n。全部卡片写在同一个参数里并整体加引号,如 --card-text '第一张${B}第二张';分隔符两侧不要断开成多个参数`},{name:"card-style",required:!1,help:`文字配图卡片样式。省略时使用${k}。小红书按正文内容只开放下列样式中的一部分,不是每次都全有;所选样式当次不可用时会在提交前失败并列出当次可选项,按报错改选即可。样式参考: ${Y.map(([t,e])=>`${t}(${e})`).join(" ")}`},{name:"topics",required:!1,help:"话题名称,逗号分隔,最多10个;先用 topics 查询。无法准确选中时停止提交"},mt,{name:"draft",type:"bool",default:!1,help:"保存为草稿,不直接发布"},{name:"timeout",type:"int",default:300,help:"整段发布流程的等待预算(秒);超时后先用 creator-notes 回查,勿直接重复发布"},{name:"ai-generated",type:"boolean",help:"声明内容由 AI 生成(发布和草稿均支持;设置失败时停止提交)"},...wt],columns:["status","detail","url"],func:async(t,e)=>{gt(e);if(!t)throw Error("Browser page required");const r=String(e.title??"").trim(),n=e.file?String(e.file).trim():"";let o=String(e.content??"").trim();if(n){if(o)throw new b("正文位置参数和 --file 只能二选一,不能同时给");const c=N.resolve(n);if(!O.existsSync(c))throw new b(`--file 指向的文件不存在: ${c}`);o=O.readFileSync(c,"utf-8").trim();if(!o)throw new b(`--file 指向的文件内容为空: ${c}`)}const i=e.images?String(e.images).split(",").map((c)=>c.trim()).filter(Boolean):[],a=pt(e),l=a.map((c)=>c.name),s=Boolean(e.draft),d=e["card-text"]?String(e["card-text"]):"",w=d?d.split(B).map((c)=>c.trim()).filter(Boolean):[],v=e["card-style"]?String(e["card-style"]).trim():"",m=w.length>0;if(!r)throw new b("--title is required");if(r.length>X)throw new b(`Title is ${r.length} chars — must be ≤ ${X}`);if(!o)throw new b("缺少笔记正文:给位置参数 <content>(字面文本),或用 --file <本机文件路径>");vt(o,{fileFlag:"--file"});if(!m&&i.length===0)throw new b("Provide --card-text (text-image mode) or --images (upload mode); neither was given.");if(i.length>F)throw new b(`Too many images: ${i.length} (max ${F})`);if(m&&i.some((c)=>N.extname(c).toLowerCase()===".gif"))throw new b("文字配图模式追加的图片不支持 .gif(编辑器图片入口只接受 jpg/jpeg/png/webp)");const f=Nt(i);await t.goto(At);await t.wait({time:1});await t.evaluate("() => { try { window.onbeforeunload = null; } catch (e) {} location.reload(); }").catch(()=>{return});let x="";for(let c=0;c<30;c++){await t.wait({time:0.5});x=await t.evaluate("() => location.href");if(x.includes("creator.xiaohongshu.com"))break}if(!x.includes("creator.xiaohongshu.com")){await t.screenshot({path:"/tmp/xhs_publish_redirect_debug.png"});throw Error(`Redirected away from creator center (landed on ${x}) — session may have expired. `+"Re-capture browser login via: ppcli xiaohongshu creator-profile. Debug screenshot: /tmp/xhs_publish_redirect_debug.png")}const S=await Dt(t);if((await zt(t,S?.ok?5000:2000)).state==="video_surface"){await t.screenshot({path:"/tmp/xhs_publish_tab_debug.png"});const c=S?.ok?`clicked "${S.text}"`:`visible candidates: ${(S?.visibleTexts||[]).join(" | ")||"none"}`;throw Error("Still on the video publish page after trying to select 图文. "+`Details: ${c}. Debug screenshot: /tmp/xhs_publish_tab_debug.png`)}const E=await Xt(t);let C=v;if(m)C=await Vt(t,w,v);else{const c=typeof t.startNetworkCapture==="function"?await t.startNetworkCapture("").catch(()=>!1):!1,g=await nt(t,f);if(!g.ok){await t.screenshot({path:"/tmp/xhs_publish_upload_debug.png"});throw new u(`图片注入失败:${g.error??"unknown"}。`+"直接重新运行本 publish 命令即可(会自动重置发布页重传);请勿手动修改当前页面。"+"Debug: /tmp/xhs_publish_upload_debug.png")}await t.wait({time:G/1000});const y=await dt(t,f.length,c);if(!y.ok){await t.screenshot({path:"/tmp/xhs_publish_upload_debug.png"});throw new u(`图片上传未全部完成:只确认 ${y.completed}/${f.length} 张传到小红书 CDN,`+"继续发布会丢图(通常只剩封面)。直接重新运行本 publish 命令即可(会自动重置发布页重传);"+"请勿手动修改当前页面。Debug: /tmp/xhs_publish_upload_debug.png")}await rt(t);if(E.length){await ct(t,E);await t.wait({time:0.5})}const M=await at(t);if(M&&typeof M.count==="number"&&M.count>f.length){await t.screenshot({path:"/tmp/xhs_publish_dup_debug.png"});throw new u(`清掉恢复态旧图后编辑器内仍有 ${M.count} 张图,超过本次注入的 ${f.length} 张。`+"直接重新运行本 publish 命令即可(会自动重置发布页);请勿手动修改当前页面。Debug: /tmp/xhs_publish_dup_debug.png")}}if(!await Ht(t)){await t.screenshot({path:"/tmp/xhs_publish_form_debug.png"});throw new u("Editing form did not appear after image acquisition. The page layout may have changed. Debug screenshot: /tmp/xhs_publish_form_debug.png")}if(m)await st(t,w.length,"文字配图 generated images");if(m&&f.length>0){const c=typeof t.startNetworkCapture==="function"?await t.startNetworkCapture("").catch(()=>!1):!1,g=await nt(t,f);if(!g.ok){await t.screenshot({path:"/tmp/xhs_publish_append_debug.png"});throw new u(`追加图片失败:${g.error??"unknown"}。`+"直接重新运行本 publish 命令即可(会自动重置发布页重传);请勿手动修改当前页面。"+"Debug: /tmp/xhs_publish_append_debug.png")}await t.wait({time:G/1000});const y=await dt(t,f.length,c);if(!y.ok){await t.screenshot({path:"/tmp/xhs_publish_append_debug.png"});throw new u(`追加图片上传未全部完成:只确认 ${y.completed}/${f.length} 张传到小红书 CDN。`+"直接重新运行本 publish 命令即可(会自动重置发布页重传);请勿手动修改当前页面。"+"Debug: /tmp/xhs_publish_append_debug.png")}await rt(t);await st(t,w.length+f.length,"文字配图 appended images")}if(m&&E.length){await ct(t,E);await t.wait({time:0.5})}await ot(t,Z,r,"title");await I(t,0.6);await ot(t,tt,o,"content");await I(t,0.6);let P=[];if(l.length)P=await bt(t,tt,a);await _t(t,e);await I(t,1,0.6);const D=await kt(t,["xhs-publish-btn"]);if(D){await Tt(t,D.x,D.y);await I(t,0.4)}const V=s?["暂存离开","存草稿"]:["发布","发布笔记"],h=await t.evaluate(`
|
|
393
393
|
(cfg => {
|
|
394
394
|
const { isDraftMode, publishNames, draftNames, labels } = cfg;
|
|
395
395
|
const isVisible = (el) => {
|
|
@@ -428,7 +428,7 @@ import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/to
|
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
430
|
return { ok: false, via: 'none', hosts: hosts.length, lastMethodError };
|
|
431
|
-
})(${JSON.stringify({isDraftMode:s,publishNames:Et,draftNames:Ct,labels:
|
|
431
|
+
})(${JSON.stringify({isDraftMode:s,publishNames:Et,draftNames:Ct,labels:V})})
|
|
432
432
|
`);if(!h?.ok){if(s){if(await t.evaluate(`
|
|
433
433
|
(() => {
|
|
434
434
|
const labels = ['返回', '关闭', '取消', '离开'];
|
|
@@ -467,7 +467,7 @@ import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/to
|
|
|
467
467
|
}
|
|
468
468
|
return false;
|
|
469
469
|
}
|
|
470
|
-
`)){h.ok=!0;h.via="auto-save"}}}}if(!h?.ok){await t.screenshot({path:"/tmp/xhs_publish_submit_debug.png"});const c=h?.via?` (via=${h.via})`:"",g=h?.error?`, error=${h.error}`:"",y=h?.lastMethodError?`, lastMethodError=${h.lastMethodError}`:"";throw Error(`未能触发「${
|
|
470
|
+
`)){h.ok=!0;h.via="auto-save"}}}}if(!h?.ok){await t.screenshot({path:"/tmp/xhs_publish_submit_debug.png"});const c=h?.via?` (via=${h.via})`:"",g=h?.error?`, error=${h.error}`:"",y=h?.lastMethodError?`, lastMethodError=${h.lastMethodError}`:"";throw Error(`未能触发「${V[0]}」按钮${c}${g}${y}。`+"直接重新运行本 publish 命令即可(会自动重置发布页);请勿手动修改当前页面。"+"Debug: /tmp/xhs_publish_submit_debug.png")}await t.wait({time:4});const T=await t.evaluate("() => location.href"),ft=s?["草稿已保存","暂存成功","保存成功","保存于","图文笔记("]:["发布成功","上传成功"],z=await t.evaluate(`
|
|
471
471
|
(markers => {
|
|
472
472
|
for (const el of document.querySelectorAll('*')) {
|
|
473
473
|
if (el.tagName === 'STYLE' || el.tagName === 'SCRIPT') continue;
|
|
@@ -477,4 +477,4 @@ import{TOPIC_ID_ARG as mt,parseTopics as pt,attachTopics as bt}from"./_shared/to
|
|
|
477
477
|
}
|
|
478
478
|
return '';
|
|
479
479
|
})(${JSON.stringify(ft)})
|
|
480
|
-
`),ht=!T.includes("/publish/publish");let R=
|
|
480
|
+
`),ht=!T.includes("/publish/publish");let R=z.length>0||ht;const q=s?"暂存成功":"发布成功";let p=null,L="";if(!s){const c=await Yt(t,r,R?2:4);p=c.note;L=c.reason;if(p)R=!0}if(!R){if(s)throw new u(`${q}无法确认:未观察到成功提示或提交后跳转。`+(T?`当前 URL: ${T}。`:"当前 URL 为空。")+"先用 `xiaohongshu drafts` 查草稿箱确认是否已存上;确认没有再重新运行本命令,避免堆出重复草稿。");throw new u(`${q}无法确认:未观察到成功提示或提交后跳转,创作者后台也暂未查到同标题笔记(${L||"未回查到"})。`+(T?`当前 URL: ${T}。`:"")+"注意:发布按钮已被触发,笔记仍可能延迟入库。禁止立即重发——请等 1-2 分钟后用 `xiaohongshu creator-notes` 回查本篇标题是否已出现;确认不存在后才重新运行本 publish 命令,否则会重复发布。")}return[{status:`✅ ${q}`,detail:[`"${r}"`,m?`${w.length}张文字配图${f.length?` + ${f.length}张图片`:""}${C&&C!==k?` (${C})`:""}`:`${f.length}张图片`,P.length?`话题: ${P.join(" ")}`:"",p?.id?`笔记ID: ${p.id}`:"",z||(p?"已在创作者后台确认":"")||T||"",p?.id?p.noteUrl?"链接需登录小红书后打开":"链接为创作者后台数据页,需登录":"",!s&&!p?.id?`未回查到笔记ID(${L||"未回查到"}),稍后用 creator-notes 按标题查`:""].filter(Boolean).join(" · "),url:p?.id?p.noteUrl||`https://creator.xiaohongshu.com/statistics/note-detail?noteId=${p.id}`:""}]}});
|
package/clis/youtube/publish.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as x from"node:path";import{cli as P,Strategy as V}from"@jackwener/opencli/registry";import{ArgumentError as m,CommandExecutionError as u}from"@jackwener/opencli/errors";import{resolveVideoFile as O,resolveImageFile as C,setVideoInput as _,unwrap as c,currentUrl as N,waitForSelector as p,videoTimeoutArg as B,SUPPORTED_VIDEO_EXTENSIONS as S,SUPPORTED_IMAGE_EXTENSIONS as D}from"../_shared/video-publish.js";const R="https://www.youtube.com/upload";export function assertSingleVideoInput(t){const e=String(t??"").trim(),a="youtube publish 仅支持视频文件(一次一个),没有图文 / 图片集发布能力",n=e.split(",").map((s)=>s.trim()).filter(Boolean);if(n.length>1&&n.every((s)=>x.extname(s)))throw new m(`${a};收到 ${n.length} 个路径。`);const o=x.extname(e).toLowerCase();if(D.has(o))throw new m(`${a};收到的是图片文件(${o})。`);if(!S.has(o))throw new m(`${a};收到的文件扩展名是「${o||"无"}」,支持 ${[...S].join("/")}。`)}const E={public:"PUBLIC",unlisted:"UNLISTED",private:"PRIVATE"},d=`
|
|
2
2
|
function __ytNorm(v) { return (v || '').replace(/\\s+/g, ' ').trim(); }
|
|
3
3
|
function __ytVisible(el) {
|
|
4
4
|
if (!el || el.offsetParent === null) return false;
|
|
@@ -29,17 +29,17 @@ import*as v from"node:path";import{cli as T,Strategy as I}from"@jackwener/opencl
|
|
|
29
29
|
}
|
|
30
30
|
`;async function i(t,e,a=4000){const n=Date.now()+a;for(;;){if(Boolean(c(await t.evaluate(`
|
|
31
31
|
(() => {
|
|
32
|
-
${
|
|
32
|
+
${d}
|
|
33
33
|
var el = __ytResolve(${JSON.stringify(e)});
|
|
34
34
|
if (!el) return false;
|
|
35
35
|
el.click();
|
|
36
36
|
return true;
|
|
37
37
|
})()
|
|
38
|
-
`))))return!0;if(Date.now()>=n)return!1;await t.wait({time:0.4})}}async function
|
|
39
|
-
(() => { ${
|
|
40
|
-
`)))}async function
|
|
41
|
-
(() => { ${
|
|
42
|
-
`)))){await t.pressKey("Escape");await t.wait({time:0.2})}}catch{}}async function
|
|
38
|
+
`))))return!0;if(Date.now()>=n)return!1;await t.wait({time:0.4})}}async function f(t,e){return Boolean(c(await t.evaluate(`
|
|
39
|
+
(() => { ${d} return !!__ytResolve(${JSON.stringify(e)}); })()
|
|
40
|
+
`)))}async function L(t){try{await t.evaluate("() => { const a = document.activeElement; if (a && a.blur) a.blur(); }")}catch{}try{if(Boolean(c(await t.evaluate(`
|
|
41
|
+
(() => { ${d} return !!__ytResolve('tp-yt-iron-dropdown'); })()
|
|
42
|
+
`)))){await t.pressKey("Escape");await t.wait({time:0.2})}}catch{}}async function T(t,e,a){if(!await p(t,e,30000))throw new u(`YouTube 输入框未出现: ${e}`);await t.click(e);await t.pressKey("Control+a");await t.pressKey("Delete");await t.insertText(a);await t.wait({time:0.4});await L(t)}async function U(t,e=360){const a=/处理|检查|上传完成|已上传|Processing|complete|Checks|Finished/;for(let n=0;n<e;n++){const o=String(c(await t.evaluate(`
|
|
43
43
|
(() => {
|
|
44
44
|
const sels = ['.progress-label', 'span.progress-label', 'ytcp-video-upload-progress'];
|
|
45
45
|
for (const sel of sels) {
|
|
@@ -48,9 +48,9 @@ import*as v from"node:path";import{cli as T,Strategy as I}from"@jackwener/opencl
|
|
|
48
48
|
}
|
|
49
49
|
return '';
|
|
50
50
|
})()
|
|
51
|
-
`))||"");if(o&&a.test(o))return!0;await t.wait({time:5})}return!1}
|
|
51
|
+
`))||"");if(o&&a.test(o))return!0;await t.wait({time:5})}return!1}P({site:"youtube",name:"publish",access:"write",description:"Publish a video to YouTube via Studio (one command: upload + metadata + publish)",domain:"www.youtube.com",strategy:V.COOKIE,browser:!0,navigateBefore:!1,args:[{name:"video",required:!0,positional:!0,help:"Video file path(仅支持单个视频文件;不支持图片 / 图文)"},{name:"title",required:!0,help:"Video title (≤100 chars)"},{name:"description",fromFile:!0,default:"",help:"Video description"},{name:"tags",default:"",help:"Comma-separated tags"},{name:"thumbnail",default:"",help:"Thumbnail image path (optional)"},{name:"playlist",default:"",help:"Playlist name to add to (optional)"},{name:"visibility",default:"public",choices:["public","unlisted","private"],help:"Visibility"},B()],columns:["status","title","visibility","url"],func:async(t,e)=>{const a=String(e.title??"").trim();if(!a)throw new m("--title is required");assertSingleVideoInput(e.video);const n=O(e.video),o=String(e.description||""),s=e.thumbnail?C(e.thumbnail):"",w=String(e.playlist||"").trim(),h=E[e.visibility]?e.visibility:"public";await t.goto(R);await t.wait({time:3});const b=await N(t);if(/accounts\.google\.com/.test(b)||/signin/i.test(b))throw new u("YouTube 登录态失效,请先 ppcli youtube login");if(!await p(t,'input[type="file"]',60000))throw new u("YouTube 上传文件输入框未出现");await _(t,['input[type="file"]'],[n]);if(!await p(t,"#title-textarea",120000))throw new u("YouTube 视频详情对话框未出现");await T(t,"#title-textarea #textbox",a.slice(0,100));if(o.trim())await T(t,"#description-textarea #textbox",o);if(s)try{await _(t,["#file-loader input[type='file']","ytcp-thumbnail-uploader input[type='file']"],[s]);await t.wait({time:2})}catch{}if(w)try{await i(t,"#basics ytcp-text-dropdown-trigger, ytcp-video-metadata-playlists ytcp-dropdown-trigger",8000);await t.wait({time:1.2});const l=`tp-yt-paper-checkbox:has-text('${w}'), ytcp-checkbox-group:has-text('${w}')`;if(await f(t,l))await i(t,l,3000);else if(await i(t,"ytcp-button:has-text('New playlist'), ytcp-button:has-text('创建播放列表')",4000)){await t.wait({time:0.8});await i(t,"tp-yt-paper-item:has-text('New playlist'), tp-yt-paper-item:has-text('新建播放列表')",3000);const r="ytcp-playlist-metadata-editor #textbox, #create-playlist-form #textbox";if(await p(t,r.split(",")[0].trim(),4000)||await f(t,r)){await i(t,r,2000);await t.insertText(w);await i(t,"ytcp-button#create-button, tp-yt-paper-dialog ytcp-button:has-text('Create'), tp-yt-paper-dialog ytcp-button:has-text('创建')",4000)}}}catch{}finally{await i(t,"ytcp-playlist-dialog #save-button, ytcp-button:has-text('Done'), ytcp-button:has-text('完成')",3000);await t.pressKey("Escape");await t.wait({time:0.6})}if(!await i(t,"tp-yt-paper-radio-button[name='VIDEO_MADE_FOR_KIDS_NOT_MFK']",1e4))await i(t,"tp-yt-paper-radio-button:has-text('not made for kids'), tp-yt-paper-radio-button:has-text('不是面向儿童')",6000);if(e.tags){const l=String(e.tags).split(",").map((r)=>r.trim()).filter(Boolean).join(",");try{await i(t,"#toggle-button",6000);await t.wait({time:0.8});const r="#tags-container #text-input, ytcp-form-input-container#tags-container input";if(await f(t,r)){await i(t,r,3000);await t.insertText(`${l.slice(0,500)},`)}}catch{}}for(let l=0;l<5;l++){if(await f(t,"tp-yt-paper-radio-button[name='PUBLIC']"))break;if(!await i(t,"#next-button",6000))await t.wait({time:1.2});await t.wait({time:1})}await i(t,`tp-yt-paper-radio-button[name='${E[h]}']`,1e4);await U(t);await t.wait({time:1.2});const v=async()=>String(c(await t.evaluate(`
|
|
52
52
|
(() => {
|
|
53
|
-
const a = document.querySelector("a[href*='youtu.be'], a[href*='watch?v=']");
|
|
53
|
+
const a = document.querySelector("a[href*='youtu.be/'], a[href*='/shorts/'], a[href*='watch?v=']");
|
|
54
54
|
return a ? (a.getAttribute('href') || '') : '';
|
|
55
55
|
})()
|
|
56
|
-
`))||"");await i(t,"ytcp-button:has-text('Close'), ytcp-button:has-text('关闭'), #close-button",8000);return[{status:"✅ Published",title:a,visibility:
|
|
56
|
+
`))||""),I=await v();if(!await i(t,"#done-button",15000))throw new u("未找到 YouTube 发布按钮(上传可能未到可发布进度),请在窗口内手动发布");await t.wait({time:4});let y=await v();if(!y)y=I;await i(t,"ytcp-button:has-text('Close'), ytcp-button:has-text('关闭'), #close-button",8000);return[{status:"✅ Published",title:a,visibility:h,url:y}]}});
|