Skip to content

Let's use AI to Earn!

feat: 快手添加简介、话题、位置、查看权限等参数

gaoSir4765362f2693
diff --git a/electron/db/models/workData.ts b/electron/db/models/workData.ts
index ed98a3ee..98ca4656 100644
--- a/electron/db/models/workData.ts
+++ b/electron/db/models/workData.ts
@@ -61,57 +61,11 @@ export class WorkData extends TempModel {
@Column({ type: 'varchar', nullable: false, comment: '用户id' })
userId!: string;
- // 标题
- @Column({ type: 'varchar', nullable: true, comment: '标题' })
- title?: string;
-
- // 简介
- @Column({ type: 'varchar', nullable: true, comment: '简介' })
- desc?: string;
-
- // 封面路径
- @Column({ type: 'varchar', nullable: true, comment: '封面路径' })
- coverPath?: string;
-
// 最后统计时间
@Column({ type: 'datetime', nullable: true, comment: '最后统计时间' })
lastStatsTime?: Date;
- // 话题
- @Column({ type: 'json', nullable: true, comment: '话题', default: '[]' })
- topics!: string[];
-
- // 位置
- @Column({ type: 'json', nullable: true, comment: '位置' })
- location?: ILocationDataItem;
-
- // 差异化参数
- @Column({
- type: 'json',
- nullable: true,
- comment: '不同平台的差异化参数',
- default: '{}',
- })
- diffParams?: DiffParmasType;
-
- // 可见性
- @Column({
- type: 'tinyint',
- nullable: false,
- comment: '可见性',
- default: VisibleTypeEnum.Private,
- })
- visibleType?: VisibleTypeEnum;
-
- // 定时发布日期
- @Column({ type: 'datetime', nullable: true, comment: '定时发布日期' })
- timingTime?: Date;
-
- // @用户
- @Column({ type: 'json', nullable: true, comment: '@用户数组', default: '[]' })
- mentionedUserInfo!: ILableValue[];
-
- // 预览地址
+ // 预览地址,这个值是发布完成手动拼接的
@Column({ type: 'varchar', nullable: true, comment: '预览地址' })
previewVideoLink?: string;
@@ -149,10 +103,6 @@ export class WorkData extends TempModel {
})
failMsg?: string;
- // 合集
- @Column({ type: 'json', nullable: true, comment: '合集' })
- mixInfo?: ILableValue;
-
// 状态
@Column({
type: 'tinyint',
@@ -186,5 +136,61 @@ export class WorkData extends TempModel {
@Column({ type: 'bigint', nullable: false, comment: '收益', default: 0 })
income?: number;
+ // 以下为发布需要的参数 --------------------------------------------------------------------
+
+ // 标题
+ @Column({ type: 'varchar', nullable: true, comment: '标题' })
+ title?: string;
+
+ // 简介,简介中不该包含话题,如果有需要每个平台再自己做处理。
+ @Column({ type: 'varchar', nullable: true, comment: '简介' })
+ desc?: string;
+
+ // 封面路径,机器的本地路径
+ @Column({ type: 'varchar', nullable: true, comment: '封面路径' })
+ coverPath?: string;
+
+ // 合集
+ @Column({ type: 'json', nullable: true, comment: '合集' })
+ mixInfo?: ILableValue;
+
+ // 话题 格式:['话题1', '话题2'],不该包含 ‘#’
+ @Column({ type: 'json', nullable: true, comment: '话题', default: '[]' })
+ topics!: string[];
+
+ // 位置
+ @Column({ type: 'json', nullable: true, comment: '位置' })
+ location?: ILocationDataItem;
+
+ /**
+ * 差异化参数
+ * 所有平台有通用参数,如:标题、话题、简介
+ * 也有每个平台自己独有的参数,如:抖音活动奖励、抖音热点、视频号声明原创
+ */
+ @Column({
+ type: 'json',
+ nullable: true,
+ comment: '不同平台的差异化参数',
+ default: '{}',
+ })
+ diffParams?: DiffParmasType;
+
+ // 可见性,作品的查看权限
+ @Column({
+ type: 'tinyint',
+ nullable: false,
+ comment: '可见性',
+ default: VisibleTypeEnum.Private,
+ })
+ visibleType?: VisibleTypeEnum;
+
+ // 定时发布日期
+ @Column({ type: 'datetime', nullable: true, comment: '定时发布日期' })
+ timingTime?: Date;
+
+ // @用户
+ @Column({ type: 'json', nullable: true, comment: '@用户数组', default: '[]' })
+ mentionedUserInfo!: ILableValue[];
+
cookies?: CookiesType;
}
diff --git a/electron/main/plat/platforms/Kwai/index.ts b/electron/main/plat/platforms/Kwai/index.ts
index b4c23221..84cc763e 100644
--- a/electron/main/plat/platforms/Kwai/index.ts
+++ b/electron/main/plat/platforms/Kwai/index.ts
@@ -26,10 +26,9 @@ import { IRequestNetResult } from '../../../../plat/requestNet';
import { IKwaiUserInfoResponse } from '../../../../plat/Kwai/kwai.type';
import { AccountType } from '../../../../../commont/AccountEnum';
import { AccountModel } from '../../../../db/models/account';
-import { VisibleTypeEnum } from '../../../../../commont/publish/PublishEnum';
-import { KwaiVisibleTypeEnum } from '../../../../plat/plat.common.type';
import dayjs from 'dayjs';
import { VideoModel } from '../../../../db/models/video';
+import { VisibleTypeEnum } from '../../../../../commont/publish/PublishEnum';
export class Kwai extends PlatformBase {
constructor() {
@@ -87,16 +86,25 @@ export class Kwai extends PlatformBase {
return new Promise(async (resolve) => {
const result = await kwaiPub
.pubVideo({
+ topics: params.topics || [],
videoPath: params.videoPath || '',
coverPath: params.coverPath || '',
cookies: params.cookies!,
desc: params.desc + params.topics.map((v) => `#${v}`).join(' '),
callback,
- visibleType: VisibleTypeEnum.Public
- ? KwaiVisibleTypeEnum.Public
- : VisibleTypeEnum.Friend
- ? KwaiVisibleTypeEnum.Friend
- : KwaiVisibleTypeEnum.Private,
+ photoStatus:
+ params.visibleType === VisibleTypeEnum.Public
+ ? 1
+ : params.visibleType === VisibleTypeEnum.Private
+ ? 2
+ : 4,
+ poiInfo: params.location
+ ? {
+ poiId: params.location.id,
+ latitude: `${params.location.latitude}`,
+ longitude: `${params.location.longitude}`,
+ }
+ : undefined,
})
.catch((e) => {
resolve({
diff --git a/electron/plat/Kwai/index.ts b/electron/plat/Kwai/index.ts
index a0d515b0..79a59cc7 100644
--- a/electron/plat/Kwai/index.ts
+++ b/electron/plat/Kwai/index.ts
@@ -17,7 +17,7 @@ import {
UploadPpreResponse,
} from './kwai.type';
import { CookieToString } from '../utils';
-import { BrowserWindow } from 'electron';
+import { BrowserWindow, screen } from 'electron';
import kwaiSign from './sign/KwaiSign';
import { FileUtils } from '../../util/file';
import { getFilePathNameCommon } from '../../../commont/utils';
@@ -30,6 +30,28 @@ interface IRequestApiParams extends IRequestNetParams {
class KwaiPub {
fileBlockSize = 4194304;
+ // 普通参数转换为快手参数
+ convertKwaiParams(params: IKwaiPubVideoParams) {
+ const kwaiParams: any = {};
+ kwaiParams['caption'] = params.desc;
+
+ // 话题处理
+ if (params.topics) {
+ kwaiParams['caption'] = ` ${params.topics.join(' ')}`;
+ }
+
+ // 位置处理
+ if (params.poiInfo) {
+ kwaiParams['poiId'] = params.poiInfo.poiId;
+ kwaiParams['latitude'] = params.poiInfo.latitude;
+ kwaiParams['longitude'] = params.poiInfo.longitude;
+ }
+
+ return {
+ ...kwaiParams,
+ photoStatus: params.photoStatus,
+ };
+ }
// 发布视频
async pubVideo(params: IKwaiPubVideoParams): Promise<{
publishId: string;
@@ -75,7 +97,7 @@ class KwaiPub {
console.log(uploadVideoRes.data);
}
- callback(60, `查看分片上传结果...`);
+ callback(60, `查询分片上传结果...`);
const completeRes = await this.requestApi({
apiUrl: `https://upload.kuaishouzt.com/api/upload/complete?upload_token=${preRes.data.data.token}&fragment_count=${filePartInfo.blockInfo.length}`,
method: 'POST',
@@ -99,12 +121,10 @@ class KwaiPub {
},
});
console.log(`视频上传结束:`, finishRes.data);
- callback(80, `视频上传结束,正发布视频...`);
+ callback(80, `正发布视频...`);
const submitParams = {
...finishRes.data.data,
coverTimeStamp: 0,
- caption: '',
- photoStatus: 2,
coverType: 1,
coverTitle: '',
photoType: 0,
@@ -133,6 +153,7 @@ class KwaiPub {
videoInfoMeta: '',
previewUrlErrorMessage: '',
triggerH265: false,
+ ...this.convertKwaiParams(params),
};
console.log('发布参数:', submitParams);
const submitRes = await this.requestApi<KwaiSubmitResponse>({
@@ -202,9 +223,10 @@ class KwaiPub {
login(): Promise<ILoginResponse> {
return new Promise(async (resolve, reject) => {
const partition = Date.now().toString();
+ const { width, height } = screen.getPrimaryDisplay().workAreaSize;
const mainWindow = new BrowserWindow({
- width: 1300,
- height: 600,
+ width: Math.ceil(width * 0.8),
+ height: Math.ceil(height * 0.8),
webPreferences: {
contextIsolation: false,
nodeIntegration: false,
diff --git a/electron/plat/Kwai/kwai.type.ts b/electron/plat/Kwai/kwai.type.ts
index 137b92f4..1a89c822 100644
--- a/electron/plat/Kwai/kwai.type.ts
+++ b/electron/plat/Kwai/kwai.type.ts
@@ -1,5 +1,4 @@
import { IRequestNetResult } from '../requestNet';
-import { KwaiVisibleTypeEnum } from '../plat.common.type';
interface AbConfig {
cpPublishNewPage2024: boolean;
@@ -149,16 +148,24 @@ export type IKwaiGetLocationsResponse = {
export interface IKwaiPubVideoParams {
// cookies
cookies: Electron.Cookie[];
+ // 话题
+ topics: string[];
// 发布视频的简介
desc: string;
// 视频的路径
videoPath: string;
// 封面路径
coverPath: string;
- // 视频可见性
- visibleType: KwaiVisibleTypeEnum;
// 发布回调,可以用于获取发布进度
callback: (progress: number, msg?: string) => void;
+ // 位置
+ poiInfo?: {
+ poiId: string;
+ latitude: string;
+ longitude: string;
+ };
+ // 作品权限 1=所有人可见 2=仅自己可见 4=好友可见
+ photoStatus: 1 | 2 | 4;
}
// 登录返回参数
diff --git a/electron/plat/plat.common.type.ts b/electron/plat/plat.common.type.ts
deleted file mode 100644
index 62364a99..00000000
--- a/electron/plat/plat.common.type.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export enum KwaiVisibleTypeEnum {
- // 仅自己可见
- Private = 1,
- // 好友可见
- Friend = 2,
- // 所有人可见
- Public = 3,
-}