@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.mjs CHANGED
@@ -4350,9 +4350,7 @@ function __webpack_require__(moduleId) {
4350
4350
  return module;
4351
4351
  };
4352
4352
  })();
4353
- var package_namespaceObject = {
4354
- i8: "4.0.3"
4355
- };
4353
+ var package_namespaceObject = JSON.parse('{"i8":"4.0.4-beta.0"}');
4356
4354
  const PROXY_CREDENTIALS = [
4357
4355
  {
4358
4356
  ip: "47.110.131.129",
@@ -15567,18 +15565,44 @@ const XiaohongshuArticleSchema = BaseArticleSchema.extend({
15567
15565
  collectNum: schemas_number(),
15568
15566
  shareNum: schemas_number()
15569
15567
  });
15568
+ const DouyinArticleSchema = BaseArticleSchema.extend({
15569
+ playNum: schemas_number(),
15570
+ likeNum: schemas_number(),
15571
+ commentNum: schemas_number(),
15572
+ shareNum: schemas_number(),
15573
+ collectNum: schemas_number(),
15574
+ awemeId: schemas_string(),
15575
+ awemeType: schemas_number(),
15576
+ duration: schemas_number().optional(),
15577
+ status: schemas_string(),
15578
+ publicUrl: schemas_string()
15579
+ });
15580
+ const ShipinhaoArticleSchema = BaseArticleSchema.extend({
15581
+ readNum: schemas_number(),
15582
+ likeNum: schemas_number(),
15583
+ commentNum: schemas_number(),
15584
+ forwardNum: schemas_number(),
15585
+ favNum: schemas_number(),
15586
+ objectId: schemas_string(),
15587
+ postType: schemas_string(),
15588
+ postStatus: schemas_number()
15589
+ });
15570
15590
  const FetchArticlesDataSchema = schemas_object({
15571
15591
  articleCell: schemas_array(union([
15572
15592
  ToutiaoArticleSchema,
15573
15593
  WeixinArticleSchema,
15574
15594
  BaijiahaoArticleSchema,
15575
- XiaohongshuArticleSchema
15595
+ XiaohongshuArticleSchema,
15596
+ DouyinArticleSchema,
15597
+ ShipinhaoArticleSchema
15576
15598
  ])).optional(),
15577
15599
  timerPublish: schemas_array(union([
15578
15600
  ToutiaoArticleSchema,
15579
15601
  WeixinArticleSchema,
15580
15602
  BaijiahaoArticleSchema,
15581
- XiaohongshuArticleSchema
15603
+ XiaohongshuArticleSchema,
15604
+ DouyinArticleSchema,
15605
+ ShipinhaoArticleSchema
15582
15606
  ])).optional(),
15583
15607
  pagination: schemas_object({
15584
15608
  total: schemas_number().optional(),
@@ -15693,6 +15717,247 @@ async function handleBaijiahaoData(_task, params) {
15693
15717
  return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
15694
15718
  }
15695
15719
  }
15720
+ async function handleDouyinData(_task, params) {
15721
+ try {
15722
+ const { cookies, pageNum = 1, pageSize = 12, status = 0, showOriginalData = false, onlySuccess = false } = params;
15723
+ const headers = {
15724
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
15725
+ referer: "https://creator.douyin.com"
15726
+ };
15727
+ const args = [
15728
+ {
15729
+ headers
15730
+ },
15731
+ _task.logger,
15732
+ params.proxyLoc,
15733
+ params.localIP,
15734
+ params.accountId
15735
+ ];
15736
+ const http = new Http(...args);
15737
+ let authorUid = "";
15738
+ try {
15739
+ const userInfo = await http.api({
15740
+ method: "get",
15741
+ url: "https://creator.douyin.com/aweme/v1/creator/user/info/"
15742
+ }, {
15743
+ retries: 3,
15744
+ retryDelay: 100,
15745
+ timeout: 5000
15746
+ });
15747
+ authorUid = userInfo.user_profile?.unique_id || "";
15748
+ if (!userInfo.has_data_mgmt_perm) _task.logger.warn("抖音账号未开通数据中心权限,近7日数据不可用");
15749
+ } catch (error) {
15750
+ _task.logger.warn("获取抖音用户信息失败");
15751
+ }
15752
+ async function fetchWorks(cursor) {
15753
+ return await http.api({
15754
+ method: "get",
15755
+ url: "https://creator.douyin.com/janus/douyin/creator/pc/work_list",
15756
+ params: {
15757
+ scene: "star_atlas",
15758
+ device_platform: "android",
15759
+ aid: 1128,
15760
+ status,
15761
+ count: pageSize,
15762
+ max_cursor: cursor
15763
+ }
15764
+ }, {
15765
+ retries: 3,
15766
+ retryDelay: 100,
15767
+ timeout: 5000
15768
+ });
15769
+ }
15770
+ const firstPageCursor = (pageNum - 1) * pageSize;
15771
+ const workListResponse = await fetchWorks(firstPageCursor);
15772
+ if (!workListResponse || !workListResponse.aweme_list) return searchPublishInfo_types_errorResponse("抖音数据获取失败,请检查账号状态", 414);
15773
+ const allWorks = [
15774
+ ...workListResponse.aweme_list
15775
+ ];
15776
+ let hasMore = workListResponse.has_more;
15777
+ let currentCursor = workListResponse.max_cursor;
15778
+ while(allWorks.length < pageSize && hasMore && !onlySuccess){
15779
+ const nextPageResponse = await fetchWorks(currentCursor);
15780
+ allWorks.push(...nextPageResponse.aweme_list);
15781
+ hasMore = nextPageResponse.has_more;
15782
+ currentCursor = nextPageResponse.max_cursor;
15783
+ if (allWorks.length >= 2 * pageSize) break;
15784
+ }
15785
+ const finalWorks = allWorks.slice(0, pageSize);
15786
+ const articleCell = finalWorks.map((item)=>{
15787
+ const workDetailUrl = `https://creator.douyin.com/creator-micro/work-management/work-detail/${item.aweme_id}`;
15788
+ const workPublicUrl = authorUid ? `https://www.douyin.com/user/${authorUid}?modal_id=${item.aweme_id}` : `https://www.douyin.com/video/${item.aweme_id}`;
15789
+ return {
15790
+ title: item.desc || "无作品描述",
15791
+ imageUrl: item.Cover?.url_list?.[0] || "",
15792
+ createTime: item.create_time,
15793
+ redirectUrl: workDetailUrl,
15794
+ playNum: item.statistics?.play_count || 0,
15795
+ likeNum: item.statistics?.digg_count || 0,
15796
+ commentNum: item.statistics?.comment_count || 0,
15797
+ shareNum: item.statistics?.share_count || 0,
15798
+ collectNum: item.statistics?.collect_count || 0,
15799
+ awemeId: item.aweme_id,
15800
+ awemeType: item.aweme_type,
15801
+ duration: item.duration,
15802
+ status: item.status?.is_private ? "private" : item.status?.in_reviewing ? "reviewing" : "public",
15803
+ publicUrl: workPublicUrl,
15804
+ ...showOriginalData ? {
15805
+ originalData: item
15806
+ } : {}
15807
+ };
15808
+ });
15809
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
15810
+ articleCell,
15811
+ ...onlySuccess ? {
15812
+ pagination: {
15813
+ total: workListResponse.total || workListResponse.aweme_list.length,
15814
+ nextPage: workListResponse.has_more,
15815
+ pageNum,
15816
+ pageSize
15817
+ }
15818
+ } : null
15819
+ }, "抖音数据获取成功");
15820
+ } catch (error) {
15821
+ return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "抖音数据获取失败");
15822
+ }
15823
+ }
15824
+ async function handleShipinhaoData(_task, params) {
15825
+ try {
15826
+ const { cookies, postType = "all", pageNum = 1, pageSize = 20, showOriginalData = false } = params;
15827
+ const aidCookie = cookies.find((it)=>"_aid" === it.name)?.value;
15828
+ const aid = aidCookie || "9d3e0e9f-b842-498d-a273-4285d58df264";
15829
+ const uinCookie = cookies.find((it)=>"uin" === it.name || "wxuin" === it.name)?.value || "0000000000";
15830
+ const deviceIdCookie = cookies.find((it)=>"device_id" === it.name || "finger_print_device_id" === it.name)?.value;
15831
+ const headers = {
15832
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
15833
+ referer: "https://channels.weixin.qq.com",
15834
+ origin: "https://channels.weixin.qq.com",
15835
+ "content-type": "application/json",
15836
+ "X-WECHAT-UIN": uinCookie,
15837
+ ...deviceIdCookie ? {
15838
+ "finger-print-device-id": deviceIdCookie
15839
+ } : {}
15840
+ };
15841
+ const args = [
15842
+ {
15843
+ headers
15844
+ },
15845
+ _task.logger,
15846
+ params.proxyLoc,
15847
+ params.localIP,
15848
+ params.accountId
15849
+ ];
15850
+ const http = new Http(...args);
15851
+ const finderIdCookie = cookies.find((it)=>"_log_finder_id" === it.name || "finder_id" === it.name)?.value || "";
15852
+ async function fetchPosts(currentPage, userpageType, pageUrl) {
15853
+ return await http.api({
15854
+ method: "post",
15855
+ url: "https://channels.weixin.qq.com/micro/content/cgi-bin/mmfinderassistant-bin/post/post_list",
15856
+ params: {
15857
+ _aid: aid,
15858
+ _rid: `${Date.now().toString(16)}-${Math.random().toString(36).substring(2, 9)}`,
15859
+ _pageUrl: encodeURIComponent(pageUrl)
15860
+ },
15861
+ data: {
15862
+ pageSize,
15863
+ currentPage,
15864
+ userpageType,
15865
+ stickyOrder: true,
15866
+ timestamp: Date.now().toString(),
15867
+ _log_finder_uin: "",
15868
+ _log_finder_id: finderIdCookie,
15869
+ rawKeyBuff: "",
15870
+ pluginSessionId: null,
15871
+ scene: 7,
15872
+ reqScene: 7
15873
+ }
15874
+ }, {
15875
+ retries: 3,
15876
+ retryDelay: 100,
15877
+ timeout: 5000
15878
+ });
15879
+ }
15880
+ const mapPost = (item, forcePostType)=>{
15881
+ let imageUrl = "";
15882
+ if (item.desc?.media?.[0]?.thumbUrl) imageUrl = item.desc.media[0].thumbUrl;
15883
+ else if (item.desc?.media?.[0]?.coverUrl) imageUrl = item.desc.media[0].coverUrl;
15884
+ else if (item.cover?.url) imageUrl = item.cover.url;
15885
+ else if (item.media_url) imageUrl = item.media_url;
15886
+ const title = item.desc?.description || item.object_desc || "无标题";
15887
+ return {
15888
+ title,
15889
+ imageUrl,
15890
+ createTime: item.createTime || item.create_time,
15891
+ redirectUrl: "https://channels.weixin.qq.com/platform",
15892
+ readNum: item.readCount || item.read_count || 0,
15893
+ likeNum: item.likeCount || item.like_count || 0,
15894
+ commentNum: item.commentCount || item.comment_count || 0,
15895
+ forwardNum: item.forwardCount || item.forward_count || 0,
15896
+ favNum: item.favCount || item.fav_count || 0,
15897
+ objectId: item.exportId || item.objectId || "",
15898
+ postType: forcePostType,
15899
+ postStatus: item.status || item.post_status || 0,
15900
+ ...showOriginalData ? {
15901
+ originalData: item
15902
+ } : {}
15903
+ };
15904
+ };
15905
+ const allArticles = [];
15906
+ const needVideo = "all" === postType || "video" === postType;
15907
+ const needArticle = "all" === postType || "article" === postType;
15908
+ const AUTH_ERROR_CODES = [
15909
+ 300333,
15910
+ 300334
15911
+ ];
15912
+ if (needVideo) try {
15913
+ const videoPageUrl = "https://channels.weixin.qq.com/micro/content/post/list";
15914
+ const videoResponse = await fetchPosts(pageNum, 11, videoPageUrl);
15915
+ if (videoResponse.errCode && AUTH_ERROR_CODES.includes(videoResponse.errCode)) throw new Error(`AUTH_ERROR:${videoResponse.errMsg || "登录已失效"}`);
15916
+ if (videoResponse.errCode) _task.logger.warn(`视频号API错误:${videoResponse.errMsg} (${videoResponse.errCode})`);
15917
+ else {
15918
+ const posts = videoResponse.data?.list || videoResponse.posts || videoResponse.post_list || [];
15919
+ const videoArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "video"));
15920
+ allArticles.push(...videoArticles);
15921
+ _task.logger.info(`视频号视频获取成功,共${videoArticles.length}条`);
15922
+ }
15923
+ } catch (error) {
15924
+ const errMsg = error instanceof Error ? error.message : String(error);
15925
+ if (errMsg.startsWith("AUTH_ERROR:")) throw error;
15926
+ _task.logger.warn(`获取视频号视频失败:${errMsg}`);
15927
+ }
15928
+ if (needArticle) try {
15929
+ const articlePageUrl = "https://channels.weixin.qq.com/micro/content/post/finderNewLifePostList";
15930
+ const articleResponse = await fetchPosts(pageNum, 10, articlePageUrl);
15931
+ if (articleResponse.errCode && AUTH_ERROR_CODES.includes(articleResponse.errCode)) throw new Error(`AUTH_ERROR:${articleResponse.errMsg || "登录已失效"}`);
15932
+ if (articleResponse.errCode) _task.logger.warn(`视频号图文API错误:${articleResponse.errMsg} (${articleResponse.errCode})`);
15933
+ else {
15934
+ const posts = articleResponse.data?.list || articleResponse.posts || articleResponse.post_list || [];
15935
+ const articleArticles = posts.filter((item)=>item.createTime || item.create_time).map((item)=>mapPost(item, "article"));
15936
+ allArticles.push(...articleArticles);
15937
+ _task.logger.info(`视频号图文获取成功,共${articleArticles.length}条`);
15938
+ }
15939
+ } catch (error) {
15940
+ const errMsg = error instanceof Error ? error.message : String(error);
15941
+ if (errMsg.startsWith("AUTH_ERROR:")) throw error;
15942
+ _task.logger.warn(`获取视频号图文失败:${errMsg}`);
15943
+ }
15944
+ allArticles.sort((a, b)=>b.createTime - a.createTime);
15945
+ _task.logger.info(`视频号数据获取成功,${JSON.stringify(allArticles)}`);
15946
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
15947
+ articleCell: allArticles,
15948
+ pagination: {
15949
+ total: allArticles.length,
15950
+ nextPage: false,
15951
+ pageNum,
15952
+ pageSize
15953
+ }
15954
+ }, "视频号数据获取成功");
15955
+ } catch (error) {
15956
+ const errMsg = error instanceof Error ? error.message : String(error);
15957
+ if (errMsg.startsWith("AUTH_ERROR:")) return searchPublishInfo_types_errorResponse("视频号数据获取失败,请检查账号状态", 414);
15958
+ return searchPublishInfo_types_errorResponse(errMsg || "视频号数据获取失败");
15959
+ }
15960
+ }
15696
15961
  async function handleToutiaoData(_task, params) {
15697
15962
  try {
15698
15963
  const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false, containsArticle = false } = params;
@@ -15725,7 +15990,7 @@ async function handleToutiaoData(_task, params) {
15725
15990
  app_id: 1231
15726
15991
  }
15727
15992
  });
15728
- if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("头条号账号信息获取失败,请检查账号状态", 414);
15993
+ if (0 !== visitedUid.code) return searchPublishInfo_types_errorResponse("头条号数据获取失败,请检查账号状态", 414);
15729
15994
  const articleInfo = await http.api({
15730
15995
  method: "get",
15731
15996
  url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
@@ -15832,7 +16097,7 @@ async function handleWeixinData(_task, params) {
15832
16097
  const size = onlySuccess ? 10 : pageSize > 20 ? 20 : pageSize;
15833
16098
  let begin = (lastPage ?? pageNum) - 1;
15834
16099
  const rawArticlesInfo = await fetchArticles(begin * size, size, token);
15835
- if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("登陆已失效,请重新登陆!", 414);
16100
+ if (rawArticlesInfo.includes("请重新<a id='jumpUrl' href='/'>登录</a>")) return searchPublishInfo_types_errorResponse("微信公众号数据获取失败,请检查账号状态", 414);
15836
16101
  const articlesInfo = ParsePublishPage(rawArticlesInfo);
15837
16102
  let articleCell = [];
15838
16103
  if (!onlySuccess && pageSize > 20) {
@@ -15994,7 +16259,7 @@ async function handleXiaohongshuData(_task, params) {
15994
16259
  const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
15995
16260
  if (!a1Cookie) return {
15996
16261
  code: 414,
15997
- message: "账号数据异常",
16262
+ message: "小红书数据获取失败,请检查账号状态",
15998
16263
  data: {}
15999
16264
  };
16000
16265
  if (onlySuccess && 10 !== pageSize) return {
@@ -16113,7 +16378,7 @@ async function handleXiaohongshuData(_task, params) {
16113
16378
  }, "小红书文章数据获取成功");
16114
16379
  }
16115
16380
  const FetchArticlesParamsSchema = ActionCommonParamsSchema.extend({
16116
- platform: schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu"),
16381
+ platform: schemas_string().describe("社交平台:weixin, toutiao, baijiahao, xiaohongshu, douyin, shipinhao"),
16117
16382
  token: union([
16118
16383
  schemas_string(),
16119
16384
  schemas_number()
@@ -16125,7 +16390,14 @@ const FetchArticlesParamsSchema = ActionCommonParamsSchema.extend({
16125
16390
  showOriginalData: schemas_boolean().optional().describe("是否展示原始数据,默认false"),
16126
16391
  cursor: schemas_number().optional().describe("仅用于微信分页游标,默认为空"),
16127
16392
  lastPage: schemas_number().optional(),
16128
- containsArticle: schemas_boolean().optional().describe("是否包含文章内容,默认false")
16393
+ containsArticle: schemas_boolean().optional().describe("是否包含文章内容,默认false"),
16394
+ status: schemas_number().optional().describe("抖音作品状态:0=全部"),
16395
+ includeAccount: schemas_boolean().optional().describe("是否包含账号数据,默认true"),
16396
+ postType: schemas_enum([
16397
+ "video",
16398
+ "article",
16399
+ "all"
16400
+ ]).optional().describe("视频号作品类型:video=视频, article=图文, all=全部")
16129
16401
  });
16130
16402
  const FetchArticles = async (_task, params)=>{
16131
16403
  const { platform } = params;
@@ -16138,6 +16410,10 @@ const FetchArticles = async (_task, params)=>{
16138
16410
  return handleBaijiahaoData(_task, params);
16139
16411
  case "xiaohongshu":
16140
16412
  return handleXiaohongshuData(_task, params);
16413
+ case "douyin":
16414
+ return handleDouyinData(_task, params);
16415
+ case "shipinhao":
16416
+ return handleShipinhaoData(_task, params);
16141
16417
  default:
16142
16418
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({}, "暂不支持该平台");
16143
16419
  }