Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 获取评论列表dataId参数改为传data
牛文政45ba4a9a3400
diff --git a/electron/main/plat/PlatformBase.ts b/electron/main/plat/PlatformBase.tsindex 6dc3eb43..67bd4d82 100644--- a/electron/main/plat/PlatformBase.ts+++ b/electron/main/plat/PlatformBase.ts@@ -121,7 +121,7 @@ export abstract class PlatformBase {*/abstract getCommentList(account: AccountModel,- dataId: string,+ workData: WorkData,pcursor?: string,): Promise<{list: CommentData[];@@ -151,7 +151,7 @@ export abstract class PlatformBase {*/abstract getCreatorSecondCommentListByOther(account: AccountModel,- dataId: string,+ workData: WorkData,root_comment_id: string,pcursor?: string,): Promise<any>;@@ -164,7 +164,7 @@ export abstract class PlatformBase {*/abstract getCreatorCommentListByOther(account: AccountModel,- dataId: string,+ workData: WorkData,pcursor?: string,): Promise<{list: CommentData[];diff --git a/electron/main/plat/plat.type.ts b/electron/main/plat/plat.type.tsindex 74e44ec1..cfb58644 100644--- a/electron/main/plat/plat.type.ts+++ b/electron/main/plat/plat.type.ts@@ -58,6 +58,9 @@ export type WorkData = {coverUrl?: string;videoUrl?: string;createTime?: string;+ option?: {+ xsec_token: string;+ };};// 评论diff --git a/electron/main/plat/platforms/Kwai/index.ts b/electron/main/plat/platforms/Kwai/index.tsindex 62bc729c..9164474e 100644--- a/electron/main/plat/platforms/Kwai/index.ts+++ b/electron/main/plat/platforms/Kwai/index.ts@@ -195,13 +195,13 @@ export class Kwai extends PlatformBase {async getCommentList(account: AccountModel,- dataId: string,+ data: WorkData,pcursor?: string,) {const cookie: CookiesType = JSON.parse(account.loginCookie);const res = await kwaiPub.getCommentList(cookie,- dataId,+ data.dataId,pcursor ? Number.parseInt(pcursor) : undefined,);@@ -212,7 +212,7 @@ export class Kwai extends PlatformBase {if (!!v.subCommentCount) {const subRes = await kwaiPub.getSubCommentList(cookie,- dataId,+ data.dataId,v.commentId,);@@ -257,7 +257,7 @@ export class Kwai extends PlatformBase {async getCreatorCommentListByOther(account: AccountModel,- dataId: string,+ data: WorkData,pcursor?: string,) {return {@@ -272,7 +272,7 @@ export class Kwai extends PlatformBase {getCreatorSecondCommentListByOther(account: AccountModel,- dataId: string,+ data: WorkData,root_comment_id: string,pcursor?: string,): Promise<any> {diff --git a/electron/main/plat/platforms/douyin/index.ts b/electron/main/plat/platforms/douyin/index.tsindex 146f7be0..4ecf68f7 100644--- a/electron/main/plat/platforms/douyin/index.ts+++ b/electron/main/plat/platforms/douyin/index.ts@@ -186,13 +186,20 @@ export class Douyin extends PlatformBase {};}+ /**+ * 获取评论列表+ * @param account+ * @param data+ * @param pcursor+ * @returns+ */async getCommentList(account: AccountModel,- dataId: string,+ data: WorkData,pcursor?: string,) {const cookie: CookiesType = JSON.parse(account.loginCookie);- const res = await douyinService.getCreatorCommentList(cookie, dataId, {+ const res = await douyinService.getCreatorCommentList(cookie, data.dataId, {count: pcursor ? 20 : undefined,cursor: pcursor || undefined,});@@ -215,7 +222,7 @@ export class Douyin extends PlatformBase {for (const element of res2.data.comment_info_list) {subList.push({userId: element.user_info.user_id,- dataId: dataId,+ dataId: data.dataId,commentId: element.comment_id,content: element.text,likeCount: Number.parseInt(element.digg_count),@@ -230,7 +237,7 @@ export class Douyin extends PlatformBase {list.push({userId: v.user_info.user_id,- dataId: dataId,+ dataId: data.dataId,commentId: v.comment_id,content: v.text,likeCount: Number.parseInt(v.digg_count),@@ -254,13 +261,13 @@ export class Douyin extends PlatformBase {// 其他人作品评论列表async getCreatorCommentListByOther(account: AccountModel,- dataId: string,+ data: WorkData,pcursor?: string,) {const cookie: CookiesType = JSON.parse(account.loginCookie);const res: any = await douyinService.getCreatorCommentListByOther(cookie,- dataId,+ data.dataId,{count: pcursor ? 20 : undefined,cursor: pcursor || undefined,@@ -575,7 +582,7 @@ export class Douyin extends PlatformBase {getCreatorSecondCommentListByOther(account: AccountModel,- dataId: string,+ data: WorkData,root_comment_id: string,pcursor?: string,): Promise<any> {diff --git a/electron/main/plat/platforms/wxSph/index.ts b/electron/main/plat/platforms/wxSph/index.tsindex 42a46d28..a0296950 100644--- a/electron/main/plat/platforms/wxSph/index.ts+++ b/electron/main/plat/platforms/wxSph/index.ts@@ -169,11 +169,11 @@ export class WxSph extends PlatformBase {async getCommentList(account: AccountModel,- dataId: string,+ data: WorkData,pcursor?: string,) {const cookie: CookiesType = JSON.parse(account.loginCookie);- const res = await shipinhaoService.getCommentList(cookie, dataId);+ const res = await shipinhaoService.getCommentList(cookie, data.dataId);const dataList: CommentData[] = [];@@ -220,7 +220,7 @@ export class WxSph extends PlatformBase {async getCreatorCommentListByOther(account: AccountModel,- dataId: string,+ data: WorkData,pcursor?: string,) {return {@@ -235,7 +235,7 @@ export class WxSph extends PlatformBase {getCreatorSecondCommentListByOther(account: AccountModel,- dataId: string,+ data: WorkData,root_comment_id: string,pcursor?: string,): Promise<any> {diff --git a/electron/main/plat/platforms/xhs/index.ts b/electron/main/plat/platforms/xhs/index.tsindex 2f19206d..4934a7a8 100644--- a/electron/main/plat/platforms/xhs/index.ts+++ b/electron/main/plat/platforms/xhs/index.ts@@ -144,7 +144,6 @@ export class Xhs extends PlatformBase {async getWorkList(account: AccountModel, pcursor?: string) {const pageNo = pcursor ? Number.parseInt(pcursor) : 0;- // TODO: 小红书的分页每页数量?const pageSize = 20;const cookie: CookiesType = JSON.parse(account.loginCookie);const res = await xiaohongshuService.getWorks(@@ -186,16 +185,19 @@ export class Xhs extends PlatformBase {};}- async getCommentList(+ async getCommentList<T>(account: AccountModel,- dataId: string,+ data: WorkData,pcursor?: string,) {const cookie: CookiesType = JSON.parse(account.loginCookie);const res = await xiaohongshuService.getCommentList(cookie,- dataId,+ {+ xsec_token: data.option!.xsec_token,+ id: data.dataId,+ },pcursor ? Number.parseInt(pcursor) : undefined,);@@ -254,12 +256,14 @@ export class Xhs extends PlatformBase {async getCreatorCommentListByOther(account: AccountModel,- dataId: string,+ data: WorkData,pcursor?: string,) {const cookie: CookiesType = JSON.parse(account.loginCookie);- console.log('------ getCreatorCommentListByOther xhs dataId---', dataId);- const res = await xiaohongshuService.getCommentList(cookie, dataId);+ const res = await xiaohongshuService.getCommentList(cookie, {+ xsec_token: data.option!.xsec_token,+ id: data.dataId,+ });const list: CommentData[] = [];@@ -305,18 +309,15 @@ export class Xhs extends PlatformBase {async getCreatorSecondCommentListByOther(account: AccountModel,- dataId: string,+ data: WorkData,root_comment_id: string,pcursor?: string,) {const cookie: CookiesType = JSON.parse(account.loginCookie);- console.log(- '------ getCreatorSecondCommentListByOther xhs dataId---',- dataId,- );+const res = await xiaohongshuService.getSecondCommentList(cookie,- dataId,+ data.dataId,root_comment_id,pcursor,);diff --git a/electron/plat/xiaohongshu/index.ts b/electron/plat/xiaohongshu/index.tsindex ec0485f7..f1eac7bd 100644--- a/electron/plat/xiaohongshu/index.ts+++ b/electron/plat/xiaohongshu/index.ts@@ -1431,11 +1431,13 @@ export class XiaohongshuService {*/async getCommentList(cookie: Electron.Cookie[],- noteId: string,+ note: {+ id: string;+ xsec_token: string;+ },cursor?: number,) {- // TODO: xsec_token 每个作品评论列表的xsec_token都不一样,需要重新获取- const url = `/api/sns/web/v2/comment/page?note_id=${noteId}&cursor=${cursor || ''}&top_comment_id=&image_formats=jpg,webp,avif&xsec_token=${esec_token}`;+ const url = `/api/sns/web/v2/comment/page?note_id=${note.id}&cursor=${cursor || ''}&top_comment_id=&image_formats=jpg,webp,avif&xsec_token=${note.xsec_token}`;const reverseRes: any = await this.getReverseResult({url,a1: CookieToString(cookie),