Skip to content

Let's use AI to Earn!

feat: 视频号获取评论列表

牛文政bd131cb8f4c1
diff --git a/electron/main/plat/PlatformBase.ts b/electron/main/plat/PlatformBase.ts
index 50ba3ea5..1a0ef90e 100644
--- a/electron/main/plat/PlatformBase.ts
+++ b/electron/main/plat/PlatformBase.ts
@@ -7,6 +7,7 @@
*/
import {
AccountInfoTypeRV,
+ CommentData,
DashboardData,
IAccountInfoParams,
IGetLocationDataParams,
@@ -95,7 +96,13 @@ export abstract class PlatformBase {
/**
* 获取评论列表
*/
- abstract getCommentList(account: AccountModel, dataId: string): Promise<any>;
+ abstract getCommentList(
+ account: AccountModel,
+ dataId: string,
+ ): Promise<{
+ list: CommentData[];
+ count: number;
+ }>;
/**
* 在该平台发布视频
diff --git a/electron/main/plat/index.ts b/electron/main/plat/index.ts
index 85c6b2f9..38afb798 100644
--- a/electron/main/plat/index.ts
+++ b/electron/main/plat/index.ts
@@ -157,6 +157,16 @@ class PlatController {
const platform = this.platforms.get(account.type)!;
return await platform.getWorkList(account, pageInfo);
}
+
+ /**
+ * 获取评论列表
+ * @param account
+ * @param pageInfo
+ */
+ public async getCommentList(account: AccountModel, dataId: string) {
+ const platform = this.platforms.get(account.type)!;
+ return await platform.getCommentList(account, dataId);
+ }
}
const platController = new PlatController();
diff --git a/electron/main/plat/plat.type.ts b/electron/main/plat/plat.type.ts
index fc6a12b9..93281441 100644
--- a/electron/main/plat/plat.type.ts
+++ b/electron/main/plat/plat.type.ts
@@ -53,6 +53,18 @@ export type WorkData = {
videoUrl?: string;
};
+// 评论
+export type CommentData = {
+ dataId: string;
+ commentId: string;
+ parentCommentId?: string; // 上级评论ID
+ content: string;
+ likeCount?: number; // 点赞次数
+ nikeName?: string;
+ headUrl?: string;
+ data: any; // 原数据
+};
+
// 视频发布进度回调函数类型
export type VideoCallbackType = (progress: number, msg?: string) => void;
diff --git a/electron/main/plat/platforms/Kwai/index.ts b/electron/main/plat/platforms/Kwai/index.ts
index a92e7788..e4455e51 100644
--- a/electron/main/plat/platforms/Kwai/index.ts
+++ b/electron/main/plat/platforms/Kwai/index.ts
@@ -171,7 +171,10 @@ export class Kwai extends PlatformBase {
async getCommentList(account: AccountModel, dataId: string) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
- return [];
+ return {
+ list: [],
+ count: 0,
+ };
}
async loginCheck(account: AccountModel): Promise<boolean> {
diff --git a/electron/main/plat/platforms/douyin/index.ts b/electron/main/plat/platforms/douyin/index.ts
index e8d648c5..2ba25ffd 100644
--- a/electron/main/plat/platforms/douyin/index.ts
+++ b/electron/main/plat/platforms/douyin/index.ts
@@ -154,7 +154,10 @@ export class Douyin extends PlatformBase {
async getCommentList(account: AccountModel, dataId: string) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
- return [];
+ return {
+ list: [],
+ count: 0,
+ };
}
async videoPublish(
diff --git a/electron/main/plat/platforms/wxSph/index.ts b/electron/main/plat/platforms/wxSph/index.ts
index c948ee0e..d8404629 100644
--- a/electron/main/plat/platforms/wxSph/index.ts
+++ b/electron/main/plat/platforms/wxSph/index.ts
@@ -161,9 +161,22 @@ export class WxSph extends PlatformBase {
async getCommentList(account: AccountModel, dataId: string) {
const cookie: CookiesType = JSON.parse(account.loginCookie);
const res = await shipinhaoService.getCommentList(cookie, dataId);
- console.log('------ res', res);
- return res;
+ const dataList = res.data.data.comment.map((item) => {
+ return {
+ dataId: item.commentId,
+ commentId: item.commentId,
+ content: item.commentContent,
+ nikeName: item.commentNickname,
+ headUrl: item.commentHeadurl,
+ data: item,
+ };
+ });
+
+ return {
+ list: dataList,
+ count: res.data.data.commentCount,
+ };
}
async getUsers(params: IGetUsersParams) {
diff --git a/electron/main/reply/controller.ts b/electron/main/reply/controller.ts
index 73acfc95..a917b214 100644
--- a/electron/main/reply/controller.ts
+++ b/electron/main/reply/controller.ts
@@ -5,10 +5,10 @@
* @LastEditors: nevin
* @Description: reply Reply
*/
-import { AccountType } from '../../../commont/AccountEnum';
import { AccountService } from '../account/service';
import { Controller, Icp, Inject } from '../core/decorators';
import platController from '../plat';
+import { WorkData } from '../plat/plat.type';
import { ReplyService } from './service';
@Controller()
@@ -30,11 +30,34 @@ export class ReplyController {
pageNo: number;
pageSize: number;
},
+ ): Promise<{
+ list: WorkData[];
+ count: number;
+ }> {
+ const account = await this.accountService.getAccountById(accountId);
+ if (!account)
+ return {
+ list: [],
+ count: 0,
+ };
+
+ const res = await platController.getWorkList(account, pageInfo);
+ return res;
+ }
+
+ /**
+ * 获取评论列表
+ */
+ @Icp('ICP_COMMENT_LIST')
+ async getCommentList(
+ event: Electron.IpcMainInvokeEvent,
+ accountId: number,
+ dataId: string,
): Promise<any> {
const account = await this.accountService.getAccountById(accountId);
if (!account) return null;
- const res = await platController.getWorkList(account, pageInfo);
+ const res = await platController.getCommentList(account, dataId);
return res;
}
}
diff --git a/electron/plat/shipinhao/index.ts b/electron/plat/shipinhao/index.ts
index 38c54622..7d3d987f 100644
--- a/electron/plat/shipinhao/index.ts
+++ b/electron/plat/shipinhao/index.ts
@@ -5,6 +5,7 @@ import { FileUtils } from '../../util/file';
import { CookieToString, getFileContent } from '../utils';
import requestNet from '../requestNet';
import {
+ SphGetCommentListResponse,
SphGetPostListResponse,
WeChatLocationData,
WeChatVideoApiResponse,
@@ -1366,7 +1367,7 @@ export class ShipinhaoService {
* @returns
*/
async getCommentList(cookie: Electron.Cookie[], exportId: string) {
- return await requestNet<WeChatVideoUserData>({
+ const res = await requestNet<SphGetCommentListResponse>({
url: `https://channels.weixin.qq.com/micro/interaction/cgi-bin/mmfinderassistant-bin/comment/comment_list?_rid=67d032a7-6c8f7126`,
headers: {
cookie: CookieToString(cookie),
@@ -1387,6 +1388,12 @@ export class ShipinhaoService {
_log_finder_uin: '',
},
});
+
+ const ret = res.data.data;
+
+ console.log('----- ', ret.comment[0].levelTwoComment);
+
+ return res;
}
/**
diff --git a/electron/plat/shipinhao/wxShp.type.ts b/electron/plat/shipinhao/wxShp.type.ts
index fed3116d..8bdaf8cc 100644
--- a/electron/plat/shipinhao/wxShp.type.ts
+++ b/electron/plat/shipinhao/wxShp.type.ts
@@ -167,3 +167,31 @@ export interface SphGetPostListResponse {
totalCount: number;
};
}
+
+export interface CommentInfo {
+ levelTwoComment: CommentInfo[]; // 二级评论
+ commentId: string; // '14610404657143548189';
+ commentNickname: string; // '义务之后是金钱';
+ commentContent: string; // '可爱吧';
+ commentHeadurl: string; // 'http://wx.qlogo.cn/finderhead/Q3auHgzwzM5OEKzc5UdzOUJUbOsaCtSkcCctCb9ddrCKiag4ZibQ73oA/0';
+ commentCreatetime: string; // '1741695959';
+ commentLikeCount: number; // 0;
+ lastBuff: string; // '';
+ downContinueFlag: number; // 0;
+ visibleFlag: number; // 0;
+ readFlag: true;
+ displayFlag: number; // 514;
+ blacklistFlag: number; // 0;
+ likeFlag: number; // 0;
+}
+
+export interface SphGetCommentListResponse {
+ errCode: number;
+ errMsg: string;
+ data: {
+ comment: CommentInfo[];
+ lastBuff: string; // 'AATVfYAEAAABAAAAAADWiCo0vu4ltcc8lXzRZyAAAADzrBEppsryM1QLZ+dDmBLm9XwcA0exd+eEMM5e+lsrR+oHHo2NIZY18J6IkJAbntQxZiEBkXZ24Y1hrnqW334ItvllglnXoA==',
+ commentCount: number; // 2;
+ downContinueFlag: number; // 0;
+ };
+}
diff --git a/src/icp/reply.ts b/src/icp/reply.ts
index 37d5f1d9..fc06d78d 100644
--- a/src/icp/reply.ts
+++ b/src/icp/reply.ts
@@ -5,11 +5,44 @@
* @LastEditors: nevin
* @Description:
*/
+export type WorkData = {
+ dataId: string;
+ readCount?: number;
+ likeCount?: number;
+ collectCount?: number;
+ forwardCount?: number;
+ commentCount?: number; // 评论数量
+ income?: number;
+ title?: string;
+ desc?: string;
+ coverUrl?: string;
+ videoUrl?: string;
+};
/**
* 获取作品列表
*/
-export async function ipcCreatorList(accountId: number) {
- const res = await window.ipcRenderer.invoke('ICP_CREATOR_LIST', accountId);
+export async function icpCreatorList(
+ accountId: number,
+ pageInfo: {
+ pageNo: number;
+ pageSize: number;
+ },
+) {
+ const res: {
+ list: WorkData[];
+ count: number;
+ } = await window.ipcRenderer.invoke('ICP_CREATOR_LIST', accountId, pageInfo);
+ return res;
+}
+
+/**
+ * 获取作品列表
+ */
+export async function icpGetCommentList(accountId: number, dataId: string) {
+ const res: {
+ list: WorkData[];
+ count: number;
+ } = await window.ipcRenderer.invoke('ICP_COMMENT_LIST', accountId, dataId);
return res;
}
diff --git a/src/views/reply/index.tsx b/src/views/reply/index.tsx
index b1cbb54d..f23b0937 100644
--- a/src/views/reply/index.tsx
+++ b/src/views/reply/index.tsx
@@ -5,16 +5,29 @@
* @LastEditors: nevin
* @Description: 评论页面 reply
*/
-import { ipcCreatorList } from '@/icp/reply';
+import { icpCreatorList, icpGetCommentList, WorkData } from '@/icp/reply';
import { Button } from 'antd';
import { useCallback, useState } from 'react';
import AccountSidebar from '../account/components/AccountSidebar/AccountSidebar';
export default function Page() {
- const [activeTab, setActiveTab] = useState('car');
+ const [wordList, setWordList] = useState<WorkData[]>([]);
const [activeAccountId, setActiveAccountId] = useState<number>(-1);
async function getCreatorList() {
- const res = await ipcCreatorList(activeAccountId);
+ const res = await icpCreatorList(activeAccountId, {
+ pageNo: 1,
+ pageSize: 10,
+ });
+ setWordList(res.list);
+ console.log('----- res', res);
+ }
+
+ /**
+ * 获取评论列表
+ */
+ async function getCommentList(dataId: string) {
+ const res = await icpGetCommentList(activeAccountId, dataId);
+ setWordList(res.list);
console.log('----- res', res);
}
@@ -32,6 +45,19 @@ export default function Page() {
<Button type="primary" onClick={getCreatorList}>
获取列表
</Button>
+ <div>
+ {wordList.map((item) => (
+ <div key={item.dataId}>
+ {item.title}
+ <Button
+ type="primary"
+ onClick={() => getCommentList(item.dataId)}
+ >
+ 获取评论列表
+ </Button>
+ </div>
+ ))}
+ </div>
</div>
</div>
);