/ clis / douyin / profile.js
profile.js
 1  import { cli, Strategy } from '@jackwener/opencli/registry';
 2  import { browserFetch } from './_shared/browser-fetch.js';
 3  import { CommandExecutionError } from '@jackwener/opencli/errors';
 4  cli({
 5      site: 'douyin',
 6      name: 'profile',
 7      description: '获取账号信息',
 8      domain: 'creator.douyin.com',
 9      strategy: Strategy.COOKIE,
10      args: [],
11      columns: ['uid', 'nickname', 'follower_count', 'following_count', 'aweme_count'],
12      func: async (page, _kwargs) => {
13          const url = 'https://creator.douyin.com/web/api/media/user/info/?aid=1128';
14          const res = (await browserFetch(page, 'GET', url));
15          const u = res.user_info ?? res.user;
16          if (!u)
17              throw new CommandExecutionError('用户信息获取失败,请确认已登录 creator.douyin.com');
18          return [
19              {
20                  uid: u.uid,
21                  nickname: u.nickname,
22                  follower_count: u.follower_count,
23                  following_count: u.following_count,
24                  aweme_count: u.aweme_count,
25              },
26          ];
27      },
28  });