Skip to content

Let's use AI to Earn!

快手二级评论

anaianai73c1b8db60f4
diff --git a/electron/main/plat/PlatformBase.ts b/electron/main/plat/PlatformBase.ts
index a894dc57..fef8fbdd 100644
--- a/electron/main/plat/PlatformBase.ts
+++ b/electron/main/plat/PlatformBase.ts
@@ -205,6 +205,7 @@ export abstract class PlatformBase {
option: {
dataId?: string; // 作品ID
comment: any; // 辅助数据,原数据
+ videoAuthId?: string; // 视频作者ID
},
): Promise<any>;
diff --git a/electron/main/plat/index.ts b/electron/main/plat/index.ts
index b85ed2c3..7acb54e6 100644
--- a/electron/main/plat/index.ts
+++ b/electron/main/plat/index.ts
@@ -330,6 +330,7 @@ class PlatController {
option: {
dataId?: string; // 作品ID
comment: any; // 辅助数据,原数据
+ videoAuthId?: string; // 视频作者ID
},
) {
const platform = this.platforms.get(account.type)!;
diff --git a/electron/main/plat/platforms/Kwai/index.ts b/electron/main/plat/platforms/Kwai/index.ts
index afe8490c..45c1810c 100644
--- a/electron/main/plat/platforms/Kwai/index.ts
+++ b/electron/main/plat/platforms/Kwai/index.ts
@@ -345,17 +345,48 @@ export class Kwai extends PlatformBase {
};
}
+ /**
+ * 获取其他视频评论列表
+ * @param account
+ * @param data
+ * @param pcursor
+ * @returns
+ */
async getCreatorCommentListByOther(
account: AccountModel,
data: WorkData,
pcursor?: string,
) {
+ const cookie: CookiesType = JSON.parse(account.loginCookie);
+ const res = await kwaiPub.getVideoCommentList(
+ cookie,
+ data.dataId,
+ pcursor,
+ );
+
+ const list: CommentData[] = [];
+ for (const v of res.data.data.visionCommentList?.rootComments || []) {
+
+ list.push({
+ userId: v.authorId + '',
+ dataId: data.dataId + '',
+ commentId: v.commentId + '',
+ parentCommentId: undefined,
+ content: v.content,
+ likeCount: v.likedCount,
+ nikeName: v.authorName,
+ headUrl: v.headurl,
+ data: v,
+ subCommentList: v.subComments,
+ });
+ }
+
return {
- list: [],
+ list: list,
pageInfo: {
count: 0,
- pcursor: '',
- hasMore: false,
+ pcursor: res.data.data.pcursor + '',
+ hasMore: !!res.data.data.pcursor,
},
};
}
@@ -392,22 +423,27 @@ export class Kwai extends PlatformBase {
option: {
dataId?: string; // 作品ID
comment: any; // 辅助数据,原数据
+ videoAuthId?: string; // 视频作者ID
},
) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
- const res = await kwaiPub.commentAdd(cookie, content, {
+
+ const res = await kwaiPub.replyCommentByOther(cookie, content, {
photoId: option.dataId,
- replyToCommentId: Number.parseInt(commentId),
+ replyToCommentId: commentId,
replyTo: option.comment.authorId,
+ photoAuthorId: option.videoAuthId,
});
- console.log('------ replyCommentByOther res ----', res);
-
- if (res.status !== 200 || res.data.result !== 1) return false;
- return false;
+
+ return res;
}
+
+
+
+
async createComment(
account: AccountModel,
dataId: string, // 作品ID
diff --git a/electron/main/reply/controller.ts b/electron/main/reply/controller.ts
index 361938c8..dc674287 100644
--- a/electron/main/reply/controller.ts
+++ b/electron/main/reply/controller.ts
@@ -249,7 +249,7 @@ export class ReplyController {
}
/**
- * 回复评论
+ * 回复二级评论
*/
@Icp('ICP_REPLY_COMMENT_BY_OTHER')
async replyCommentByOther(
@@ -260,6 +260,7 @@ export class ReplyController {
option: {
dataId?: string; // 作品ID
comment: any; // 辅助数据,原数据
+ videoAuthId?: string; // 视频作者ID
},
): Promise<any> {
const account = await this.accountService.getAccountById(accountId);
diff --git a/electron/plat/Kwai/index.ts b/electron/plat/Kwai/index.ts
index e3025338..333d559b 100644
--- a/electron/plat/Kwai/index.ts
+++ b/electron/plat/Kwai/index.ts
@@ -522,7 +522,6 @@ class KwaiPub {
},
});
- console.log('---- douyin commentAdd ----', res);
return res;
}
@@ -557,7 +556,6 @@ class KwaiPub {
},
});
- console.log('---- douyin commentAdd ----', res);
return res;
}
@@ -576,7 +574,6 @@ class KwaiPub {
content: string,
authorId?: string
) {
- console.log('dataIddataId:' , dataId, authorId)
const res = await this.requestApi<CommentAddResponse>({
cookie: cookie,
apiUrl: 'https://www.kuaishou.com/graphql',
@@ -595,14 +592,108 @@ class KwaiPub {
},
});
- console.log('---- douyin commentAdd ----', res);
return res;
}
+
+ /**
+ * 获取视频评论列表
+ * @param cookie
+ * @param photoId
+ * @param content
+ * @param reply
+ * @returns
+ */
+ async getVideoCommentList(
+ cookie: Electron.Cookie[],
+ dataId: string,
+ pcursor?: string
+ ) {
+ const res = await this.requestApi<any>({
+ cookie: cookie,
+ apiUrl: 'https://www.kuaishou.com/graphql',
+ method: 'POST',
+ body: {
+ "operationName":"commentListQuery",
+ "variables":{
+ "pcursor": '',
+ "photoId": dataId
+ },
+ "query":
+ "query commentListQuery($photoId: String, $pcursor: String) {\n visionCommentList(photoId: $photoId, pcursor: $pcursor) {\n commentCount\n pcursor\n rootComments {\n commentId\n authorId\n authorName\n content\n headurl\n timestamp\n likedCount\n realLikedCount\n liked\n status\n authorLiked\n subCommentCount\n subCommentsPcursor\n subComments {\n commentId\n authorId\n authorName\n content\n headurl\n timestamp\n likedCount\n realLikedCount\n liked\n status\n authorLiked\n replyToUserName\n replyTo\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"
+ },
+ headers: {
+ Referer: `https://www.kuaishou.com/short-video/${dataId}`,
+ 'User-Agent':
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
+ },
+ });
+
+
+ return res;
+ }
+
+ /**
+ * 回复二级评论
+ * @param cookie
+ * @param commentId
+ * @param content
+ * @param option
+ * @returns
+ */
+
+
+ async replyCommentByOther(
+ cookie: Electron.Cookie[],
+ content: string,
+ option: {
+ replyToCommentId?: any; // 969549966791;
+ replyTo?: any; // 798319351;
+ photoId?: string; // 作品ID
+ photoAuthorId: any; // 视频作者ID
+ },
+ ) {
+
+ console.log('------ replyCommentByOther option ----', {
+
+ "photoId": option.photoId,
+ "photoAuthorId": option.photoAuthorId,
+ "content": content,
+ "replyToCommentId": option.replyToCommentId,
+ "replyTo": option.replyTo,
+ "expTag":"1_a/2004436422502146722_xpcwebdetailxxnull0"
+
+ });
+
+ const res = await this.requestApi<any>({
+ cookie: cookie,
+ apiUrl: 'https://www.kuaishou.com/graphql',
+ method: 'POST',
+ body: {
+ "operationName":"visionAddComment",
+ "variables":{
+ "photoId": option.photoId,
+ "photoAuthorId": option.photoAuthorId,
+ "content": content,
+ "replyToCommentId": option.replyToCommentId,
+ "replyTo": option.replyTo,
+ "expTag":"1_a/2004436422502146722_xpcwebdetailxxnull0"
+ },
+ "query":
+ "mutation visionAddComment($photoId: String, $photoAuthorId: String, $content: String, $replyToCommentId: ID, $replyTo: ID, $expTag: String) {\n visionAddComment(photoId: $photoId, photoAuthorId: $photoAuthorId, content: $content, replyToCommentId: $replyToCommentId, replyTo: $replyTo, expTag: $expTag) {\n result\n commentId\n content\n timestamp\n status\n __typename\n }\n}\n"
+ },
+ headers: {
+ Referer: `https://www.kuaishou.com/short-video/${option.photoId}`,
+ 'User-Agent':
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
+ },
+ });
+ return res;
+ }
diff --git a/src/icp/replyother.ts b/src/icp/replyother.ts
index e2f4a817..4496ba02 100644
--- a/src/icp/replyother.ts
+++ b/src/icp/replyother.ts
@@ -25,6 +25,7 @@ export type WorkData = {
export type CommentData = {
dataId: string;
+ videoAuthId?: string;
commentId: string;
parentCommentId?: string; // 上级评论ID
content: string;
@@ -167,6 +168,7 @@ export async function icpReplyCommentByOther(
option: {
dataId?: string; // 作品ID
comment: any; // 辅助数据,原数据
+ videoAuthId?: string; // 视频作者ID
},
) {
const res: boolean = await window.ipcRenderer.invoke(
diff --git a/src/views/replyother/components/replyComment.tsx b/src/views/replyother/components/replyComment.tsx
index b7ef1df9..45ce2923 100644
--- a/src/views/replyother/components/replyComment.tsx
+++ b/src/views/replyother/components/replyComment.tsx
@@ -34,6 +34,16 @@ const Com = forwardRef<ReplyCommentRef>((props: any, ref) => {
* 回复评论
*/
async function replyComment(content: string) {
+
+ // console.log('----- replyComment commentData', commentData!.commentId,
+ // content,
+ // {
+ // dataId: commentData!.dataId,
+ // comment: commentData!.data,
+ // }
+ // );
+ // return;
+
const res: any = await icpReplyCommentByOther(
accountId,
commentData!.commentId,
@@ -41,10 +51,11 @@ const Com = forwardRef<ReplyCommentRef>((props: any, ref) => {
{
dataId: commentData!.dataId,
comment: commentData!.data,
+ videoAuthId: commentData!.videoAuthId,
},
);
console.log('----- replyComment res', res);
- if (res.status_code == 0 || res.data.code == 0) {
+ if (res.status_code == 0 || res.data.code == 0 || res.data.data.visionAddComment?.result == 1) {
message.success('回复成功');
setIsModalOpen(false);
} else {
diff --git a/src/views/replyother/index.tsx b/src/views/replyother/index.tsx
index 59584f7b..d448cfff 100644
--- a/src/views/replyother/index.tsx
+++ b/src/views/replyother/index.tsx
@@ -334,6 +334,7 @@ export default function Page() {
* @param data
*/
function openReplyComment(data: CommentData) {
+ data.videoAuthId = currentPost.author.id;
console.log('------ openReplyComment', data);
Ref_ReplyComment.current?.init(activeAccountId, data);
}
@@ -347,9 +348,10 @@ export default function Page() {
}
/**
- * 显示评论弹窗
+ * 显示评论列表弹窗
*/
const showCommentModal = async (post: any) => {
+ console.log('------ showCommentModal post', post);
setCurrentPost(post);
setCommentModalVisible(true);
@@ -361,7 +363,7 @@ export default function Page() {
xsec_token: post.option.xsec_token || post.xsec_token,
},
});
-
+ console.log('------ getCommentListByOther res', res);
// 为每个评论添加加载状态标记
const commentsWithLoadingState = (res.list || []).map((comment) => ({
...comment,
@@ -989,7 +991,7 @@ export default function Page() {
}}
>
<Avatar
- src={`https://api.dicebear.com/7.x/miniavs/svg?seed=${currentPost?.author?.name}`}
+ src={`${currentPost?.author?.avatar}`}
/>
<Text strong style={{ marginLeft: 10 }}>
{currentPost?.author?.name}