@ikenxuan/amagi 1.4.3

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.
Files changed (58) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +82 -0
  3. package/config/config.yaml +5 -0
  4. package/config/default_config.yaml +5 -0
  5. package/lib/app.d.ts +1 -0
  6. package/lib/app.js +2 -0
  7. package/lib/business/bilibili/API.d.ts +39 -0
  8. package/lib/business/bilibili/API.js +37 -0
  9. package/lib/business/bilibili/getdata.d.ts +9 -0
  10. package/lib/business/bilibili/getdata.js +169 -0
  11. package/lib/business/bilibili/getid.d.ts +26 -0
  12. package/lib/business/bilibili/getid.js +41 -0
  13. package/lib/business/bilibili/index.d.ts +7 -0
  14. package/lib/business/bilibili/index.js +7 -0
  15. package/lib/business/bilibili/qtparam.d.ts +13 -0
  16. package/lib/business/bilibili/qtparam.js +16 -0
  17. package/lib/business/bilibili/result.d.ts +6 -0
  18. package/lib/business/bilibili/result.js +36 -0
  19. package/lib/business/bilibili/sign/CorrespondPath.d.ts +1 -0
  20. package/lib/business/bilibili/sign/CorrespondPath.js +11 -0
  21. package/lib/business/bilibili/sign/wbi.d.ts +1 -0
  22. package/lib/business/bilibili/sign/wbi.js +56 -0
  23. package/lib/business/douyin/API.d.ts +37 -0
  24. package/lib/business/douyin/API.js +42 -0
  25. package/lib/business/douyin/getdata.d.ts +9 -0
  26. package/lib/business/douyin/getdata.js +119 -0
  27. package/lib/business/douyin/getid.d.ts +13 -0
  28. package/lib/business/douyin/getid.js +36 -0
  29. package/lib/business/douyin/index.d.ts +6 -0
  30. package/lib/business/douyin/index.js +6 -0
  31. package/lib/business/douyin/result.d.ts +6 -0
  32. package/lib/business/douyin/result.js +39 -0
  33. package/lib/business/douyin/sign/a_bougs.js +487 -0
  34. package/lib/business/douyin/sign/index.d.ts +8 -0
  35. package/lib/business/douyin/sign/index.js +29 -0
  36. package/lib/index.d.ts +30 -0
  37. package/lib/index.js +113 -0
  38. package/lib/model/config.d.ts +70 -0
  39. package/lib/model/config.js +173 -0
  40. package/lib/model/index.d.ts +4 -0
  41. package/lib/model/index.js +4 -0
  42. package/lib/model/logger.d.ts +3 -0
  43. package/lib/model/logger.js +28 -0
  44. package/lib/model/networks.d.ts +38 -0
  45. package/lib/model/networks.js +224 -0
  46. package/lib/types/ConfigType.d.ts +10 -0
  47. package/lib/types/ConfigType.js +1 -0
  48. package/lib/types/DataType.d.ts +32 -0
  49. package/lib/types/DataType.js +1 -0
  50. package/lib/types/GetDataResponseType.d.ts +17 -0
  51. package/lib/types/GetDataResponseType.js +1 -0
  52. package/lib/types/NetworksConfigType.d.ts +30 -0
  53. package/lib/types/NetworksConfigType.js +1 -0
  54. package/lib/types/OptionsType.d.ts +66 -0
  55. package/lib/types/OptionsType.js +1 -0
  56. package/lib/types/index.d.ts +6 -0
  57. package/lib/types/index.js +1 -0
  58. package/package.json +49 -0
@@ -0,0 +1,42 @@
1
+ // 未初始化,必须这么导入
2
+ import Sign from './sign/index.js';
3
+ const fp = Sign.VerifyFpManager();
4
+ class DouyinAPI {
5
+ 视频或图集(data) {
6
+ return `https://www.douyin.com/aweme/v1/web/aweme/detail/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=${data.aweme_id}&update_version_code=170400&pc_client_type=1&version_code=190500&version_name=19.5.0&cookie_enabled=true&screen_width=2328&screen_height=1310&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=150&webid=7351848354471872041&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
7
+ }
8
+ 评论(data) {
9
+ return `https://www.douyin.com/aweme/v1/web/comment/list/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=${data.aweme_id}&cursor=0&count=50&item_type=0&insert_ids=&whale_cut_token=&cut_version=1&rcFT=&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
10
+ }
11
+ 二级评论(data) {
12
+ return `https://www.douyin.com/aweme/v1/web/comment/list/reply/?device_platform=webapp&aid=6383&channel=channel_pc_web&item_id=${data.aweme_id}&comment_id=${data.comment_id}&cut_version=1&cursor=0&count=10&item_type=0&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=126.0.0.0&browser_online=true&engine_name=Blink&engine_version=126.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=0&webid=7326516708850599434&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
13
+ }
14
+ 动图(data) {
15
+ return `https://www.iesdouyin.com/web/api/v2/aweme/slidesinfo/?reflow_source=reflow_page&web_id=7326472315356857893&device_id=7326472315356857893&aweme_ids=[${data.aweme_id}]&request_source=200&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
16
+ }
17
+ 表情() {
18
+ return 'https://www.douyin.com/aweme/v1/web/emoji/list';
19
+ }
20
+ 用户主页视频(data) {
21
+ return `https://www.douyin.com/aweme/v1/web/aweme/post/?device_platform=webapp&aid=6383&channel=channel_pc_web&sec_user_id=${data.sec_uid}&max_cursor=0&locate_query=false&show_live_replay_strategy=1&need_time_list=1&time_list_query=0&whale_cut_token=&cut_version=1&count=18&publish_video_strategy_type=2&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7338423850134226495&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
22
+ }
23
+ 用户主页信息(data) {
24
+ return `https://www.douyin.com/aweme/v1/web/user/profile/other/?device_platform=webapp&aid=6383&channel=channel_pc_web&publish_video_strategy_type=2&source=channel_pc_web&sec_user_id=${data.sec_uid}&personal_center_strategy=1&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=0&webid=7327957959955580467&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
25
+ }
26
+ 热点词(data) {
27
+ return `https://www.douyin.com/aweme/v1/web/api/suggest_words/?device_platform=webapp&aid=6383&channel=channel_pc_web&query=${encodeURIComponent(data.query)}&business_id=30088&from_group_id=7129543174929812767&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh - CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7327957959955580467&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
28
+ }
29
+ 搜索(data) {
30
+ return `https://www.douyin.com/aweme/v1/web/general/search/single/?device_platform=webapp&aid=6383&channel=channel_pc_web&search_channel=aweme_general&sort_type=0&publish_time=0&keyword=${data.query}&search_source=normal_search&query_correct_type=1&is_filter_search=0&from_group_id=&offset=0&count=15&pc_client_type=1&version_code=190600&version_name=19.6.0&cookie_enabled=true&screen_width=1552&screen_height=970&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=125.0.0.0&browser_online=true&engine_name=Blink&engine_version=125.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50&webid=7338423850134226495&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
31
+ }
32
+ 互动表情() {
33
+ return `https://www.douyin.com/aweme/v1/web/im/strategy/config?device_platform=webapp&aid=1128&channel=channel_pc_web&publish_video_strategy_type=2&app_id=1128&scenes=[%22interactive_resources%22]&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=2328&screen_height=1310&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=126.0.0.0&browser_online=true&engine_name=Blink&engine_version=126.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=1.5&effective_type=4g&round_trip_time=350&webid=7347329698282833447&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
34
+ }
35
+ 背景音乐(data) {
36
+ return `https://www.douyin.com/aweme/v1/web/music/detail/?device_platform=webapp&aid=6383&channel=channel_pc_web&music_id=${data.music_id}&scene=1&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=2328&screen_height=1310&browser_language=zh-CN&browser_platform=Win32&browser_name=Chrome&browser_version=126.0.0.0&browser_online=true&engine_name=Blink&engine_version=126.0.0.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=8&platform=PC&downlink=1.5&effective_type=4g&round_trip_time=350&webid=7347329698282833447&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
37
+ }
38
+ 直播间信息(data) {
39
+ return `https://live.douyin.com/webcast/room/info_by_scene/?aid=6383&app_name=douyin_web&live_id=1&device_platform=web&language=zh-CN&cookie_enabled=true&screen_width=2328&screen_height=1310&browser_language=zh-CN&browser_platform=Win32&browser_name=Edge&browser_version=125.0.0.0&room_id=${data.room_id}&scene=aweme_video_feed_pc&channel=channel_pc_web&region=cn&device_id=7355205920467306010&device_type=web_device&os_version=web&version_code=170400&webcast_sdk_version=2450&msToken=${Sign.Mstoken(116)}&verifyFp=${fp}&fp=${fp}`;
40
+ }
41
+ }
42
+ export default new DouyinAPI();
@@ -0,0 +1,9 @@
1
+ import { DouyinDataType, DouyinOptionsType, NetworksConfigType } from '../../types/index.js';
2
+ export default class DouyinData {
3
+ type: DouyinDataType;
4
+ headers: any;
5
+ URL: string | undefined;
6
+ constructor(type: DouyinDataType);
7
+ GetData(data?: DouyinOptionsType): Promise<any>;
8
+ GlobalGetData(options: NetworksConfigType): Promise<any>;
9
+ }
@@ -0,0 +1,119 @@
1
+ import { Sign, DouyinAPI } from '../../business/douyin/index.js';
2
+ import { Networks, Config } from '../../model/index.js';
3
+ export default class DouyinData {
4
+ type;
5
+ headers;
6
+ URL;
7
+ constructor(type) {
8
+ this.type = type;
9
+ this.headers = {
10
+ Accept: 'application/json, text/plain, */*',
11
+ 'Accept-Encoding': 'gzip, deflate, br, zstd',
12
+ 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
13
+ Priority: 'u=1, i',
14
+ 'Sec-Ch-Ua': '"Not/A)Brand";v="8", "Chromium";v="125", "Microsoft Edge";v="125"',
15
+ 'Sec-Ch-Ua-Mobile': '?0',
16
+ 'Sec-Ch-Ua-Platform': '"Windows"',
17
+ 'Sec-Fetch-Dest': 'empty',
18
+ 'Sec-Fetch-Mode': 'cors',
19
+ 'Sec-Fetch-Site': 'same-site',
20
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36',
21
+ 'Content-Type': 'application/json',
22
+ Referer: 'https://www.douyin.com/?recommend=1',
23
+ Cookie: Config.douyin
24
+ };
25
+ }
26
+ async GetData(data = {}) {
27
+ switch (this.type) {
28
+ case 'VideoData':
29
+ case 'NoteData':
30
+ this.URL = DouyinAPI.视频或图集({ aweme_id: data.aweme_id });
31
+ const VideoData = await this.GlobalGetData({
32
+ url: `${this.URL}&a_bougs=${Sign.AB(this.URL)}`,
33
+ headers: this.headers,
34
+ });
35
+ return VideoData;
36
+ case 'CommentData':
37
+ this.URL = DouyinAPI.评论({ aweme_id: data.aweme_id });
38
+ const CommentsData = await this.GlobalGetData({
39
+ url: `${this.URL}&a_bougs=${Sign.AB(this.URL)}`,
40
+ headers: this.headers,
41
+ });
42
+ return CommentsData;
43
+ case 'CommentReplyData':
44
+ this.URL = DouyinAPI.二级评论({ aweme_id: data.aweme_id, comment_id: data.comment_id });
45
+ const CommentReplyData = await this.GlobalGetData({
46
+ url: `${this.URL}&a_bougs=${Sign.AB(this.URL)}`,
47
+ headers: this.headers,
48
+ });
49
+ return CommentReplyData;
50
+ case 'UserInfoData':
51
+ this.URL = DouyinAPI.用户主页信息({ sec_uid: data.sec_uid });
52
+ const UserInfoData = await this.GlobalGetData({
53
+ url: `${this.URL}&a_bougs=${Sign.AB(this.URL)}`,
54
+ headers: {
55
+ ...this.headers,
56
+ Referer: `https://www.douyin.com/user/${data.sec_uid}`,
57
+ },
58
+ });
59
+ return UserInfoData;
60
+ case 'EmojiData':
61
+ this.URL = DouyinAPI.表情();
62
+ const EmojiData = await this.GlobalGetData({
63
+ url: this.URL,
64
+ headers: this.headers,
65
+ });
66
+ return EmojiData;
67
+ case 'UserVideosListData':
68
+ this.URL = DouyinAPI.用户主页视频({ sec_uid: data.sec_uid });
69
+ const UserVideoListData = await this.GlobalGetData({
70
+ url: `${this.URL}&a_bougs=${Sign.AB(this.URL)}`,
71
+ headers: {
72
+ ...this.headers,
73
+ Referer: `https://www.douyin.com/user/${data.sec_uid}`,
74
+ },
75
+ });
76
+ return UserVideoListData;
77
+ case 'SuggestWordsData':
78
+ this.URL = DouyinAPI.热点词({ query: data.query });
79
+ const SuggestWordsData = await this.GlobalGetData({
80
+ url: `${this.URL}&a_bougs=${Sign.AB(this.URL)}`,
81
+ headers: {
82
+ ...this.headers,
83
+ Referer: `https://www.douyin.com/search/${encodeURIComponent(String(data.query))}`,
84
+ },
85
+ });
86
+ return SuggestWordsData;
87
+ case 'SearchData':
88
+ this.URL = DouyinAPI.搜索({ query: data.query });
89
+ const SearchData = await this.GlobalGetData({
90
+ url: `${this.URL}&a_bougs=${Sign.AB(this.URL)}`,
91
+ headers: {
92
+ ...this.headers,
93
+ Referer: `https://www.douyin.com/https://www.douyin.com/search/${encodeURIComponent(String(data.query))}`,
94
+ },
95
+ });
96
+ return SearchData;
97
+ case 'ExpressionPlusData':
98
+ this.URL = DouyinAPI.互动表情();
99
+ const ExpressionPlusData = await this.GlobalGetData({
100
+ url: `${this.URL}&a_bougs=${Sign.AB(this.URL)}`,
101
+ headers: this.headers,
102
+ });
103
+ return ExpressionPlusData;
104
+ case 'MusicData':
105
+ this.URL = DouyinAPI.背景音乐({ music_id: data.music_id });
106
+ const MusicData = await this.GlobalGetData({
107
+ url: `${this.URL}&a_bougs=${Sign.AB(this.URL)}`,
108
+ headers: this.headers,
109
+ });
110
+ return MusicData;
111
+ default:
112
+ break;
113
+ }
114
+ }
115
+ async GlobalGetData(options) {
116
+ const ResponseData = await new Networks(options).getData();
117
+ return ResponseData;
118
+ }
119
+ }
@@ -0,0 +1,13 @@
1
+ import { DouyinDataType } from '../../types/index.js';
2
+ interface IDDataTypes {
3
+ type: DouyinDataType;
4
+ aweme_id?: string;
5
+ sec_uid?: string;
6
+ }
7
+ /**
8
+ * return aweme_id
9
+ * @param {string} url 视频分享连接
10
+ * @returns
11
+ */
12
+ export default function GetDouyinID(url: string): Promise<IDDataTypes>;
13
+ export {};
@@ -0,0 +1,36 @@
1
+ import { Networks } from '../../model/index.js';
2
+ /**
3
+ * return aweme_id
4
+ * @param {string} url 视频分享连接
5
+ * @returns
6
+ */
7
+ export default async function GetDouyinID(url) {
8
+ const longLink = await new Networks({ url }).getLongLink();
9
+ let result = {};
10
+ switch (true) {
11
+ case /video\/(\d+)/.test(longLink):
12
+ const videoMatch = longLink.match(/video\/(\d+)/);
13
+ result = {
14
+ type: "VideoData" /* DouyinDataType['单个视频作品数据'] */,
15
+ aweme_id: videoMatch ? videoMatch[1] : '',
16
+ };
17
+ break;
18
+ case /note\/(\d+)/.test(longLink):
19
+ const noteMatch = longLink.match(/note\/(\d+)/);
20
+ result = {
21
+ type: "NoteData" /* DouyinDataType['图集作品数据'] */,
22
+ aweme_id: noteMatch ? noteMatch[1] : '',
23
+ };
24
+ break;
25
+ case /user\/(\S+?)\?/.test(longLink):
26
+ const userMatch = longLink.match(/user\/(\S+?)\?/);
27
+ result = {
28
+ type: "UserVideosListData" /* DouyinDataType['用户主页视频列表数据'] */,
29
+ sec_uid: userMatch ? userMatch[1] : '',
30
+ };
31
+ break;
32
+ default:
33
+ break;
34
+ }
35
+ return result;
36
+ }
@@ -0,0 +1,6 @@
1
+ import DouyinData from './getdata.js';
2
+ import DouyinAPI from './API.js';
3
+ import GetDouyinID from './getid.js';
4
+ import DouyinResult from './result.js';
5
+ import Sign from './sign/index.js';
6
+ export { DouyinAPI, DouyinData, GetDouyinID, DouyinResult, Sign };
@@ -0,0 +1,6 @@
1
+ import DouyinData from './getdata.js';
2
+ import DouyinAPI from './API.js';
3
+ import GetDouyinID from './getid.js';
4
+ import DouyinResult from './result.js';
5
+ import Sign from './sign/index.js';
6
+ export { DouyinAPI, DouyinData, GetDouyinID, DouyinResult, Sign };
@@ -0,0 +1,6 @@
1
+ import { DouyinDataType, GetDataResponseType, DouyinOptionsType } from '../../types/index.js';
2
+ export default class DouyinResult {
3
+ type: DouyinDataType;
4
+ constructor(type: DouyinDataType);
5
+ result(options?: DouyinOptionsType): Promise<GetDataResponseType>;
6
+ }
@@ -0,0 +1,39 @@
1
+ import { DouyinData, GetDouyinID } from '../../business/douyin/index.js';
2
+ export default class DouyinResult {
3
+ type;
4
+ constructor(type) {
5
+ this.type = type;
6
+ }
7
+ async result(options = {}) {
8
+ let result;
9
+ switch (this.type) {
10
+ case 'CommentReplyData':
11
+ case 'UserInfoData':
12
+ case 'UserVideosListData':
13
+ case 'SuggestWordsData':
14
+ case 'SearchData':
15
+ case 'EmojiData':
16
+ case 'ExpressionPlusData':
17
+ case 'MusicData':
18
+ case 'LiveImageData':
19
+ result = await new DouyinData(this.type).GetData(options);
20
+ break;
21
+ case 'VideoData':
22
+ case 'NoteData':
23
+ case 'CommentData': {
24
+ const defurl = options?.url?.toString().match(/(http|https):\/\/.*\.(douyin|iesdouyin)\.com\/[^ ]+/g);
25
+ const iddata = await GetDouyinID(String(defurl));
26
+ result = await new DouyinData(this.type).GetData(iddata);
27
+ break;
28
+ }
29
+ default:
30
+ result = '';
31
+ break;
32
+ }
33
+ return {
34
+ code: result !== false && result !== '' ? 200 : 503,
35
+ message: result !== false && result !== '' ? 'success' : 'error',
36
+ data: result !== false && result !== '' ? result : null,
37
+ };
38
+ }
39
+ }