Skip to content

Let's use AI to Earn!

feat: 发布完成的视频返回预览地址完成

gaoSirf58a4019f082
diff --git a/electron/db/models/video.ts b/electron/db/models/video.ts
index 5951a2d3..0a9ae398 100644
--- a/electron/db/models/video.ts
+++ b/electron/db/models/video.ts
@@ -102,9 +102,9 @@ export class VideoModel extends WorkData {
@Column({ type: 'json', nullable: true, comment: '@用户数组' })
mentionedUserInfo?: ILableValue[];
- // 其它数据,发布完成每个可能需要这个平台独特的数据
- @Column({ type: 'json', nullable: true, comment: '@用户数组' })
- videoPubOtherData?: IVideoPubOtherData;
+ // 预览地址
+ @Column({ type: 'varchar', nullable: true, comment: '预览地址' })
+ previewVideoLink?: string;
// 视频可见性
@Column({
diff --git a/electron/main/plat/module.ts b/electron/main/plat/module.ts
index abdb4046..13f9a84c 100644
--- a/electron/main/plat/module.ts
+++ b/electron/main/plat/module.ts
@@ -11,6 +11,7 @@ interface IProperty {
code: number;
msg: string;
dataId: string;
+ previewVideoLink: string;
}
export interface IVideoPubOtherData {
@@ -28,18 +29,20 @@ export class PublishVideoResult {
msg: string;
// 数据ID
dataId?: string;
- // 其它数据,发布完成每个可能需要这个平台独特的数据
- videoPubOtherData?: IVideoPubOtherData;
+ // 预览视频地址
+ previewVideoLink?: string;
constructor(
- { code, msg, dataId }: IProperty = {
+ { code, msg, dataId, previewVideoLink }: IProperty = {
code: 1,
msg: '发布成功!',
dataId: '',
+ previewVideoLink: '',
},
) {
this.code = code;
this.msg = msg;
this.dataId = dataId;
+ this.previewVideoLink = previewVideoLink;
}
}
diff --git a/electron/main/plat/platforms/douyin/index.ts b/electron/main/plat/platforms/douyin/index.ts
index 01d726a8..f14f706c 100644
--- a/electron/main/plat/platforms/douyin/index.ts
+++ b/electron/main/plat/platforms/douyin/index.ts
@@ -329,6 +329,7 @@ export class Douyin extends PlatformBase {
code: 1,
msg: '发布成功',
dataId: result.publishId,
+ previewVideoLink: result.shareLink,
});
});
}
diff --git a/electron/main/plat/platforms/xhs/index.ts b/electron/main/plat/platforms/xhs/index.ts
index 3f2f8922..f7f2ee55 100644
--- a/electron/main/plat/platforms/xhs/index.ts
+++ b/electron/main/plat/platforms/xhs/index.ts
@@ -303,12 +303,7 @@ 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,
- },
- },
+ previewVideoLink: result.shareLink,
});
});
}
diff --git a/electron/main/plat/pub/PubItemVideo.ts b/electron/main/plat/pub/PubItemVideo.ts
index 2467ebfa..40f313be 100644
--- a/electron/main/plat/pub/PubItemVideo.ts
+++ b/electron/main/plat/pub/PubItemVideo.ts
@@ -74,7 +74,7 @@ export class PubItemVideo extends PubItemBase {
// 发布成功
this.videoModel.status = PubStatus.RELEASED;
this.videoModel.dataId = publishVideoResult.dataId;
- this.videoModel.videoPubOtherData = publishVideoResult.videoPubOtherData;
+ this.videoModel.previewVideoLink = publishVideoResult.previewVideoLink;
}
await this.uploadRecord();
return publishVideoResult;
diff --git a/electron/plat/douyin/index.ts b/electron/plat/douyin/index.ts
index d40c6f65..2d555fd1 100644
--- a/electron/plat/douyin/index.ts
+++ b/electron/plat/douyin/index.ts
@@ -625,7 +625,7 @@ export class DouyinService {
const response = {
publishTime: Math.floor(Date.now() / 1000),
publishId: publishResult.data.item_id,
- shareLink: '',
+ shareLink: `https://www.douyin.com/user/self?from_tab_name=main&modal_id=${publishResult.data.item_id}&showTab=post`,
};
console.log(
`[${new Date().toLocaleString()}] 发布成功,返回数据:`,
diff --git a/electron/plat/shipinhao/index.ts b/electron/plat/shipinhao/index.ts
index 0e447a81..88733145 100644
--- a/electron/plat/shipinhao/index.ts
+++ b/electron/plat/shipinhao/index.ts
@@ -972,7 +972,10 @@ export class ShipinhaoService {
endUploadTime: number,
clipResult: any,
platformSetting: any,
- ): Promise<string> {
+ ): Promise<{
+ lastPublishId: string;
+ previewVideoLink: string;
+ }> {
return new Promise(async (resolve, reject) => {
try {
// 处理标题、@好友、话题
@@ -1119,7 +1122,7 @@ export class ShipinhaoService {
reject('发布失败,失败原因:' + createRes.data.baseResp.errmsg);
} else {
const lastWorkInfo = await this.getLastPublishId(cookieString);
- resolve(lastWorkInfo.lastPublishId);
+ resolve(lastWorkInfo);
}
} catch (err: any) {
let errorMessage;
@@ -1167,30 +1170,24 @@ export class ShipinhaoService {
}
// 获取预览的视频链接
- // const previewVideoRes = await this.makeRequest(
- // 'https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/post/get_object_short_link',
- // {
- // method: 'POST',
- // headers: {
- // Cookie: cookieString,
- // 'Content-Type': 'application/json',
- // },
- // data: {},
- // },
- // );
-
- // let lastPublishId = '';
- // if (workListRes.errCode === 0) {
- // const workList = workListRes.data.list;
- // if (workList.length > 0) {
- // lastPublishId = workList[0].desc.media[0].md5sum ?? '';
- // }
- // }
+ const previewVideoRes = await this.makeRequest(
+ 'https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/post/get_object_short_link',
+ {
+ method: 'POST',
+ headers: {
+ Cookie: cookieString,
+ 'Content-Type': 'application/json',
+ },
+ data: {
+ exportId: work.exportId,
+ nonceId: work.objectNonce,
+ },
+ },
+ );
+
return {
lastPublishId: work?.desc?.media[0]?.md5sum ?? '',
- previewVideoLink: ''
- // previewVideoLink: {
- // }
+ previewVideoLink: previewVideoRes,
};
}
@@ -1272,7 +1269,7 @@ export class ShipinhaoService {
uploadParams,
);
callback(80, '正在发布视频...');
- const lastPublishId = await this.postCreateVideo(
+ const lastPublishRes = await this.postCreateVideo(
cookieString,
traceKey,
startUploadTime,
@@ -1290,8 +1287,8 @@ export class ShipinhaoService {
// 返回成功
return {
publishTime: Math.floor(Date.now() / 1000),
- publishId: lastPublishId,
- shareLink: '',
+ publishId: lastPublishRes.lastPublishId,
+ shareLink: lastPublishRes.previewVideoLink,
};
} catch (err: any) {
console.error('发布视频失败:', err);
diff --git a/electron/plat/xiaohongshu/index.ts b/electron/plat/xiaohongshu/index.ts
index a2509c41..2eb8b874 100644
--- a/electron/plat/xiaohongshu/index.ts
+++ b/electron/plat/xiaohongshu/index.ts
@@ -9,7 +9,6 @@ import {
IXHSGetWorksResponse,
IXHSLocationResponse,
IXHSTopicsResponse,
- IXHSWorks,
XhsCommentListResponse,
XhsCommentPostResponse,
XiaohongshuApiResponse,
@@ -1191,7 +1190,6 @@ export class XiaohongshuService {
publishTime: number;
publishId: string;
shareLink: string;
- works?: IXHSWorks;
}> {
return new Promise(async (resolve, reject) => {
try {
@@ -1260,8 +1258,7 @@ export class XiaohongshuService {
resolve({
publishTime: Math.floor(Date.now() / 1000),
publishId: result.publishId,
- shareLink: result.shareLink || '',
- works,
+ shareLink: `https://www.xiaohongshu.com/explore/${result.publishId}?xsec_token=${works!.xsec_token}&xsec_source=${works!.xsec_source}`,
});
} catch (err) {
console.warn(err);
diff --git a/src/utils/videoPub.ts b/src/utils/videoPub.ts
deleted file mode 100644
index 3713149b..00000000
--- a/src/utils/videoPub.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { VideoPul } from '../views/publish/children/videoPage/comment';
-import { AccountType } from '../../commont/AccountEnum';
-
-/**
- * 获取视频发布预览的地址
- * @param videoRecord
- */
-export function getVideoPreviewPage(videoRecord: VideoPul) {
- let url = '';
- switch (videoRecord.type) {
- case AccountType.Douyin:
- url = `https://www.douyin.com/user/self?from_tab_name=main&modal_id=${videoRecord.dataId}&showTab=post`;
- break;
- case AccountType.Xhs:
- url = `https://www.xiaohongshu.com/explore/${videoRecord.dataId}?xsec_token=${videoRecord.videoPubOtherData![AccountType.Xhs]!.xsec_token}&xsec_source=${videoRecord.videoPubOtherData![AccountType.Xhs]!.xsec_source}`;
- break;
- }
- return url;
-}
diff --git a/src/views/publish/children/pubRecord/page.tsx b/src/views/publish/children/pubRecord/page.tsx
index 2edbaed7..76c2edbc 100644
--- a/src/views/publish/children/pubRecord/page.tsx
+++ b/src/views/publish/children/pubRecord/page.tsx
@@ -23,7 +23,6 @@ import { useNavigate } from 'react-router-dom';
import { AccountType } from '../../../../../commont/AccountEnum';
import WebView from '../../../../components/WebView';
import { getVideoFile } from '../../../../components/Choose/VideoChoose';
-import { getVideoPreviewPage } from '../../../../utils/videoPub';
const PubCon = ({ prm }: { prm: PubRecordModel }) => {
const [imgFile, setImgFile] = useState<IImgFile>();
@@ -167,7 +166,7 @@ export default function Page() {
src={examineVideo.videoSrc}
controls
autoPlay
- style={{ margin: '0 auto', display: 'block' }}
+ style={{ margin: '0 auto', display: 'block', height: '100%' }}
/>
</>
) : (
@@ -267,8 +266,7 @@ export default function Page() {
if (account?.type === AccountType.WxSph) {
newState.videoSrc = videoFile.videoUrl;
} else {
- newState.url = getVideoPreviewPage(v);
- console.log(newState.url);
+ newState.url = v.previewVideoLink || '';
}
return newState;
});