@ikenxuan/amagi 4.3.2 → 4.4.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.
@@ -1283,7 +1283,7 @@ var DouyinData = async (data2, cookie) => {
1283
1283
  const url = douyinAPI.\u641C\u7D22({
1284
1284
  query: data2.query,
1285
1285
  number: requestCount,
1286
- search_id: search_id === "" ? undefined : search_id
1286
+ search_id: search_id === "" ? void 0 : search_id
1287
1287
  });
1288
1288
  const response = await GlobalGetData2({
1289
1289
  url: `${url}&a_bogus=${douyinSign.AB(url)}`,
@@ -1656,18 +1656,45 @@ var registerKuaishouRoutes = (fastify, cookie) => {
1656
1656
  };
1657
1657
 
1658
1658
  // src/model/DataFetchers.ts
1659
- var getDouyinData = async (type, cookie, options) => {
1659
+ async function getDouyinData(type, arg2, arg3) {
1660
+ let cookie;
1661
+ let options;
1662
+ if (typeof arg2 === "string") {
1663
+ cookie = arg2;
1664
+ options = arg3;
1665
+ } else {
1666
+ options = arg2;
1667
+ cookie = arg3;
1668
+ }
1660
1669
  const data2 = await DouyinData({ ...options, methodType: type }, cookie);
1661
1670
  return data2;
1662
- };
1663
- async function getBilibiliData(methodType, cookie, options) {
1671
+ }
1672
+ async function getBilibiliData(methodType, arg2, arg3) {
1673
+ let cookie;
1674
+ let options;
1675
+ if (typeof arg2 === "string") {
1676
+ cookie = arg2;
1677
+ options = arg3;
1678
+ } else {
1679
+ options = arg2;
1680
+ cookie = arg3;
1681
+ }
1664
1682
  const data2 = await BilibiliData({ ...options, methodType }, cookie);
1665
1683
  return data2;
1666
1684
  }
1667
- var getKuaishouData = async (methodType, cookie, options) => {
1685
+ async function getKuaishouData(methodType, arg2, arg3) {
1686
+ let cookie;
1687
+ let options;
1688
+ if (typeof arg2 === "string") {
1689
+ cookie = arg2;
1690
+ options = arg3;
1691
+ } else {
1692
+ options = arg2;
1693
+ cookie = arg3;
1694
+ }
1668
1695
  const data2 = await KuaishouData({ ...options, methodType }, cookie);
1669
1696
  return data2;
1670
- };
1697
+ }
1671
1698
  var fetchDouyinData = getDouyinData;
1672
1699
  var fetchBilibiliData = getBilibiliData;
1673
1700
  var fetchKuaishouData = getKuaishouData;
@@ -1771,7 +1798,7 @@ var Networks = class {
1771
1798
  this.data = {};
1772
1799
  this.timeout = data2.timeout ?? 15e3;
1773
1800
  this.isGetResult = false;
1774
- this.timer = undefined;
1801
+ this.timer = void 0;
1775
1802
  this.axiosInstance = axios__default.default.create({
1776
1803
  timeout: this.timeout,
1777
1804
  headers: this.headers,
@@ -1902,9 +1929,9 @@ var amagi = class {
1902
1929
  * @param cookie - 包含抖音ck、B站ck、快手ck的对象
1903
1930
  */
1904
1931
  constructor(data2) {
1905
- this.douyin = (data2 == null ? undefined : data2.douyin) ?? "";
1906
- this.bilibili = (data2 == null ? undefined : data2.bilibili) ?? "";
1907
- this.kuaishou = (data2 == null ? undefined : data2.kuaishou) ?? "";
1932
+ this.douyin = (data2 == null ? void 0 : data2.douyin) ?? "";
1933
+ this.bilibili = (data2 == null ? void 0 : data2.bilibili) ?? "";
1934
+ this.kuaishou = (data2 == null ? void 0 : data2.kuaishou) ?? "";
1908
1935
  }
1909
1936
  /**
1910
1937
  * 启动本地http服务
@@ -1271,7 +1271,7 @@ var DouyinData = async (data2, cookie) => {
1271
1271
  const url = douyinAPI.\u641C\u7D22({
1272
1272
  query: data2.query,
1273
1273
  number: requestCount,
1274
- search_id: search_id === "" ? undefined : search_id
1274
+ search_id: search_id === "" ? void 0 : search_id
1275
1275
  });
1276
1276
  const response = await GlobalGetData2({
1277
1277
  url: `${url}&a_bogus=${douyinSign.AB(url)}`,
@@ -1644,18 +1644,45 @@ var registerKuaishouRoutes = (fastify, cookie) => {
1644
1644
  };
1645
1645
 
1646
1646
  // src/model/DataFetchers.ts
1647
- var getDouyinData = async (type, cookie, options) => {
1647
+ async function getDouyinData(type, arg2, arg3) {
1648
+ let cookie;
1649
+ let options;
1650
+ if (typeof arg2 === "string") {
1651
+ cookie = arg2;
1652
+ options = arg3;
1653
+ } else {
1654
+ options = arg2;
1655
+ cookie = arg3;
1656
+ }
1648
1657
  const data2 = await DouyinData({ ...options, methodType: type }, cookie);
1649
1658
  return data2;
1650
- };
1651
- async function getBilibiliData(methodType, cookie, options) {
1659
+ }
1660
+ async function getBilibiliData(methodType, arg2, arg3) {
1661
+ let cookie;
1662
+ let options;
1663
+ if (typeof arg2 === "string") {
1664
+ cookie = arg2;
1665
+ options = arg3;
1666
+ } else {
1667
+ options = arg2;
1668
+ cookie = arg3;
1669
+ }
1652
1670
  const data2 = await BilibiliData({ ...options, methodType }, cookie);
1653
1671
  return data2;
1654
1672
  }
1655
- var getKuaishouData = async (methodType, cookie, options) => {
1673
+ async function getKuaishouData(methodType, arg2, arg3) {
1674
+ let cookie;
1675
+ let options;
1676
+ if (typeof arg2 === "string") {
1677
+ cookie = arg2;
1678
+ options = arg3;
1679
+ } else {
1680
+ options = arg2;
1681
+ cookie = arg3;
1682
+ }
1656
1683
  const data2 = await KuaishouData({ ...options, methodType }, cookie);
1657
1684
  return data2;
1658
- };
1685
+ }
1659
1686
  var fetchDouyinData = getDouyinData;
1660
1687
  var fetchBilibiliData = getBilibiliData;
1661
1688
  var fetchKuaishouData = getKuaishouData;
@@ -1759,7 +1786,7 @@ var Networks = class {
1759
1786
  this.data = {};
1760
1787
  this.timeout = data2.timeout ?? 15e3;
1761
1788
  this.isGetResult = false;
1762
- this.timer = undefined;
1789
+ this.timer = void 0;
1763
1790
  this.axiosInstance = axios.create({
1764
1791
  timeout: this.timeout,
1765
1792
  headers: this.headers,
@@ -1890,9 +1917,9 @@ var amagi = class {
1890
1917
  * @param cookie - 包含抖音ck、B站ck、快手ck的对象
1891
1918
  */
1892
1919
  constructor(data2) {
1893
- this.douyin = (data2 == null ? undefined : data2.douyin) ?? "";
1894
- this.bilibili = (data2 == null ? undefined : data2.bilibili) ?? "";
1895
- this.kuaishou = (data2 == null ? undefined : data2.kuaishou) ?? "";
1920
+ this.douyin = (data2 == null ? void 0 : data2.douyin) ?? "";
1921
+ this.bilibili = (data2 == null ? void 0 : data2.bilibili) ?? "";
1922
+ this.kuaishou = (data2 == null ? void 0 : data2.kuaishou) ?? "";
1896
1923
  }
1897
1924
  /**
1898
1925
  * 启动本地http服务
package/dist/index.d.ts CHANGED
@@ -13357,9 +13357,42 @@ type NetworksConfigType = {
13357
13357
 
13358
13358
  /** 定义一个泛型类型 OmitMethodType<T>,从类型 T 中排除 'methodType' 属性 */
13359
13359
  type OmitMethodType<T> = Omit<T, 'methodType'>;
13360
- type DouyinDataOptions<T extends keyof DouyinDataOptionsMap> = OmitMethodType<DouyinDataOptionsMap[T]['opt']>;
13361
- type BilibiliDataOptions<T extends keyof BilibiliDataOptionsMap> = OmitMethodType<BilibiliDataOptionsMap[T]['opt']>;
13362
- type KuaishouDataOptions<T extends keyof KuaishouDataOptionsMap> = OmitMethodType<KuaishouDataOptionsMap[T]['opt']>;
13360
+ type DouyinDataOptions<T extends keyof DouyinDataOptionsMap> = OmitMethodType<DouyinDataOptionsMap[T]['opt']> & TypeControl;
13361
+ type BilibiliDataOptions<T extends keyof BilibiliDataOptionsMap> = OmitMethodType<BilibiliDataOptionsMap[T]['opt']> & TypeControl;
13362
+ type KuaishouDataOptions<T extends keyof KuaishouDataOptionsMap> = OmitMethodType<KuaishouDataOptionsMap[T]['opt']> & TypeControl;
13363
+ /** 根据 `typeMode` 定义返回类型 */
13364
+ type Fnc<T extends {
13365
+ data: any;
13366
+ }, R extends TypeControl['typeMode']> = R extends 'strict' ? T['data'] : any;
13367
+ /**
13368
+ * 类型精度控制参数
13369
+ */
13370
+ type TypeControl = {
13371
+ /**
13372
+ * 获取返回类型
13373
+ * 类型定义时间:2025-02-02
13374
+ *
13375
+ * 类型解析模式:
13376
+ * - `strict`: 返回严格类型(基于接口响应定义,随时间推移可能缺少未声明的字段)
13377
+ * - `loose` 或 `未指定`: 返回宽松的 any 类型(默认)
13378
+ *
13379
+ * @default 'loose'
13380
+ * @example
13381
+ * ```ts
13382
+ * // 严格模式
13383
+ * const data = await amagi.getDouyinData('视频作品数据', {
13384
+ * aweme_id: '123',
13385
+ * typeMode: 'strict' // 返回精确的 VideoWork 类型
13386
+ * });
13387
+ *
13388
+ * // 宽松模式
13389
+ * const data = await amagi.getDouyinData('视频作品数据', {
13390
+ * aweme_id: '123' // 返回 any 类型
13391
+ * });
13392
+ * ```
13393
+ */
13394
+ typeMode?: 'strict' | 'loose';
13395
+ };
13363
13396
 
13364
13397
  /**
13365
13398
  * 获取抖音数据
@@ -13367,46 +13400,63 @@ type KuaishouDataOptions<T extends keyof KuaishouDataOptionsMap> = OmitMethodTyp
13367
13400
  * @param cookie - 有效的用户Cookie
13368
13401
  * @param options - 请求参数,是一个对象
13369
13402
  * @returns 返回接口的原始数据
13370
- * @example
13371
- * ```ts
13372
- * const data = await getDouyinData('搜索数据', 'User Cookies', {
13373
- * query: '114514',
13374
- * number: 10
13375
- * })
13376
- * ```
13377
13403
  */
13378
- declare const getDouyinData: <T extends keyof DouyinDataOptionsMap>(type: T, cookie?: string, options?: DouyinDataOptions<T>) => Promise<DouyinDataOptionsMap[T]["data"]>;
13404
+ declare function getDouyinData<T extends keyof DouyinDataOptionsMap, R extends 'strict' | 'loose'>(type: T, cookie: string, options?: DouyinDataOptions<T> & {
13405
+ typeMode?: R;
13406
+ }): Promise<Fnc<DouyinDataOptionsMap[T], R>>;
13407
+ /**
13408
+ * 获取抖音数据
13409
+ * @param type - 请求数据类型
13410
+ * @param options - 请求参数,是一个对象
13411
+ * @param cookie - 有效的用户Cookie
13412
+ * @returns 返回接口的原始数据
13413
+ */
13414
+ declare function getDouyinData<T extends keyof DouyinDataOptionsMap, R extends 'strict' | 'loose'>(type: T, options?: DouyinDataOptions<T> & {
13415
+ typeMode?: R;
13416
+ }, cookie?: string): Promise<Fnc<DouyinDataOptionsMap[T], R>>;
13379
13417
  /**
13380
13418
  * 获取B站数据
13381
13419
  * @param type - 请求数据类型
13382
13420
  * @param cookie - 有效的用户Cookie
13383
13421
  * @param options - 请求参数,是一个对象
13384
13422
  * @returns 返回接口的原始数据
13385
- * @example
13386
- * ```ts
13387
- * const data = await getBilibiliData('单个视频作品数据', 'User Cookies', {
13388
- * bvid: 'BV1fK4y1q79u'
13389
- * })
13390
- * ```
13391
13423
  */
13392
- declare function getBilibiliData<T extends keyof BilibiliDataOptionsMap>(methodType: T, cookie?: string, options?: BilibiliDataOptions<T>): Promise<BilibiliDataOptionsMap[T]['data']>;
13424
+ declare function getBilibiliData<T extends keyof BilibiliDataOptionsMap, R extends 'strict' | 'loose'>(methodType: T, cookie?: string, options?: BilibiliDataOptions<T> & {
13425
+ typeMode?: R;
13426
+ }): Promise<Fnc<BilibiliDataOptionsMap[T], R>>;
13427
+ /**
13428
+ * 获取B站数据
13429
+ * @param type - 请求数据类型
13430
+ * @param options - 请求参数,是一个对象
13431
+ * @param cookie - 有效的用户Cookie
13432
+ * @returns 返回接口的原始数据
13433
+ */
13434
+ declare function getBilibiliData<T extends keyof BilibiliDataOptionsMap, R extends 'strict' | 'loose'>(methodType: T, options?: BilibiliDataOptions<T> & {
13435
+ typeMode?: R;
13436
+ }, cookie?: string): Promise<Fnc<BilibiliDataOptionsMap[T], R>>;
13393
13437
  /**
13394
13438
  * 获取快手数据
13395
13439
  * @param type - 请求数据类型
13396
13440
  * @param cookie - 有效的用户Cookie
13397
13441
  * @param options - 请求参数,是一个对象
13398
13442
  * @returns 返回接口的原始数据
13399
- * @example
13400
- * ```ts
13401
- * const data = await getKuaishouData('单个视频作品数据', 'User Cookies', {
13402
- * photoId: '3xdpv6sfi8yjsqy'
13403
- * })
13404
- * ```
13405
13443
  */
13406
- declare const getKuaishouData: <T extends keyof KuaishouDataOptionsMap>(methodType: T, cookie?: string, options?: KuaishouDataOptions<T>) => Promise<KuaishouDataOptionsMap[T]["data"]>;
13407
- declare const fetchDouyinData: <T extends keyof DouyinDataOptionsMap>(type: T, cookie?: string, options?: DouyinDataOptions<T>) => Promise<DouyinDataOptionsMap[T]["data"]>;
13444
+ declare function getKuaishouData<T extends keyof KuaishouDataOptionsMap, R extends 'strict' | 'loose'>(methodType: T, cookie?: string, options?: KuaishouDataOptions<T> & {
13445
+ typeMode?: R;
13446
+ }): Promise<Fnc<KuaishouDataOptionsMap[T], R>>;
13447
+ /**
13448
+ * 获取快手数据
13449
+ * @param type - 请求数据类型
13450
+ * @param options - 请求参数,是一个对象
13451
+ * @param cookie - 有效的用户Cookie
13452
+ * @returns 返回接口的原始数据
13453
+ */
13454
+ declare function getKuaishouData<T extends keyof KuaishouDataOptionsMap, R extends 'strict' | 'loose'>(methodType: T, options?: KuaishouDataOptions<T> & {
13455
+ typeMode?: R;
13456
+ }, cookie?: string): Promise<Fnc<KuaishouDataOptionsMap[T], R>>;
13457
+ declare const fetchDouyinData: typeof getDouyinData;
13408
13458
  declare const fetchBilibiliData: typeof getBilibiliData;
13409
- declare const fetchKuaishouData: <T extends keyof KuaishouDataOptionsMap>(methodType: T, cookie?: string, options?: KuaishouDataOptions<T>) => Promise<KuaishouDataOptionsMap[T]["data"]>;
13459
+ declare const fetchKuaishouData: typeof getKuaishouData;
13410
13460
 
13411
13461
  declare class CustomLogger {
13412
13462
  private logger;
@@ -13665,7 +13715,9 @@ declare class amagi {
13665
13715
  * })
13666
13716
  * ```
13667
13717
  */
13668
- getDouyinData: <T extends keyof DouyinDataOptionsMap = keyof DouyinDataOptionsMap>(methodType: T, options?: DouyinDataOptions<T>) => Promise<DouyinDataOptionsMap[T]["data"]>;
13718
+ getDouyinData: <T extends keyof DouyinDataOptionsMap, R extends "strict" | "loose">(methodType: T, options?: DouyinDataOptions<T> & {
13719
+ typeMode?: R;
13720
+ }) => Promise<Fnc<DouyinDataOptionsMap[T], R>>;
13669
13721
  /**
13670
13722
  * 获取B站数据
13671
13723
  * @param type - 请求数据类型
@@ -13683,7 +13735,9 @@ declare class amagi {
13683
13735
  * })
13684
13736
  * ```
13685
13737
  */
13686
- getBilibiliData: <T extends keyof BilibiliDataOptionsMap = keyof BilibiliDataOptionsMap>(methodType: T, options?: BilibiliDataOptions<T>) => Promise<BilibiliDataOptionsMap[T]["data"]>;
13738
+ getBilibiliData: <T extends keyof BilibiliDataOptionsMap, R extends "strict" | "loose">(methodType: T, options?: BilibiliDataOptions<T> & {
13739
+ typeMode?: R;
13740
+ }) => Promise<Fnc<BilibiliDataOptionsMap[T], R>>;
13687
13741
  /**
13688
13742
  * 获取快手数据
13689
13743
  * @param type - 请求数据类型
@@ -13701,7 +13755,9 @@ declare class amagi {
13701
13755
  * })
13702
13756
  * ```
13703
13757
  */
13704
- getKuaishouData: <T extends keyof KuaishouDataOptionsMap = keyof KuaishouDataOptionsMap>(methodType: T, options?: KuaishouDataOptions<T>) => Promise<KuaishouDataOptionsMap[T]["data"]>;
13758
+ getKuaishouData: <T extends keyof KuaishouDataOptionsMap, R extends "strict" | "loose">(methodType: T, options?: KuaishouDataOptions<T> & {
13759
+ typeMode?: R;
13760
+ }) => Promise<Fnc<KuaishouDataOptionsMap[T], R>>;
13705
13761
  }
13706
13762
 
13707
13763
  /**
@@ -13714,4 +13770,4 @@ declare const startClient: (client: FastifyInstance, port: 4567) => void;
13714
13770
 
13715
13771
  declare function Amagi(options: ckParams): amagi;
13716
13772
 
13717
- export { Amagi, BilibiliData, type BilibiliDataOptions, type BilibiliDataOptionsMap, type BilibiliMethodOptionsMap, DouyinData, type DouyinDataOptions, type DouyinDataOptionsMap, type DouyinMethodOptionsMap, KuaishouAPI, KuaishouData, type KuaishouDataOptions, type KuaishouDataOptionsMap, Networks, type NetworksConfigType, type OmitMethodType, amagi, av2bv, bilibiliAPI, bv2av, type ckParams, amagi as default, douyinAPI, douyinSign, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, startClient, validateData, wbi_sign };
13773
+ export { Amagi, BilibiliData, type BilibiliDataOptions, type BilibiliDataOptionsMap, type BilibiliMethodOptionsMap, DouyinData, type DouyinDataOptions, type DouyinDataOptionsMap, type DouyinMethodOptionsMap, type Fnc, KuaishouAPI, KuaishouData, type KuaishouDataOptions, type KuaishouDataOptionsMap, Networks, type NetworksConfigType, type OmitMethodType, type TypeControl, amagi, av2bv, bilibiliAPI, bv2av, type ckParams, amagi as default, douyinAPI, douyinSign, fetchBilibiliData, fetchDouyinData, fetchKuaishouData, getBilibiliData, getDouyinData, getKuaishouData, logger, qtparam, registerBilibiliRoutes, registerDouyinRoutes, registerKuaishouRoutes, startClient, validateData, wbi_sign };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikenxuan/amagi",
3
- "version": "4.3.2",
3
+ "version": "4.4.0",
4
4
  "description": "抖音、B站的 web 端相关数据接口基于 Node.js 的实现",
5
5
  "keywords": [
6
6
  "douyin",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "main": "dist/cjs/index.cjs",
33
33
  "module": "dist/esm/index.mjs",
34
- "types": "dist/esm/index.d.ts",
34
+ "types": "dist/index.d.ts",
35
35
  "files": [
36
36
  "dist/*",
37
37
  "LICENSE",