@iflyrpa/actions 1.2.16-beta.4 → 1.2.16

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.js CHANGED
@@ -1168,9 +1168,7 @@ var __webpack_exports__ = {};
1168
1168
  };
1169
1169
  }
1170
1170
  constructor(config){
1171
- this.apiClient = external_axios_default().create({
1172
- ...config
1173
- });
1171
+ this.apiClient = external_axios_default().create(config);
1174
1172
  }
1175
1173
  addResponseInterceptor(findError) {
1176
1174
  this.apiClient.interceptors.response.use((response)=>{
@@ -1861,20 +1859,12 @@ var __webpack_exports__ = {};
1861
1859
  type: "news"
1862
1860
  }
1863
1861
  });
1864
- const data = res?.data?.article.activity_list.map((_item)=>({
1862
+ return (0, share_namespaceObject.success)(res?.data?.article.activity_list.map((_item)=>({
1865
1863
  id: _item.id,
1866
1864
  name: _item.name,
1867
1865
  detail: _item.detail,
1868
1866
  is_enable: _item.is_enable
1869
- })) ?? [];
1870
- data.push({
1871
- id: "bjh_publish_num_left",
1872
- name: "账号剩余发文数",
1873
- detail: "",
1874
- is_enable: 1,
1875
- publish_num_left: res.data.ability.publish_num_left
1876
- });
1877
- return (0, share_namespaceObject.success)(data, "获取百家号配置项成功!");
1867
+ })) ?? [], "获取头条发布配置项成功");
1878
1868
  };
1879
1869
  const searchToutiaoTopicList = async (_task, params)=>{
1880
1870
  const http = new Http({
@@ -2044,7 +2034,7 @@ var __webpack_exports__ = {};
2044
2034
  this.iv = external_node_buffer_namespaceObject.Buffer.from("4uzjr7mbsibcaldp", "utf8");
2045
2035
  }
2046
2036
  }
2047
- const searchXiaohongshuTopicList_xsEncrypt = new XsEncrypt();
2037
+ const xsEncrypt = new XsEncrypt();
2048
2038
  const searchXiaohongshuTopicList = async (_task, params)=>{
2049
2039
  const http = new Http({
2050
2040
  headers: {
@@ -2072,9 +2062,9 @@ var __webpack_exports__ = {};
2072
2062
  page: 1
2073
2063
  }
2074
2064
  };
2075
- const topicDataStr = searchXiaohongshuTopicList_xsEncrypt.dumps(topicData);
2065
+ const topicDataStr = xsEncrypt.dumps(topicData);
2076
2066
  const fatchTopic = `/web_api/sns/v1/search/topic${topicDataStr}`;
2077
- const xs = await searchXiaohongshuTopicList_xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
2067
+ const xs = await xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
2078
2068
  const result = await http.api({
2079
2069
  method: "post",
2080
2070
  url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
@@ -2624,770 +2614,6 @@ var __webpack_exports__ = {};
2624
2614
  }, "获取粉丝数失败,请检查登陆有效性!");
2625
2615
  }
2626
2616
  };
2627
- const TTSessionCheck = async (_task, params)=>{
2628
- const http = new Http({
2629
- headers: {
2630
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2631
- referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
2632
- }
2633
- });
2634
- try {
2635
- const res = await http.api({
2636
- method: "get",
2637
- url: "https://mp.toutiao.com/mp/agw/creator_center/user_info",
2638
- defaultErrorMsg: `头条号登录状态失效。`
2639
- });
2640
- return (0, share_namespaceObject.success)(0 === res.code ? {
2641
- isValidSession: true
2642
- } : {
2643
- isValidSession: false
2644
- }, "头条账号有效性检测完成!");
2645
- } catch (error) {
2646
- return (0, share_namespaceObject.success)({
2647
- isValidSession: false
2648
- }, "头条账号有效性检测失败!");
2649
- }
2650
- };
2651
- const WxSessionCheck = async (_task, params)=>{
2652
- const http = new Http({
2653
- headers: {
2654
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2655
- }
2656
- });
2657
- const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
2658
- try {
2659
- const res = await http.api({
2660
- method: "get",
2661
- url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",
2662
- params: {
2663
- fingerprint,
2664
- sub: "list",
2665
- begin: 0,
2666
- count: 10,
2667
- query: "",
2668
- type: 1011102103,
2669
- show_type: "",
2670
- free_publish_type: 1102103,
2671
- sub_action: "list_ex",
2672
- search_card: 0,
2673
- token: params.token,
2674
- lang: "zh_CN",
2675
- f: "json",
2676
- ajax: 1
2677
- }
2678
- });
2679
- return (0, share_namespaceObject.success)(0 === res.base_resp.ret ? {
2680
- isValidSession: true
2681
- } : {
2682
- isValidSession: false
2683
- }, "微信账号有效性检测完成!");
2684
- } catch (error) {
2685
- return (0, share_namespaceObject.success)({
2686
- isValidSession: false
2687
- }, "微信账号有效性检测失败!");
2688
- }
2689
- };
2690
- const XhsSessionCheck = async (_task, params)=>{
2691
- const http = new Http({
2692
- headers: {
2693
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2694
- referer: "https://creator.xiaohongshu.com/new/home?source=official"
2695
- }
2696
- });
2697
- try {
2698
- const res = await http.api({
2699
- method: "get",
2700
- url: "https://creator.xiaohongshu.com/api/galaxy/user/info"
2701
- });
2702
- return (0, share_namespaceObject.success)(0 === res.result ? {
2703
- isValidSession: true
2704
- } : {
2705
- isValidSession: false
2706
- }, "小红书账号有效性检测完成!");
2707
- } catch (error) {
2708
- return (0, share_namespaceObject.success)({
2709
- isValidSession: false
2710
- }, "小红书账号有效性检测完成!");
2711
- }
2712
- };
2713
- const BjhSessionCheck = async (_task, params)=>{
2714
- const http = new Http({
2715
- headers: {
2716
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2717
- referer: "https://baijiahao.baidu.com/builder/rc/home"
2718
- }
2719
- });
2720
- try {
2721
- const res = await http.api({
2722
- method: "get",
2723
- url: "https://baijiahao.baidu.com/pcui/home/index",
2724
- defaultErrorMsg: `百家号登录状态失效。`
2725
- });
2726
- return (0, share_namespaceObject.success)(0 === res.errno ? {
2727
- isValidSession: true
2728
- } : {
2729
- isValidSession: false
2730
- }, "百家号账号有效性检测完成!");
2731
- } catch (error) {
2732
- return (0, share_namespaceObject.success)({
2733
- isValidSession: false
2734
- }, "百家号账号有效性检测失败!");
2735
- }
2736
- };
2737
- const types_errorResponse = (message, code = 500)=>({
2738
- code,
2739
- message,
2740
- data: null
2741
- });
2742
- async function getBaijiahaoData(params) {
2743
- try {
2744
- const { token } = params;
2745
- if (!token) return types_errorResponse("缺少token", 200);
2746
- const http = new Http({
2747
- headers: {
2748
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2749
- token: String(token),
2750
- Referer: "https://baijiahao.baidu.com/builder/rc/home"
2751
- }
2752
- });
2753
- const yesterday = TimeFormatter.format(new Date().setDate(new Date().getDate() - 1), "yyyyMMdd");
2754
- const [fansData, readData, incomeData, yesterdayData] = await Promise.all([
2755
- http.api({
2756
- method: "get",
2757
- url: "https://baijiahao.baidu.com/pcui/home/index"
2758
- }),
2759
- http.api({
2760
- method: "get",
2761
- url: "https://baijiahao.baidu.com/author/eco/statistic/getauthorhistory"
2762
- }),
2763
- http.api({
2764
- method: "get",
2765
- url: "https://baijiahao.baidu.com/author/eco/income4/homepageincome"
2766
- }),
2767
- http.api({
2768
- method: "get",
2769
- url: "https://baijiahao.baidu.com/author/eco/statistics/appStatistic",
2770
- params: {
2771
- type: "all",
2772
- is_yesterday: false,
2773
- start_day: yesterday,
2774
- end_day: yesterday,
2775
- stat: 0
2776
- }
2777
- })
2778
- ]);
2779
- const bjhData = {
2780
- fansNum: fansData.data.coreData.fansCount,
2781
- fansNumYesterday: -1 == yesterdayData.data.data.fans_increase ? null : yesterdayData.data.data.fans_increase,
2782
- readNum: readData.data.total.view_count,
2783
- incomeNum: incomeData.data.all_income.total_income,
2784
- incomeNumYesterday: -1 == incomeData.data.all_income.yesterday_income ? null : incomeData.data.all_income.yesterday_income,
2785
- recommendNumYesterday: -1 == yesterdayData.data.data.recommend_count ? null : yesterdayData.data.data.recommend_count,
2786
- readNumYesterday: -1 == yesterdayData.data.data.view_count ? null : yesterdayData.data.data.view_count,
2787
- likeNumYesterday: -1 == yesterdayData.data.data.likes_count ? null : yesterdayData.data.data.likes_count,
2788
- commentNumYesterday: -1 == yesterdayData.data.data.comment_count ? null : yesterdayData.data.data.comment_count
2789
- };
2790
- return (0, share_namespaceObject.success)(bjhData, "百家号平台数据获取成功!");
2791
- } catch (error) {
2792
- return types_errorResponse(error instanceof Error ? error.message : "百家号平台数据获取失败");
2793
- }
2794
- }
2795
- async function getToutiaoData(params) {
2796
- const { cookies } = params;
2797
- try {
2798
- const http = new Http({
2799
- headers: {
2800
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2801
- referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
2802
- }
2803
- });
2804
- const [totalData, contentDataYesterday] = await Promise.all([
2805
- http.api({
2806
- method: "get",
2807
- url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
2808
- params: {
2809
- app_id: 1231
2810
- }
2811
- }),
2812
- http.api({
2813
- method: "get",
2814
- url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
2815
- params: {
2816
- type: 0,
2817
- app_id: 1231
2818
- }
2819
- })
2820
- ]);
2821
- const isReday = void 0 !== totalData.data.statistic.data.yesterday_read_count;
2822
- const ttData = {
2823
- fansNum: Number(totalData.data.statistic.data.total_subscribe_count),
2824
- fansNumYesterday: void 0 !== totalData.data.statistic.data.yesterday_fans ? Number(totalData.data.statistic.data.yesterday_fans) : null,
2825
- readNum: Number(totalData.data.statistic.data.total_read_play_count),
2826
- incomeNum: totalData.data.statistic.data.total_income,
2827
- incomeNumYesterday: totalData.data.statistic.data.is_yesterday_income_ready ? totalData.data.statistic.data.yesterday_income : null,
2828
- showNumYesterday: isReday ? contentDataYesterday.author_stat.consume_data.impression_count : null,
2829
- readNumYesterday: isReday ? contentDataYesterday.author_stat.consume_data.go_detail_count : null,
2830
- likeNumYesterday: isReday ? contentDataYesterday.author_stat.interaction_data.digg_count : null,
2831
- commentNumYesterday: isReday ? contentDataYesterday.author_stat.interaction_data.comment_count : null
2832
- };
2833
- return (0, share_namespaceObject.success)(ttData, "头条号粉丝数据获取成功!");
2834
- } catch (error) {
2835
- return types_errorResponse(error instanceof Error ? error.message : "头条号数据获取失败");
2836
- }
2837
- }
2838
- async function getWeixinData(params) {
2839
- const { token } = params;
2840
- if (!token) return {
2841
- code: 200,
2842
- message: "缺少token",
2843
- data: null
2844
- };
2845
- try {
2846
- const { token } = params;
2847
- if (!token) return types_errorResponse("缺少token", 200);
2848
- const http = new Http({
2849
- headers: {
2850
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2851
- }
2852
- });
2853
- const userInfo = {
2854
- originalCount: 0,
2855
- totalUsers: 0,
2856
- userIncrease: 0,
2857
- yesterday: {
2858
- read: 0,
2859
- share: 0,
2860
- subscribe: 0
2861
- }
2862
- };
2863
- const userInfoHtml = await http.api({
2864
- method: "get",
2865
- url: "https://mp.weixin.qq.com/cgi-bin/home",
2866
- params: {
2867
- t: "home/index",
2868
- token,
2869
- lang: "zh_CN"
2870
- }
2871
- });
2872
- const originalMatch = userInfoHtml.trim().match(/原创内容[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2873
- if (originalMatch) userInfo.originalCount = parseInt(originalMatch[1].replace(/,/g, ''), 10);
2874
- const totalUsersMatch = userInfoHtml.match(/总用户数[\s\S]*?<div[^>]*class=["']weui-desktop-user_sum["'][^>]*>[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2875
- if (totalUsersMatch) userInfo.totalUsers = parseInt(totalUsersMatch[1].replace(/,/g, ''), 10);
2876
- const increaseMatch = userInfoHtml.match(/weui-desktop-user_increase_num[^>]*>\s*([+-]?)\s*<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2877
- if (increaseMatch) {
2878
- const sign = '-' === increaseMatch[1] ? -1 : 1;
2879
- userInfo.userIncrease = sign * parseInt(increaseMatch[2].replace(/,/g, ''), 10);
2880
- }
2881
- const readMatch = userInfoHtml.match(/昨日阅读[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2882
- if (readMatch) userInfo.yesterday.read = parseInt(readMatch[1].replace(/,/g, ''), 10);
2883
- const shareMatch = userInfoHtml.match(/昨日分享[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2884
- if (shareMatch) userInfo.yesterday.share = parseInt(shareMatch[1].replace(/,/g, ''), 10);
2885
- const subscribeMatch = userInfoHtml.match(/昨日新增关注[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2886
- if (subscribeMatch) userInfo.yesterday.subscribe = parseInt(subscribeMatch[1].replace(/,/g, ''), 10);
2887
- const wxData = {
2888
- fansNum: userInfo.totalUsers,
2889
- fansNumYesterday: userInfo.yesterday.subscribe,
2890
- readNumYesterday: userInfo.yesterday.read,
2891
- shareNumYesterday: userInfo.yesterday.share
2892
- };
2893
- return (0, share_namespaceObject.success)(wxData, "微信平台数据获取成功!");
2894
- } catch (error) {
2895
- return types_errorResponse(error instanceof Error ? error.message : "微信平台数据获取失败");
2896
- }
2897
- }
2898
- async function getXiaohongshuData(params) {
2899
- try {
2900
- const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
2901
- if (!a1Cookie) return types_errorResponse("账号数据异常,请重新绑定账号后重试。", 200);
2902
- const http = new Http({
2903
- headers: {
2904
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2905
- referer: "https://creator.xiaohongshu.com",
2906
- origin: "https://creator.xiaohongshu.com"
2907
- }
2908
- });
2909
- const xsEncrypt = new XsEncrypt();
2910
- const xt = Date.now().toString();
2911
- const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
2912
- const xs = await xsEncrypt.encryptXs(sevenDataUrl, a1Cookie, xt);
2913
- const [overAllData, sevenData] = await Promise.all([
2914
- http.api({
2915
- method: "get",
2916
- url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
2917
- }),
2918
- http.api({
2919
- method: "get",
2920
- baseURL: "https://creator.xiaohongshu.com",
2921
- url: sevenDataUrl,
2922
- headers: {
2923
- "x-s": xs,
2924
- "x-t": xt
2925
- }
2926
- })
2927
- ]);
2928
- const xhsData = {
2929
- fansNum: overAllData.data.fans_count,
2930
- favedNum: overAllData.data.faved_count,
2931
- watchNumLastWeek: sevenData.data.seven.view_count,
2932
- likeNumLastWeek: sevenData.data.seven.like_count,
2933
- collectNumLastWeek: sevenData.data.seven.collect_count,
2934
- commentNumLastWeek: sevenData.data.seven.comment_count,
2935
- fansNumLastWeek: sevenData.data.seven.rise_fans_count,
2936
- fansNumYesterday: sevenData.data.seven.rise_fans_list[0].count
2937
- };
2938
- return (0, share_namespaceObject.success)(xhsData, "小红书平台数据获取成功!");
2939
- } catch (error) {
2940
- return types_errorResponse(error instanceof Error ? error.message : "小红书平台数据获取失败");
2941
- }
2942
- }
2943
- const SearchAccountInfo = async (_task, params)=>{
2944
- const { platform } = params;
2945
- switch(platform){
2946
- case "toutiao":
2947
- return getToutiaoData(params);
2948
- case "xiaohongshu":
2949
- return getXiaohongshuData(params);
2950
- case "weixin":
2951
- return getWeixinData(params);
2952
- case "baijiahao":
2953
- return getBaijiahaoData(params);
2954
- default:
2955
- return (0, share_namespaceObject.success)(null, "暂不支持该平台");
2956
- }
2957
- };
2958
- const searchPublishInfo_types_errorResponse = (message, code = 500)=>({
2959
- code,
2960
- message,
2961
- data: null
2962
- });
2963
- async function handleToutiaoData(params) {
2964
- try {
2965
- const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
2966
- const http = new Http({
2967
- headers: {
2968
- cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2969
- }
2970
- });
2971
- const visitedUid = await http.api({
2972
- url: "https://mp.toutiao.com/mp/agw/creator_center/user_info?",
2973
- method: "get",
2974
- params: {
2975
- app_id: 1231
2976
- }
2977
- });
2978
- const articleInfo = await http.api({
2979
- method: "get",
2980
- url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
2981
- params: {
2982
- provider_type: "mp_provider",
2983
- aid: "13",
2984
- app_name: "news_article",
2985
- category: "mp_all",
2986
- channel: "",
2987
- stream_api_version: "88",
2988
- genre_type_switch: '{"repost":1,"small_video":1,"toutiao_graphic":1,"weitoutiao":1,"xigua_video":1}',
2989
- device_platform: "pc",
2990
- platform_id: "0",
2991
- visited_uid: visitedUid.user_id_str,
2992
- offset: (pageNum - 1) * pageSize,
2993
- count: pageSize,
2994
- keyword: "",
2995
- client_extra_params: `{"category":"mp_all","real_app_id":"1231","need_forward":"true","offset_mode":"1","page_index":"1","status":${onlySuccess ? "2" : "8"},"source":"0"}`,
2996
- app_id: "1231"
2997
- }
2998
- });
2999
- const articleCell = articleInfo.data.map((item)=>({
3000
- title: item.assembleCell.itemCell.articleBase.title,
3001
- imageUrl: item.assembleCell.itemCell.imageList.staggerFeedCover[0].url,
3002
- createTime: item.assembleCell.itemCell.articleBase.publishTime,
3003
- redirectUrl: item.assembleCell.itemCell.articleBase.articleURL,
3004
- showNum: item.assembleCell.itemCell.itemCounter.showCount,
3005
- readNum: item.assembleCell.itemCell.itemCounter.readCount,
3006
- likeNum: item.assembleCell.itemCell.itemCounter.diggCount,
3007
- commentNum: item.assembleCell.itemCell.itemCounter.commentCount,
3008
- ...showOriginalData ? {
3009
- originalData: item
3010
- } : {}
3011
- }));
3012
- const api_base_info_json = JSON.parse(articleInfo.api_base_info.app_extra_params);
3013
- return (0, share_namespaceObject.success)({
3014
- articleCell,
3015
- ...onlySuccess ? {
3016
- pagination: {
3017
- total: api_base_info_json.total_count || -1,
3018
- pageNum,
3019
- pageSize
3020
- }
3021
- } : null
3022
- }, "头条号文章文章获取成功");
3023
- } catch (error) {
3024
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "头条号文章数据获取失败");
3025
- }
3026
- }
3027
- async function handleWeixinData(params) {
3028
- try {
3029
- const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false, cursor, lastPage } = params;
3030
- if (!token) return {
3031
- code: 200,
3032
- message: "缺少token",
3033
- data: null
3034
- };
3035
- const http = new Http({
3036
- headers: {
3037
- cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
3038
- }
3039
- });
3040
- const ParsePublishPage = (body)=>{
3041
- const match = body.match(/publish_page\s*=\s*({[\s\S]*?});/);
3042
- if (!match) throw new Error('无法提取 publish_page 字段');
3043
- let parsedData = JSON.parse(match[1]);
3044
- const decodeEntities = function(str, decode = false) {
3045
- const encodeMap = [
3046
- "&",
3047
- "&amp;",
3048
- "<",
3049
- "&lt;",
3050
- ">",
3051
- "&gt;",
3052
- " ",
3053
- "&nbsp;",
3054
- '"',
3055
- "&quot;",
3056
- "'",
3057
- "&#39;"
3058
- ];
3059
- const decodeMap = [
3060
- "&#39;",
3061
- "'",
3062
- "&quot;",
3063
- '"',
3064
- "&nbsp;",
3065
- " ",
3066
- "&gt;",
3067
- ">",
3068
- "&lt;",
3069
- "<",
3070
- "&amp;",
3071
- "&",
3072
- "&#60;",
3073
- "<",
3074
- "&#62;",
3075
- ">"
3076
- ];
3077
- const map = decode ? decodeMap : encodeMap;
3078
- let result = str;
3079
- for(let i = 0; i < map.length; i += 2)result = result.replace(new RegExp(map[i], "g"), map[i + 1]);
3080
- return result;
3081
- };
3082
- const finalData = {
3083
- ...parsedData,
3084
- publish_list: parsedData.publish_list.map((item)=>{
3085
- const decoded = decodeEntities(item.publish_info, true);
3086
- const parsedInfo = JSON.parse(decoded);
3087
- return {
3088
- publish_type: item.publish_type,
3089
- publish_info: parsedInfo
3090
- };
3091
- })
3092
- };
3093
- return finalData;
3094
- };
3095
- async function fetchArticles(begin, pageSize, token) {
3096
- return http.api({
3097
- method: "get",
3098
- url: 'https://mp.weixin.qq.com/cgi-bin/appmsgpublish',
3099
- params: {
3100
- sub: "list",
3101
- begin: begin,
3102
- count: pageSize,
3103
- token: token,
3104
- lang: "zh_CN"
3105
- }
3106
- });
3107
- }
3108
- let size = onlySuccess ? 10 : pageSize > 20 ? 20 : pageSize;
3109
- let begin = (lastPage ?? pageNum) - 1;
3110
- let rawArticlesInfo = await fetchArticles(begin * size, size, token);
3111
- let articlesInfo = ParsePublishPage(rawArticlesInfo);
3112
- let articleCell = [];
3113
- if (!onlySuccess && pageSize > 20) {
3114
- let totalFetched = articlesInfo.publish_list.length;
3115
- let nextPage = pageNum + 1;
3116
- while(totalFetched < pageSize){
3117
- const remaining = pageSize - totalFetched;
3118
- const currentPageSize = remaining > 20 ? 20 : remaining;
3119
- let _rawArticlesInfo = await fetchArticles((nextPage - 1) * 20, currentPageSize, token);
3120
- let parsed = ParsePublishPage(_rawArticlesInfo);
3121
- articlesInfo.publish_list = articlesInfo.publish_list.concat(parsed.publish_list);
3122
- totalFetched = articlesInfo.publish_list.length;
3123
- if (parsed.publish_list.length < currentPageSize) break;
3124
- nextPage++;
3125
- }
3126
- articleCell = articlesInfo.publish_list.map((item)=>({
3127
- title: item.publish_info.appmsg_info[0].title,
3128
- imageUrl: item.publish_info.appmsg_info[0].cover,
3129
- createTime: item.publish_info.appmsg_info[0].line_info.send_time,
3130
- redirectUrl: item.publish_info.appmsg_info[0].content_url,
3131
- readNum: item.publish_info.appmsg_info[0].read_num,
3132
- likeNum: item.publish_info.appmsg_info[0].old_like_num,
3133
- shareNum: item.publish_info.appmsg_info[0].share_num,
3134
- recommendNum: item.publish_info.appmsg_info[0].like_num,
3135
- ...showOriginalData ? {
3136
- originalData: item
3137
- } : {}
3138
- }));
3139
- }
3140
- let nextPage = false;
3141
- if (onlySuccess) {
3142
- let filteredList = articlesInfo.publish_list.filter((item)=>-1 == item.publish_info.appmsg_info[0].content_url.indexOf("tempkey")).map((item)=>item.publish_info);
3143
- if (cursor) {
3144
- const cursorIndex = filteredList.findIndex((item)=>item.msgid === cursor);
3145
- if (-1 !== cursorIndex) filteredList = filteredList.slice(cursorIndex + 1);
3146
- }
3147
- let totalFetched = filteredList.length;
3148
- while(totalFetched < pageSize && begin * size < articlesInfo.total_count){
3149
- begin += 1;
3150
- let nextRawArticlesInfo = await fetchArticles(begin * size, size, token);
3151
- let nextArticlesInfo = ParsePublishPage(nextRawArticlesInfo);
3152
- const newFiltered = nextArticlesInfo.publish_list.filter((item)=>-1 == item.publish_info.appmsg_info[0].content_url.indexOf("tempkey")).map((item)=>item.publish_info);
3153
- filteredList = filteredList.concat(newFiltered);
3154
- totalFetched = filteredList.length;
3155
- }
3156
- filteredList = filteredList.slice(0, pageSize);
3157
- totalFetched = filteredList.length;
3158
- if (totalFetched >= pageSize && begin * size < articlesInfo.total_count) {
3159
- let nextRawArticlesInfo = await fetchArticles((begin + 1) * size, size, token);
3160
- let nextArticlesInfo = ParsePublishPage(nextRawArticlesInfo);
3161
- nextPage = nextArticlesInfo.publish_list.length > 0 && nextArticlesInfo.publish_list.some((item)=>-1 == item.publish_info.appmsg_info[0].content_url.indexOf("tempkey"));
3162
- }
3163
- const lastMsgId = filteredList.length > 0 ? filteredList[filteredList.length - 1].msgid : void 0;
3164
- articleCell = filteredList.map((item)=>({
3165
- title: item.appmsg_info[0].title,
3166
- imageUrl: item.appmsg_info[0].cover,
3167
- createTime: item.appmsg_info[0].line_info.send_time,
3168
- redirectUrl: item.appmsg_info[0].content_url,
3169
- readNum: item.appmsg_info[0].read_num,
3170
- likeNum: item.appmsg_info[0].old_like_num,
3171
- shareNum: item.appmsg_info[0].share_num,
3172
- recommendNum: item.appmsg_info[0].like_num,
3173
- ...showOriginalData ? {
3174
- originalData: item
3175
- } : {}
3176
- }));
3177
- return (0, share_namespaceObject.success)({
3178
- articleCell,
3179
- pagination: {
3180
- nextPage,
3181
- pageNum,
3182
- pageSize,
3183
- lastPage: begin + 1,
3184
- cursor: lastMsgId
3185
- }
3186
- }, "微信文章文章获取成功");
3187
- }
3188
- return (0, share_namespaceObject.success)({
3189
- articleCell
3190
- }, "微信文章文章获取成功");
3191
- } catch (error) {
3192
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "微信文章数据获取失败");
3193
- }
3194
- }
3195
- async function handleBaijiahaoData(params) {
3196
- try {
3197
- const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3198
- if (!token) return {
3199
- code: 200,
3200
- message: "缺少token",
3201
- data: null
3202
- };
3203
- const http = new Http({
3204
- headers: {
3205
- cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3206
- token: token
3207
- }
3208
- });
3209
- async function fetchArticles(pageNum, pageSize, onlySuccess = false) {
3210
- return await http.api({
3211
- method: "get",
3212
- url: "https://baijiahao.baidu.com/pcui/article/lists",
3213
- params: {
3214
- currentPage: pageNum,
3215
- pageSize: pageSize,
3216
- search: "",
3217
- type: "",
3218
- collection: onlySuccess ? "publish" : "",
3219
- clearBeforeFetch: false,
3220
- dynamic: 1
3221
- }
3222
- });
3223
- }
3224
- const articleInfo = await fetchArticles(pageNum, pageSize, onlySuccess);
3225
- let filtered = articleInfo.data.list.filter((item)=>"draft" !== item.status);
3226
- const totalPage = articleInfo.data.page?.totalPage || 1;
3227
- let currentPage = pageNum + 1;
3228
- const usedPages = new Set();
3229
- while(filtered.length < pageSize && currentPage <= totalPage){
3230
- if (usedPages.has(currentPage)) {
3231
- currentPage++;
3232
- continue;
3233
- }
3234
- const res = await fetchArticles(currentPage, pageSize, onlySuccess);
3235
- usedPages.add(currentPage);
3236
- const validItems = res.data.list.filter((item)=>"draft" !== item.status);
3237
- filtered.push(...validItems);
3238
- currentPage++;
3239
- }
3240
- const final = filtered.slice(0, pageSize);
3241
- const articleCell = final.map((item)=>({
3242
- title: item.title,
3243
- imageUrl: JSON.parse(item.cover_images)[0].src,
3244
- createTime: Math.floor(new Date(item.publish_at.replace(/-/g, "/")).getTime() / 1000),
3245
- redirectUrl: item.url,
3246
- recommendNum: item.rec_amount | item.forward_num,
3247
- collectNum: item.collection_amount,
3248
- readNum: item.read_amount | item.read_num,
3249
- likeNum: item.like_amount | item.praise_num,
3250
- commentNum: item.comment_amount | item.comment_num,
3251
- shareNum: item.share_amount,
3252
- ...showOriginalData ? {
3253
- originalData: item
3254
- } : {}
3255
- }));
3256
- return (0, share_namespaceObject.success)({
3257
- articleCell,
3258
- ...onlySuccess ? {
3259
- pagination: {
3260
- total: articleInfo.data.page?.totalCount,
3261
- pageNum,
3262
- pageSize
3263
- }
3264
- } : null
3265
- }, "百家号文章数据获取成功");
3266
- } catch (error) {
3267
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
3268
- }
3269
- }
3270
- async function handleXiaohongshuData(params) {
3271
- try {
3272
- const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3273
- const xsEncrypt = new XsEncrypt();
3274
- const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
3275
- if (!a1Cookie) return {
3276
- code: 200,
3277
- message: "账号数据异常",
3278
- data: null
3279
- };
3280
- if (onlySuccess && 10 != pageSize) return {
3281
- code: 200,
3282
- message: "小红书pageSize不可修改",
3283
- data: null
3284
- };
3285
- const http = new Http({
3286
- headers: {
3287
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3288
- referer: "https://creator.xiaohongshu.com",
3289
- origin: "https://creator.xiaohongshu.com"
3290
- }
3291
- });
3292
- async function fetchArticles(pageNum, a1Cookie, onlySuccess = false) {
3293
- const xt = Date.now().toString();
3294
- const serveUrl = `/web_api/sns/v5/creator/note/user/posted?tab=${onlySuccess ? 1 : 0}&page=${pageNum - 1}`;
3295
- const xs = await xsEncrypt.encryptXs(serveUrl, a1Cookie, xt);
3296
- return await http.api({
3297
- method: "get",
3298
- baseURL: "https://edith.xiaohongshu.com",
3299
- url: serveUrl,
3300
- headers: {
3301
- "x-s": xs,
3302
- "x-t": xt
3303
- }
3304
- });
3305
- }
3306
- const articleInfo = await fetchArticles(pageNum, a1Cookie, onlySuccess);
3307
- let hasNextpage = -1 != articleInfo.data.page;
3308
- let filtered = articleInfo.data.notes;
3309
- let currentPage = pageNum + 1;
3310
- const usedPages = new Set();
3311
- while(filtered.length < pageSize && hasNextpage){
3312
- if (usedPages.has(currentPage)) {
3313
- currentPage++;
3314
- continue;
3315
- }
3316
- const res = await fetchArticles(currentPage, a1Cookie, onlySuccess);
3317
- usedPages.add(currentPage);
3318
- const validItems = res.data.notes;
3319
- filtered.push(...validItems);
3320
- currentPage++;
3321
- hasNextpage = -1 != res.data.page;
3322
- }
3323
- const final = filtered.slice(0, pageSize);
3324
- const articleCell = final.map((item)=>({
3325
- title: item.display_title,
3326
- imageUrl: item.images_list[0].url,
3327
- createTime: Math.floor(new Date(item.time.replace(/-/g, "/")).getTime() / 1000),
3328
- redirectUrl: `https://www.xiaohongshu.com/explore/${item.id}?xsec_token=${item.xsec_token}&xsec_source=pc_creatormng`,
3329
- readNum: item.view_count,
3330
- likeNum: item.likes,
3331
- commentNum: item.comments_count,
3332
- collectNum: item.collected_count,
3333
- shareNum: item.shared_count,
3334
- ...showOriginalData ? {
3335
- originalData: item
3336
- } : {}
3337
- }));
3338
- return (0, share_namespaceObject.success)({
3339
- articleCell,
3340
- ...onlySuccess ? {
3341
- pagination: {
3342
- nextPage: hasNextpage,
3343
- pageNum,
3344
- pageSize
3345
- }
3346
- } : null
3347
- }, "小红书文章数据获取成功");
3348
- } catch (error) {
3349
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "小红书文章数据获取失败");
3350
- }
3351
- }
3352
- const FetchArticles = async (_task, params)=>{
3353
- const { platform } = params;
3354
- switch(platform){
3355
- case "toutiao":
3356
- return handleToutiaoData(params);
3357
- case "weixin":
3358
- return handleWeixinData(params);
3359
- case "baijiahao":
3360
- return handleBaijiahaoData(params);
3361
- case "xiaohongshu":
3362
- return handleXiaohongshuData(params);
3363
- default:
3364
- return (0, share_namespaceObject.success)(null, "暂不支持该平台");
3365
- }
3366
- };
3367
- const getWeixinConfig = async (_task, params)=>{
3368
- const http = new Http({
3369
- headers: {
3370
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
3371
- }
3372
- });
3373
- const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
3374
- const res = await http.api({
3375
- method: "get",
3376
- url: "https://mp.weixin.qq.com/cgi-bin/masssendpage",
3377
- params: {
3378
- f: 'json',
3379
- token: params.token,
3380
- lang: 'zh_CN',
3381
- ajax: 1,
3382
- fingerprint: fingerprint,
3383
- random: Math.random().toString()
3384
- }
3385
- });
3386
- const filtered = {
3387
- publishQuota: 0 === res.base_resp.ret ? res.quota_detail_list.filter((item)=>"kQuotaTypeMassSendNormal" === item.quota_type).map((item)=>item.quota_item_list) : []
3388
- };
3389
- return (0, share_namespaceObject.success)(filtered, 0 === res.base_resp.ret ? "微信配置信息获取成功!" : "微信配置信息获取失败!");
3390
- };
3391
2617
  const weitoutiaoPublish_mock_mockAction = async (task, params)=>{
3392
2618
  const tmpCachePath = task.getTmpPath();
3393
2619
  const http = new Http({
@@ -4958,33 +4184,40 @@ var __webpack_exports__ = {};
4958
4184
  }
4959
4185
  });
4960
4186
  let uploadInfos = [];
4961
- coverIdInfo.data.uploadTempPermits.map((item)=>{
4962
- uploadInfos.push({
4963
- bucket: "",
4964
- uploadAddr: item.uploadAddr,
4965
- fileIds: item.fileIds,
4966
- token: item.token
4187
+ coverIdInfo.data.uploadTempPermits.forEach((item)=>{
4188
+ item.fileIds.forEach((fileId)=>{
4189
+ uploadInfos.push({
4190
+ bucket: item.bucket || "",
4191
+ uploadAddr: item.uploadAddr || "",
4192
+ fileIds: fileId,
4193
+ token: item.token || ""
4194
+ });
4967
4195
  });
4968
4196
  });
4197
+ if (uploadInfos.length < params.banners.length) return {
4198
+ code: 200,
4199
+ message: "可用 OSS bucket 数量不足,无法上传所有图片!",
4200
+ data: ""
4201
+ };
4969
4202
  if (0 === uploadInfos.length) return {
4970
4203
  code: 200,
4971
4204
  message: "图片上传失败,请稍后重试!",
4972
4205
  data: ""
4973
4206
  };
4974
- const uploadFile = async (url, index, infoIndex = 0)=>{
4207
+ const availableBuckets = Array.from({
4208
+ length: uploadInfos.length
4209
+ }, (_, i)=>i);
4210
+ const uploadFile = async (url, index)=>{
4975
4211
  const fileName = (0, share_namespaceObject.getFilenameFromUrl)(url);
4976
4212
  const localUrl = await (0, share_namespaceObject.downloadImage)(url, external_node_path_default().join(tmpCachePath, fileName));
4977
4213
  const fileBuffer = external_node_fs_default().readFileSync(localUrl);
4978
- const tryUpload = async (uploadIndex)=>{
4979
- if (uploadIndex >= uploadInfos.length) {
4980
- external_node_fs_default().unlinkSync(localUrl);
4981
- return {
4982
- ossFileId: "",
4983
- ossToken: ""
4984
- };
4985
- }
4986
- const currentInfo = uploadInfos[uploadIndex];
4987
- const ossFileId = currentInfo.fileIds[0];
4214
+ const MAX_RETRIES = uploadInfos.length;
4215
+ let attempt = 0;
4216
+ while(attempt < MAX_RETRIES){
4217
+ const ossBucketIndex = availableBuckets.shift();
4218
+ if (void 0 === ossBucketIndex) break;
4219
+ const currentInfo = uploadInfos[ossBucketIndex];
4220
+ const ossFileId = currentInfo.fileIds;
4988
4221
  const ossToken = currentInfo.token;
4989
4222
  const ossDomain = currentInfo.uploadAddr;
4990
4223
  try {
@@ -5002,10 +4235,13 @@ var __webpack_exports__ = {};
5002
4235
  ossToken
5003
4236
  };
5004
4237
  } catch (error) {
5005
- return tryUpload(uploadIndex + 1);
4238
+ attempt++;
5006
4239
  }
4240
+ }
4241
+ return {
4242
+ ossFileId: "",
4243
+ ossToken: ""
5007
4244
  };
5008
- return tryUpload(infoIndex);
5009
4245
  };
5010
4246
  const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
5011
4247
  const invalidUpload = coverInfos.find((it)=>"" === it.ossToken || "" == it.ossFileId);
@@ -5350,7 +4586,9 @@ var __webpack_exports__ = {};
5350
4586
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
5351
4587
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
5352
4588
  };
5353
- var package_namespaceObject = JSON.parse('{"i8":"1.2.16-beta.3"}');
4589
+ var package_namespaceObject = {
4590
+ i8: "1.2.15"
4591
+ };
5354
4592
  class Action {
5355
4593
  constructor(task){
5356
4594
  this.task = task;
@@ -5371,24 +4609,6 @@ var __webpack_exports__ = {};
5371
4609
  } else this.task.logger.info(`${func.name} action success`);
5372
4610
  return responseData;
5373
4611
  }
5374
- FetchArticles(params) {
5375
- return this.bindTask(FetchArticles, params);
5376
- }
5377
- SearchAccountInfo(params) {
5378
- return this.bindTask(SearchAccountInfo, params);
5379
- }
5380
- TTSessionCheck(params) {
5381
- return this.bindTask(TTSessionCheck, params);
5382
- }
5383
- WxSessionCheck(params) {
5384
- return this.bindTask(WxSessionCheck, params);
5385
- }
5386
- XhsSessionCheck(params) {
5387
- return this.bindTask(XhsSessionCheck, params);
5388
- }
5389
- BjhSessionCheck(params) {
5390
- return this.bindTask(BjhSessionCheck, params);
5391
- }
5392
4612
  searchToutiaoTopicList(params) {
5393
4613
  return this.bindTask(searchToutiaoTopicList, params);
5394
4614
  }
@@ -5413,9 +4633,6 @@ var __webpack_exports__ = {};
5413
4633
  getToutiaoConfig(params) {
5414
4634
  return this.bindTask(getToutiaoConfig, params);
5415
4635
  }
5416
- getWeixinConfig(params) {
5417
- return this.bindTask(getWeixinConfig, params);
5418
- }
5419
4636
  getBaijiahaoConfig(params) {
5420
4637
  return this.bindTask(getBaijiahaoConfig, params);
5421
4638
  }