Skip to content

Let's use AI to Earn!

feat: 添加查看小红书视频

gaoSir3cbc2dd4c86e
diff --git a/electron/db/models/video.ts b/electron/db/models/video.ts
index 79ae204f..5951a2d3 100644
--- a/electron/db/models/video.ts
+++ b/electron/db/models/video.ts
@@ -11,6 +11,7 @@ import { VisibleTypeEnum } from '../../../commont/publish/PublishEnum';
import { AccountType } from '../../../commont/AccountEnum';
import type { ILocationDataItem, WxSphEvent } from '../../main/plat/plat.type';
import { DeclarationDouyin } from '../../plat/douyin/common.douyin';
+import type { IVideoPubOtherData } from '../../main/plat/module';
// 包含一个name和一个value的对象
export interface ILableValue {
@@ -101,6 +102,10 @@ export class VideoModel extends WorkData {
@Column({ type: 'json', nullable: true, comment: '@用户数组' })
mentionedUserInfo?: ILableValue[];
+ // 其它数据,发布完成每个可能需要这个平台独特的数据
+ @Column({ type: 'json', nullable: true, comment: '@用户数组' })
+ videoPubOtherData?: IVideoPubOtherData;
+
// 视频可见性
@Column({
type: 'tinyint',
diff --git a/electron/main/plat/module.ts b/electron/main/plat/module.ts
index 73c94215..abdb4046 100644
--- a/electron/main/plat/module.ts
+++ b/electron/main/plat/module.ts
@@ -5,12 +5,22 @@
* @LastEditors: nevin
* @Description:
*/
+import { AccountType } from '../../../commont/AccountEnum';
+
interface IProperty {
code: number;
msg: string;
dataId: string;
}
+export interface IVideoPubOtherData {
+ [AccountType.Xhs]?: {
+ // 预览需要
+ xsec_token: string;
+ xsec_source: string;
+ };
+}
+
export class PublishVideoResult {
// 0=失败 1=成功
code: number;
@@ -18,6 +28,8 @@ export class PublishVideoResult {
msg: string;
// 数据ID
dataId?: string;
+ // 其它数据,发布完成每个可能需要这个平台独特的数据
+ videoPubOtherData?: IVideoPubOtherData;
constructor(
{ code, msg, dataId }: IProperty = {
diff --git a/electron/main/plat/platforms/xhs/index.ts b/electron/main/plat/platforms/xhs/index.ts
index ef7c2f5c..cb5d7e31 100644
--- a/electron/main/plat/platforms/xhs/index.ts
+++ b/electron/main/plat/platforms/xhs/index.ts
@@ -233,7 +233,7 @@ export class Xhs extends PlatformBase {
});
});
- if (result && !result.publishId)
+ if (!result || !result.publishId)
return resolve({
code: 0,
msg: '网络繁忙,请稍后重试!',
@@ -243,6 +243,12 @@ export class Xhs extends PlatformBase {
code: 1,
msg: '成功!',
dataId: result!.publishId,
+ videoPubOtherData: {
+ [AccountType.Xhs]: {
+ xsec_token: result!.works!.xsec_token,
+ xsec_source: result!.works!.xsec_source,
+ },
+ },
});
});
}
diff --git a/electron/main/plat/pub/PubItemVideo.ts b/electron/main/plat/pub/PubItemVideo.ts
index 11e473c9..09278890 100644
--- a/electron/main/plat/pub/PubItemVideo.ts
+++ b/electron/main/plat/pub/PubItemVideo.ts
@@ -74,6 +74,7 @@ export class PubItemVideo extends PubItemBase {
// 发布成功
this.videoModel.status = PubStatus.RELEASED;
this.videoModel.dataId = publishVideoResult.dataId;
+ this.videoModel.videoPubOtherData = publishVideoResult.videoPubOtherData;
}
await this.uploadRecord();
return publishVideoResult;
diff --git a/electron/plat/Kwai/index.ts b/electron/plat/Kwai/index.ts
index 29aea4aa..6edb6d23 100644
--- a/electron/plat/Kwai/index.ts
+++ b/electron/plat/Kwai/index.ts
@@ -390,6 +390,9 @@ class KwaiPub {
/**
* 添加评论和回复评论
* @param cookie
+ * @param photoId
+ * @param content
+ * @param reply
* @returns
*/
async commentAdd(
diff --git a/electron/plat/xiaohongshu/index.ts b/electron/plat/xiaohongshu/index.ts
index c0e33f5a..93a5c9a7 100644
--- a/electron/plat/xiaohongshu/index.ts
+++ b/electron/plat/xiaohongshu/index.ts
@@ -6,8 +6,10 @@ import { FileUtils } from '../../util/file';
import { CookieToString, getFileContent } from '../utils';
import requestNet from '../requestNet';
import {
+ IXHSGetWorksResponse,
IXHSLocationResponse,
IXHSTopicsResponse,
+ IXHSWorks,
XiaohongshuApiResponse,
} from './xiaohongshu.type';
@@ -1189,6 +1191,7 @@ export class XiaohongshuService {
publishTime: number;
publishId: string;
shareLink: string;
+ works?: IXHSWorks;
}> {
return new Promise(async (resolve, reject) => {
try {
@@ -1244,14 +1247,24 @@ export class XiaohongshuService {
).catch((err) => {
reject(err);
});
+ callback(80, '发布完成,正在查询结果...');
+
+ const worksList = await this.getWorks(JSON.parse(cookies));
+ console.log(worksList);
+ const works = worksList.data.data.notes.find(
+ (v) => v.id === result.publishId,
+ );
+ console.log(works);
callback(100);
// 返回信息
resolve({
publishTime: Math.floor(Date.now() / 1000),
publishId: result.publishId,
shareLink: result.shareLink || '',
+ works,
});
} catch (err) {
+ console.warn(err);
reject(err);
callback(-1);
}
@@ -1348,6 +1361,28 @@ export class XiaohongshuService {
});
}
+ // 获取作品列表
+ async getWorks(cookie: Electron.Cookie[]) {
+ const reverseRes: any = await this.getReverseResult({
+ url: '/web_api/sns/v5/creator/note/user/posted?tab=0&page=0',
+ a1: CookieToString(cookie),
+ });
+
+ return await requestNet<IXHSGetWorksResponse>({
+ url: `https://edith.xiaohongshu.com/web_api/sns/v5/creator/note/user/posted?tab=0&page=0`,
+ headers: {
+ cookie: CookieToString(cookie),
+ Referer: this.loginUrl,
+ origin: this.loginUrl,
+ 'X-S': reverseRes['X-s'],
+ 'X-T': reverseRes['X-t'],
+ userAgent:
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.36',
+ },
+ method: 'GET',
+ });
+ }
+
// 获取@用户列表
async getUsers(cookie: Electron.Cookie[], keyword: string, page: number) {
return await requestNet<XiaohongshuApiResponse>({
diff --git a/electron/plat/xiaohongshu/xiaohongshu.type.ts b/electron/plat/xiaohongshu/xiaohongshu.type.ts
index e0350421..96ea556e 100644
--- a/electron/plat/xiaohongshu/xiaohongshu.type.ts
+++ b/electron/plat/xiaohongshu/xiaohongshu.type.ts
@@ -70,6 +70,43 @@ interface XiaohongshuData {
user_info_dtos: XiaohongshuUserInfoDTO[];
}
+export interface IXHSWorks {
+ collected_count: number;
+ comments_count: number;
+ display_title: string;
+ id: string;
+ images_list: {
+ url: string;
+ }[];
+ level: number;
+ permission_code: number;
+ likes: number;
+ permission_msg: string;
+ schedule_post_time: number;
+ shared_count: number;
+ sticky: boolean;
+ tab_status: number;
+ time: string;
+ type: string;
+ video_info: {
+ duration: number;
+ };
+ view_count: number;
+ xsec_source: string;
+ xsec_token: string;
+}
+
+export type IXHSGetWorksResponse = CommonResponse<{
+ page: number;
+ notes: IXHSWorks[];
+ tags: {
+ checked: boolean;
+ id: string;
+ name: string;
+ notes_count: number;
+ }[];
+}>;
+
// 搜索用户
export type XiaohongshuApiResponse = CommonResponse<XiaohongshuData>;
diff --git a/src/components/WebView/index.tsx b/src/components/WebView/index.tsx
index d481da86..106a09c8 100644
--- a/src/components/WebView/index.tsx
+++ b/src/components/WebView/index.tsx
@@ -36,6 +36,7 @@ const WebView = memo(
// 隔离ID
const partitionId = useRef(generateUUID());
+ console.log(cookieParams);
useEffect(() => {
setLoading(true);
diff --git a/src/views/publish/children/pubRecord/page.tsx b/src/views/publish/children/pubRecord/page.tsx
index 718c382d..398a98da 100644
--- a/src/views/publish/children/pubRecord/page.tsx
+++ b/src/views/publish/children/pubRecord/page.tsx
@@ -1,27 +1,18 @@
-import { useEffect, useRef, useState } from 'react';
-import { PubRecordModel } from '../../comment';
-import styles from './pubRecord.module.scss';
-import { icpGetPubRecordList, icpGetPubVideoRecord } from '@/icp/publish';
-import {
- Avatar,
- Button,
- Drawer,
- Modal,
- Spin,
- Table,
- TableProps,
- Tooltip,
-} from 'antd';
-import { getImgFile, IImgFile } from '@/components/Choose/ImgChoose';
-import { formatTime, getFilePathName } from '@/utils';
-import { VideoPul } from '@/views/publish/children/videoPage/comment';
-import { icpGetAccountList } from '@/icp/account';
-import { AccountInfo, AccountPlatInfoMap } from '@/views/account/comment';
-import { useVideoPageStore } from '../videoPage/useVideoPageStore';
-import { useShallow } from 'zustand/react/shallow';
-import { useNavigate } from 'react-router-dom';
-import { AccountType } from '../../../../../commont/AccountEnum';
-import WebView from '../../../../components/WebView';
+import { useEffect, useRef, useState } from "react";
+import { PubRecordModel } from "../../comment";
+import styles from "./pubRecord.module.scss";
+import { icpGetPubRecordList, icpGetPubVideoRecord } from "@/icp/publish";
+import { Avatar, Button, Drawer, Modal, Spin, Table, TableProps, Tooltip } from "antd";
+import { getImgFile, IImgFile } from "@/components/Choose/ImgChoose";
+import { formatTime, getFilePathName } from "@/utils";
+import { VideoPul } from "@/views/publish/children/videoPage/comment";
+import { icpGetAccountList } from "@/icp/account";
+import { AccountInfo, AccountPlatInfoMap } from "@/views/account/comment";
+import { useVideoPageStore } from "../videoPage/useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import { useNavigate } from "react-router-dom";
+import { AccountType } from "../../../../../commont/AccountEnum";
+import WebView from "../../../../components/WebView";
const PubCon = ({ prm }: { prm: PubRecordModel }) => {
const [imgFile, setImgFile] = useState<IImgFile>();
@@ -216,7 +207,7 @@ export default function Page() {
</div>
</div>
<div className="pubRecord-record-item-btns">
- {v.status === 2 ? (
+ {v.status !== 1 ? (
<Button
type="link"
onClick={() => {
@@ -241,7 +232,6 @@ export default function Page() {
type="link"
onClick={() => {
if (!v.dataId) return;
- console.log(v);
setExamineVideo((prevState) => {
const newState = { ...prevState };
newState.open = true;
@@ -249,8 +239,10 @@ export default function Page() {
if (account?.type === AccountType.Douyin) {
newState.url = `https://www.douyin.com/user/self?from_tab_name=main&modal_id=${v.dataId}&showTab=post`;
- } else {
- newState.url = `https://www.xiaohongshu.com/explore/67d18664000000000903814a?xsec_token=YBMab332BXv8-5Do5w8-AfCUsQpEry-xdpKLyG1y_g67k%3D&xsec_source=pc_creatormng`;
+ } else if (account?.type === AccountType.Xhs) {
+ newState.url = `https://www.xiaohongshu.com/explore/${v.dataId}?xsec_token=${v.videoPubOtherData![AccountType.Xhs]!.xsec_token}&xsec_source=${v.videoPubOtherData![AccountType.Xhs]!.xsec_source}`;
+ } else if (account?.type === AccountType.WxSph) {
+ console.log(newState.url);
}
return newState;
});