@iflyrpa/actions 4.0.3 → 4.0.4-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -144,6 +144,36 @@ export declare class Action {
144
144
  collectNum: number;
145
145
  shareNum: number;
146
146
  originalData?: unknown;
147
+ } | {
148
+ title: string;
149
+ imageUrl: string;
150
+ createTime: number;
151
+ redirectUrl: string;
152
+ playNum: number;
153
+ likeNum: number;
154
+ commentNum: number;
155
+ shareNum: number;
156
+ collectNum: number;
157
+ awemeId: string;
158
+ awemeType: number;
159
+ status: string;
160
+ publicUrl: string;
161
+ originalData?: unknown;
162
+ duration?: number | undefined;
163
+ } | {
164
+ title: string;
165
+ imageUrl: string;
166
+ createTime: number;
167
+ redirectUrl: string;
168
+ readNum: number;
169
+ likeNum: number;
170
+ commentNum: number;
171
+ forwardNum: number;
172
+ favNum: number;
173
+ objectId: string;
174
+ postType: string;
175
+ postStatus: number;
176
+ originalData?: unknown;
147
177
  })[] | undefined;
148
178
  timerPublish?: ({
149
179
  title: string;
@@ -188,6 +218,36 @@ export declare class Action {
188
218
  collectNum: number;
189
219
  shareNum: number;
190
220
  originalData?: unknown;
221
+ } | {
222
+ title: string;
223
+ imageUrl: string;
224
+ createTime: number;
225
+ redirectUrl: string;
226
+ playNum: number;
227
+ likeNum: number;
228
+ commentNum: number;
229
+ shareNum: number;
230
+ collectNum: number;
231
+ awemeId: string;
232
+ awemeType: number;
233
+ status: string;
234
+ publicUrl: string;
235
+ originalData?: unknown;
236
+ duration?: number | undefined;
237
+ } | {
238
+ title: string;
239
+ imageUrl: string;
240
+ createTime: number;
241
+ redirectUrl: string;
242
+ readNum: number;
243
+ likeNum: number;
244
+ commentNum: number;
245
+ forwardNum: number;
246
+ favNum: number;
247
+ objectId: string;
248
+ postType: string;
249
+ postStatus: number;
250
+ originalData?: unknown;
191
251
  })[] | undefined;
192
252
  pagination?: {
193
253
  pageNum: number;
package/dist/index.js CHANGED
@@ -4398,9 +4398,7 @@ var __webpack_exports__ = {};
4398
4398
  });
4399
4399
  const package_json_namespaceObject = require("@iflyrpa/share/package.json");
4400
4400
  var package_json_default = /*#__PURE__*/ __webpack_require__.n(package_json_namespaceObject);
4401
- var package_namespaceObject = {
4402
- i8: "4.0.3"
4403
- };
4401
+ var package_namespaceObject = JSON.parse('{"i8":"4.0.4-beta.0"}');
4404
4402
  const share_namespaceObject = require("@iflyrpa/share");
4405
4403
  const external_node_fs_namespaceObject = require("node:fs");
4406
4404
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
@@ -15644,18 +15642,44 @@ var __webpack_exports__ = {};
15644
15642
  collectNum: schemas_number(),
15645
15643
  shareNum: schemas_number()
15646
15644
  });
15645
+ const DouyinArticleSchema = BaseArticleSchema.extend({
15646
+ playNum: schemas_number(),
15647
+ likeNum: schemas_number(),
15648
+ commentNum: schemas_number(),
15649
+ shareNum: schemas_number(),
15650
+ collectNum: schemas_number(),
15651
+ awemeId: schemas_string(),
15652
+ awemeType: schemas_number(),
15653
+ duration: schemas_number().optional(),
15654
+ status: schemas_string(),
15655
+ publicUrl: schemas_string()
15656
+ });
15657
+ const ShipinhaoArticleSchema = BaseArticleSchema.extend({
15658
+ readNum: schemas_number(),
15659
+ likeNum: schemas_number(),
15660
+ commentNum: schemas_number(),
15661
+ forwardNum: schemas_number(),
15662
+ favNum: schemas_number(),
15663
+ objectId: schemas_string(),
15664
+ postType: schemas_string(),
15665
+ postStatus: schemas_number()
15666
+ });
15647
15667
  const FetchArticlesDataSchema = schemas_object({
15648
15668
  articleCell: schemas_array(union([
15649
15669
  ToutiaoArticleSchema,
15650
15670
  WeixinArticleSchema,
15651
15671
  BaijiahaoArticleSchema,
15652
- XiaohongshuArticleSchema
15672
+ XiaohongshuArticleSchema,
15673
+ DouyinArticleSchema,
15674
+ ShipinhaoArticleSchema
15653
15675
  ])).optional(),
15654
15676
  timerPublish: schemas_array(union([
15655
15677
  ToutiaoArticleSchema,
15656
15678
  WeixinArticleSchema,
15657
15679
  BaijiahaoArticleSchema,
15658
- XiaohongshuArticleSchema
15680
+ XiaohongshuArticleSchema,
15681
+ DouyinArticleSchema,
15682
+ ShipinhaoArticleSchema
15659
15683
  ])).optional(),
15660
15684
  pagination: schemas_object({
15661
15685
  total: schemas_number().optional(),
@@ -15770,6 +15794,247 @@ var __webpack_exports__ = {};
15770
15794
  return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
15771
15795
  }
15772
15796
  }
15797
+ async function handleDouyinData(_task, params) {
15798
+ try {
15799
+ const { cookies, pageNum = 1, pageSize = 12, status = 0, showOriginalData = false, onlySuccess = false } = params;
15800
+ const headers = {
15801
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
15802
+ referer: "https://creator.douyin.com"
15803
+ };
15804
+ const args = [
15805
+ {
15806
+ headers
15807
+ },
15808
+ _task.logger,
15809
+ params.proxyLoc,
15810
+ params.localIP,
15811
+ params.accountId
15812
+ ];
15813
+ const http = new Http(...args);
15814
+ let authorUid = "";
15815
+ try {
15816
+ const userInfo = await http.api({
15817
+ method: "get",
15818
+ url: "https://creator.douyin.com/aweme/v1/creator/user/info/"
15819
+ }, {
15820
+ retries: 3,
15821
+ retryDelay: 100,
15822
+ timeout: 5000
15823
+ });
15824
+ authorUid = userInfo.user_profile?.unique_id || "";
15825
+ if (!userInfo.has_data_mgmt_perm) _task.logger.warn("抖音账号未开通数据中心权限,近7日数据不可用");
15826
+ } catch (error) {
15827
+ _task.logger.warn("获取抖音用户信息失败");
15828
+ }
15829
+ async function fetchWorks(cursor) {
15830
+ return await http.api({
15831
+ method: "get",
15832
+ url: "https://creator.douyin.com/janus/douyin/creator/pc/work_list",
15833
+ params: {
15834
+ scene: "star_atlas",
15835
+ device_platform: "android",
15836
+ aid: 1128,
15837
+ status,
15838
+ count: pageSize,
15839
+ max_cursor: cursor
15840
+ }
15841
+ }, {
15842
+ retries: 3,
15843
+ retryDelay: 100,
15844
+ timeout: 5000
15845
+ });
15846
+ }
15847
+ const firstPageCursor = (pageNum - 1) * pageSize;
15848
+ const workListResponse = await fetchWorks(firstPageCursor);
15849
+ if (!workListResponse || !workListResponse.aweme_list) return searchPublishInfo_types_errorResponse("抖音数据获取失败,请检查账号状态", 414);
15850
+ const allWorks = [
15851
+ ...workListResponse.aweme_list
15852
+ ];
15853
+ let hasMore = workListResponse.has_more;
15854
+ let currentCursor = workListResponse.max_cursor;
15855
+ while(allWorks.length < pageSize && hasMore && !onlySuccess){
15856
+ const nextPageResponse = await fetchWorks(currentCursor);
15857
+ allWorks.push(...nextPageResponse.aweme_list);
15858
+ hasMore = nextPageResponse.has_more;
15859
+ currentCursor = nextPageResponse.max_cursor;
15860
+ if (allWorks.length >= 2 * pageSize) break;
15861
+ }
15862
+ const finalWorks = allWorks.slice(0, pageSize);
15863
+ const articleCell = finalWorks.map((item)=>{
15864
+ const workDetailUrl = `https://creator.douyin.com/creator-micro/work-management/work-detail/${item.aweme_id}`;
15865
+ const workPublicUrl = authorUid ? `https://www.douyin.com/user/${authorUid}?modal_id=${item.aweme_id}` : `https://www.douyin.com/video/${item.aweme_id}`;
15866
+ return {
15867
+ title: item.desc || "无作品描述",
15868
+ imageUrl: item.Cover?.url_list?.[0] || "",
15869
+ createTime: item.create_time,
15870
+ redirectUrl: workDetailUrl,
15871
+ playNum: item.statistics?.play_count || 0,
15872
+ likeNum: item.statistics?.digg_count || 0,
15873
+ commentNum: item.statistics?.comment_count || 0,
15874
+ shareNum: item.statistics?.share_count || 0,
15875
+ collectNum: item.statistics?.collect_count || 0,
15876
+ awemeId: item.aweme_id,
15877
+ awemeType: item.aweme_type,
15878
+ duration: item.duration,
15879
+ status: item.status?.is_private ? "private" : item.status?.in_reviewing ? "reviewing" : "public",
15880
+ publicUrl: workPublicUrl,
15881
+ ...showOriginalData ? {
15882
+ originalData: item
15883
+ } : {}
15884
+ };
15885
+ });
15886
+ return (0, share_namespaceObject.success)({
15887
+ articleCell,
15888
+ ...onlySuccess ? {
15889
+ pagination: {
15890
+ total: workListResponse.total || workListResponse.aweme_list.length,
15891
+ nextPage: workListResponse.has_more,
15892
+ pageNum,
15893
+ pageSize
15894
+ }
15895
+ } : null
15896
+ }, "抖音数据获取成功");
15897
+ } catch (error) {
15898
+ return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "抖音数据获取失败");
15899
+ }
15900
+ }
15901
+ async function handleShipinhaoData(_task, params) {
15902
+ try {
15903
+ const { cookies, postType = "all", pageNum = 1, pageSize = 20, showOriginalData = false } = params;
15904
+ const aidCookie = cookies.find((it)=>"_aid" === it.name)?.value;
15905
+ const aid = aidCookie || "9d3e0e9f-b842-498d-a273-4285d58df264";
15906
+ const uinCookie = cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
15907
+ const deviceIdCookie = cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
15908
+ const headers = {
15909
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
15910
+ referer: "https://channels.weixin.qq.com",
15911
+ origin: "https://channels.weixin.qq.com",
15912
+ "content-type": "application/json",
15913
+ "X-WECHAT-UIN": uinCookie,
15914
+ ...deviceIdCookie ? {
15915
+ "finger-print-device-id": deviceIdCookie
15916
+ } : {}
15917
+ };
15918
+ const args = [
15919
+ {
15920
+ headers
15921
+ },
15922
+ _task.logger,
15923
+ params.proxyLoc,
15924
+ params.localIP,
15925
+ params.accountId
15926
+ ];
15927
+ const http = new Http(...args);
15928
+ const finderIdCookie = cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
15929
+ async function fetchPosts(currentPage, userpageType, pageUrl) {
15930
+ return await http.api({
15931
+ method: "post",
15932
+ url: "https://channels.weixin.qq.com/micro/content/cgi-bin/mmfinderassistant-bin/post/post_list",
15933
+ params: {
15934
+ _aid: aid,
15935
+ _rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
15936
+ _pageUrl: encodeURIComponent(pageUrl)
15937
+ },
15938
+ data: {
15939
+ pageSize,
15940
+ currentPage,
15941
+ userpageType,
15942
+ stickyOrder: true,
15943
+ timestamp: Date.now().toString(),
15944
+ _log_finder_uin: "",
15945
+ _log_finder_id: finderIdCookie,
15946
+ rawKeyBuff: "",
15947
+ pluginSessionId: null,
15948
+ scene: 7,
15949
+ reqScene: 7
15950
+ }
15951
+ }, {
15952
+ retries: 3,
15953
+ retryDelay: 100,
15954
+ timeout: 5000
15955
+ });
15956
+ }
15957
+ const mapPost = (item, forcePostType)=>{
15958
+ let imageUrl = "";
15959
+ if (item.desc?.media?.[0]?.thumbUrl) imageUrl = item.desc.media[0].thumbUrl;
15960
+ else if (item.desc?.media?.[0]?.coverUrl) imageUrl = item.desc.media[0].coverUrl;
15961
+ else if (item.cover?.url) imageUrl = item.cover.url;
15962
+ else if (item.media_url) imageUrl = item.media_url;
15963
+ const title = item.desc?.description || item.object_desc || "无标题";
15964
+ return {
15965
+ title,
15966
+ imageUrl,
15967
+ createTime: item.createTime || item.create_time,
15968
+ redirectUrl: "https://channels.weixin.qq.com/platform",
15969
+ readNum: item.readCount || item.read_count || 0,
15970
+ likeNum: item.likeCount || item.like_count || 0,
15971
+ commentNum: item.commentCount || item.comment_count || 0,
15972
+ forwardNum: item.forwardCount || item.forward_count || 0,
15973
+ favNum: item.favCount || item.fav_count || 0,
15974
+ objectId: item.exportId || item.objectId || "",
15975
+ postType: forcePostType,
15976
+ postStatus: item.status || item.post_status || 0,
15977
+ ...showOriginalData ? {
15978
+ originalData: item
15979
+ } : {}
15980
+ };
15981
+ };
15982
+ const allArticles = [];
15983
+ const needVideo = "all" === postType || "video" === postType;
15984
+ const needArticle = "all" === postType || "article" === postType;
15985
+ const AUTH_ERROR_CODES = [
15986
+ 300333,
15987
+ 300334
15988
+ ];
15989
+ if (needVideo) try {
15990
+ const videoPageUrl = "https://channels.weixin.qq.com/micro/content/post/list";
15991
+ const videoResponse = await fetchPosts(pageNum, 11, videoPageUrl);
15992
+ if (videoResponse.errCode && AUTH_ERROR_CODES.includes(videoResponse.errCode)) throw new Error(`AUTH_ERROR:${videoResponse.errMsg || "登录已失效"}`);
15993
+ if (videoResponse.errCode) _task.logger.warn(`视频号API错误:${videoResponse.errMsg} (${videoResponse.errCode})`);
15994
+ else {
15995
+ const posts = videoResponse.data?.list || videoResponse.posts || videoResponse.post_list || [];
15996
+ const videoArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "video"));
15997
+ allArticles.push(...videoArticles);
15998
+ _task.logger.info(`视频号视频获取成功,共${videoArticles.length}条`);
15999
+ }
16000
+ } catch (error) {
16001
+ const errMsg = error instanceof Error ? error.message : String(error);
16002
+ if (errMsg.startsWith("AUTH_ERROR:")) throw error;
16003
+ _task.logger.warn(`获取视频号视频失败:${errMsg}`);
16004
+ }
16005
+ if (needArticle) try {
16006
+ const articlePageUrl = "https://channels.weixin.qq.com/micro/content/post/finderNewLifePostList";
16007
+ const articleResponse = await fetchPosts(pageNum, 10, articlePageUrl);
16008
+ if (articleResponse.errCode && AUTH_ERROR_CODES.includes(articleResponse.errCode)) throw new Error(`AUTH_ERROR:${articleResponse.errMsg || "登录已失效"}`);
16009
+ if (articleResponse.errCode) _task.logger.warn(`视频号图文API错误:${articleResponse.errMsg} (${articleResponse.errCode})`);
16010
+ else {
16011
+ const posts = articleResponse.data?.list || articleResponse.posts || articleResponse.post_list || [];
16012
+ const articleArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "article"));
16013
+ allArticles.push(...articleArticles);
16014
+ _task.logger.info(`视频号图文获取成功,共${articleArticles.length}条`);
16015
+ }
16016
+ } catch (error) {
16017
+ const errMsg = error instanceof Error ? error.message : String(error);
16018
+ if (errMsg.startsWith("AUTH_ERROR:")) throw error;
16019
+ _task.logger.warn(`获取视频号图文失败:${errMsg}`);
16020
+ }
16021
+ allArticles.sort((a, b)=>b.createTime - a.createTime);
16022
+ _task.logger.info(`视频号数据获取成功,${JSON.stringify(allArticles)}`);
16023
+ return (0, share_namespaceObject.success)({
16024
+ articleCell: allArticles,
16025
+ pagination: {
16026
+ total: allArticles.length,
16027
+ nextPage: false,
16028
+ pageNum,
16029
+ pageSize
16030
+ }
16031
+ }, "视频号数据获取成功");
16032
+ } catch (error) {
16033
+ const errMsg = error instanceof Error ? error.message : String(error);
16034
+ if (errMsg.startsWith("AUTH_ERROR:")) return searchPublishInfo_types_errorResponse("视频号数据获取失败,请检查账号状态", 414);
16035
+ return searchPublishInfo_types_errorResponse(errMsg || "视频号数据获取失败");
16036
+ }
16037
+ }
15773
16038
  async function handleToutiaoData(_task, params) {
15774
16039
  try {
15775
16040
  const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false, containsArticle = false } = params;
@@ -15802,7 +16067,7 @@ var __webpack_exports__ = {};
15802
16067
  app_id: 1231
15803
16068
  }
15804
16069
  });
15805
- if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("头条号账号信息获取失败,请检查账号状态", 414);
16070
+ if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("头条号数据获取失败,请检查账号状态", 414);
15806
16071
  const articleInfo = await http.api({
15807
16072
  method: "get",
15808
16073
  url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
@@ -15911,7 +16176,7 @@ var __webpack_exports__ = {};
15911
16176
  const size = onlySuccess ? 10 : pageSize > 20 ? 20 : pageSize;
15912
16177
  let begin = (lastPage ?? pageNum) - 1;
15913
16178
  const rawArticlesInfo = await fetchArticles(begin * size, size, token);
15914
- if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("登陆已失效,请重新登陆!", 414);
16179
+ if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("微信公众号数据获取失败,请检查账号状态", 414);
15915
16180
  const articlesInfo = ParsePublishPage(rawArticlesInfo);
15916
16181
  let articleCell = [];
15917
16182
  if (!onlySuccess && pageSize > 20) {
@@ -16073,7 +16338,7 @@ var __webpack_exports__ = {};
16073
16338
  const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
16074
16339
  if (!a1Cookie) return {
16075
16340
  code: 414,
16076
- message: "账号数据异常",
16341
+ message: "小红书数据获取失败,请检查账号状态",
16077
16342
  data: {}
16078
16343
  };
16079
16344
  if (onlySuccess && 10 !== pageSize) return {
@@ -16192,7 +16457,7 @@ var __webpack_exports__ = {};
16192
16457
  }, "小红书文章数据获取成功");
16193
16458
  }
16194
16459
  const FetchArticlesParamsSchema = ActionCommonParamsSchema.extend({
16195
- platform: schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu"),
16460
+ platform: schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu, douyin, shipinhao"),
16196
16461
  token: union([
16197
16462
  schemas_string(),
16198
16463
  schemas_number()
@@ -16204,7 +16469,14 @@ var __webpack_exports__ = {};
16204
16469
  showOriginalData: schemas_boolean().optional().describe("是否展示原始数据,默认false"),
16205
16470
  cursor: schemas_number().optional().describe("仅用于微信分页游标,默认为空"),
16206
16471
  lastPage: schemas_number().optional(),
16207
- containsArticle: schemas_boolean().optional().describe("是否包含文章内容,默认false")
16472
+ containsArticle: schemas_boolean().optional().describe("是否包含文章内容,默认false"),
16473
+ status: schemas_number().optional().describe("抖音作品状态:0=全部"),
16474
+ includeAccount: schemas_boolean().optional().describe("是否包含账号数据,默认true"),
16475
+ postType: schemas_enum([
16476
+ "video",
16477
+ "article",
16478
+ "all"
16479
+ ]).optional().describe("视频号作品类型:video=视频, article=图文, all=全部")
16208
16480
  });
16209
16481
  const FetchArticles = async (_task, params)=>{
16210
16482
  const { platform } = params;
@@ -16217,6 +16489,10 @@ var __webpack_exports__ = {};
16217
16489
  return handleBaijiahaoData(_task, params);
16218
16490
  case "xiaohongshu":
16219
16491
  return handleXiaohongshuData(_task, params);
16492
+ case "douyin":
16493
+ return handleDouyinData(_task, params);
16494
+ case "shipinhao":
16495
+ return handleShipinhaoData(_task, params);
16220
16496
  default:
16221
16497
  return (0, share_namespaceObject.success)({}, "暂不支持该平台");
16222
16498
  }