### Develop F2 Documentation Locally Source: https://github.com/johnserf-seed/f2/blob/main/CONTRIBUTING.md Install dependencies and start a local development server for F2 documentation using pnpm and VitePress. This allows for live previewing of documentation changes. ```bash cd docs pnpm i pnpm docs:dev ``` -------------------------------- ### Compile and Install F2 from Source (Windows) Source: https://github.com/johnserf-seed/f2/blob/main/docs/install.md Clone the F2 repository and perform a development installation using pip. ```shell $ git clone https://github.com/Johnserf-Seed/f2.git $ cd f2 $ pip install -e . # 在当前目录下进行开发安装 ``` -------------------------------- ### Compile and Install F2 from Source (Linux/macOS) Source: https://github.com/johnserf-seed/f2/blob/main/docs/install.md Clone the F2 repository and perform a development installation using pip3. ```shell $ git clone https://github.com/Johnserf-Seed/f2.git $ cd f2 $ pip3 install -e . # 在当前目录下进行开发安装 ``` -------------------------------- ### Switch to Development Branch and Install (Windows) Source: https://github.com/johnserf-seed/f2/blob/main/docs/install.md View all branches, checkout a specific development branch, and perform a development installation using pip. ```shell $ git branch -a # 查看所有分支 $ git checkout vx.x.x.x # 切换到最新的vx.x.x.x分支 $ pip install -e . # 开发安装 ``` -------------------------------- ### Install F2 with Alternative Mirror (Windows) Source: https://github.com/johnserf-seed/f2/blob/main/docs/install.md Install F2 using pip with a specified alternative mirror, useful for slow network environments. ```shell $ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple f2 ``` -------------------------------- ### Switch to Development Branch and Install (Linux/macOS) Source: https://github.com/johnserf-seed/f2/blob/main/docs/install.md View all branches, checkout a specific development branch, and perform a development installation using pip3. ```shell $ git branch -a # 查看所有分支 $ git checkout vx.x.x.x # 切换到最新的vx.x.x.x分支 $ pip3 install -e . # 开发安装 ``` -------------------------------- ### Install F2 with Alternative Mirror (Linux/macOS) Source: https://github.com/johnserf-seed/f2/blob/main/docs/install.md Install F2 using pip3 with a specified alternative mirror, useful for slow network environments. ```shell $ pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple f2 ``` -------------------------------- ### Install F2 using Pip (Windows) Source: https://github.com/johnserf-seed/f2/blob/main/docs/install.md Use pip to install the latest version of F2, a specific version, update to the latest, or uninstall. ```shell $ pip install f2 # 安装最新版本 $ pip install f2==x.x.x.x # 安装指定版本 $ pip install -U f2 # 更新到最新版本 $ pip uninstall f2 # 卸载 ``` -------------------------------- ### Install F2 using Pip (Linux/macOS) Source: https://github.com/johnserf-seed/f2/blob/main/docs/install.md Use pip3 to install the latest version of F2, a specific version, update to the latest, or uninstall. ```shell $ pip3 install f2 # 安装最新版本 $ pip3 install f2==x.x.x.x # 安装指定版本 $ pip3 install -U f2 # 更新到最新版本 $ pip3 uninstall f2 # 卸载 ``` -------------------------------- ### Update Cookie Configuration Example Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/weibo/cli.md Demonstrates how to update the configuration with a provided cookie and specify a configuration file. ```bash f2 wb -k "your_cookie" -c your_config.yaml --update-config ``` -------------------------------- ### Weibo Client Configuration Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Initializes the Weibo client. This is the starting point for interacting with the Weibo API. ```python from f2.apps.weibo.client import Client client = Client() ``` -------------------------------- ### Find F2 Installation Location Source: https://github.com/johnserf-seed/f2/blob/main/docs/site-config.md Use pip show to find the installation directory of the F2 package. This is useful for locating configuration files if they are not in the expected path. ```bash $ pip show f2 ``` ```bash $ pip3 show f2 ``` -------------------------------- ### Twitter Client Configuration Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Initializes the Twitter client. This is the starting point for interacting with the Twitter API. ```python from f2.apps.twitter.client import Client client = Client() ``` -------------------------------- ### Get Douyin User Follow Live Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Fetches a list of live streams that the user is following on Douyin. ```python from f2.apps.douyin.client import Client client = Client() followed_lives = client.user_follow_live("12345678") ``` -------------------------------- ### TikTok Client Configuration Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Initializes the TikTok client. This is the starting point for interacting with the TikTok API. ```python from f2.apps.tiktok.client import Client client = Client() ``` -------------------------------- ### Manage msToken - Douyin API Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/api-examples.md Manages msToken for Douyin API requests. Includes examples for real and false scenarios. ```python from douyin.utils import token_manager # Real msToken print(token_manager.mstoken_real_sinppest()) ``` ```python from douyin.utils import token_manager # False msToken print(token_manager.mstoken_false_sinppest()) ``` -------------------------------- ### Crawler: Bark Notification Interface (GET) Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/bark/overview.md Asynchronous method to send Bark notifications using the GET method. ```APIDOC ## GET /api/crawler/bark_notification ### Description Asynchronous method to send Bark notifications using the GET method. ### Method GET ### Endpoint /api/crawler/bark_notification ### Parameters #### Query Parameters - **params** (BarkModel) - Required - The interface parameter model for Bark notifications. ### Response #### Success Response (200) - **_fetch_get_json** (dict) - The return value after successfully sending the notification. ### Response Example ```json { "message": "Notification sent successfully" } ``` ``` -------------------------------- ### Fetch Bark Notification (GET) Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/bark/overview.md Asynchronous method to send Bark notifications using the GET method. Requires a BarkModel for parameters. ```python from f2.apps.crawler.bark import BarkCrawler from f2.apps.bark.model import BarkModel async def main(): params = BarkModel( body="通知内容", title="通知标题", group="通知分组", icon="通知图标", sound="通知声音", level="通知级别", badge=1, # ... other parameters ) await BarkCrawler().fetch_bark_notification(params=params) if __name__ == "__main__": import asyncio asyncio.run(main()) ``` -------------------------------- ### Download Douyin Posts using Main Configuration (Windows) Source: https://github.com/johnserf-seed/f2/blob/main/docs/cli.md Execute F2 on Windows to download Douyin posts using the main configuration file. The '-c' parameter is omitted when using the primary configuration. ```sh $ f2 dy ``` -------------------------------- ### POST /api/douyin/user/get-add Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves or creates user data and their corresponding directory. This is a CLI mode interface where developers can define user directory creation logic. If 'mode' is not set, it defaults to PLEASE_SETUP_MODE. ```APIDOC ## POST /api/douyin/user/get-add ### Description Asynchronously retrieves or creates user data and their corresponding directory. This is a CLI mode interface where developers can define user directory creation logic. If 'mode' is not set, it defaults to PLEASE_SETUP_MODE. ### Method POST ### Endpoint /api/douyin/user/get-add ### Parameters #### Request Body - **sec_user_id** (str) - Required - User ID - **db** (AsyncUserDB) - Required - User database instance - **kwargs** (dict) - Required - CLI dictionary data, requires path parameters ### Request Example ```json { "sec_user_id": "some_user_id", "db": "", "kwargs": { "path": "/some/path" } } ``` ### Response #### Success Response (200) - **user_path** (Path) - User directory path object #### Response Example ```json { "user_path": "/path/to/user/directory" } ``` ``` -------------------------------- ### Douyin Client Configuration Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Basic client configuration for Douyin. This snippet shows initializing the client. ```python from f2.apps.douyin.client import Client client = Client() ``` -------------------------------- ### Initialize Custom Configuration Source: https://github.com/johnserf-seed/f2/blob/main/docs/site-config.md Run this command to initialize a custom configuration file for your applications. The filename can be specified with the --init-config flag. ```bash $ f2 apps --init-config my_apps.yaml ``` -------------------------------- ### Initialize Configuration for Specific Apps Source: https://github.com/johnserf-seed/f2/blob/main/docs/site-config.md Initialize configuration files for specific applications using their full or shorthand names. This is useful for managing configurations for multiple apps like Douyin and TikTok. ```bash $ f2 dy/douyin --init-config dy.yaml ``` ```bash $ f2 tk/tiktok --init-config tk.yaml ``` -------------------------------- ### GET /api/douyin/video/one Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves details for a single video. ```APIDOC ## GET /api/douyin/video/one ### Description Asynchronously retrieves details for a single video. ### Method GET ### Endpoint /api/douyin/video/one ### Parameters #### Query Parameters - **aweme_id** (str) - Required - Video ID ### Request Example ``` GET /api/douyin/video/one?aweme_id=some_video_id ``` ### Response #### Success Response (200) - **PostDetailFilter** (model) - Single video data filter, includes _to_raw, _to_dict, _to_list methods. #### Response Example ```json { "PostDetailFilter": { "_to_raw": "", "_to_dict": "", "_to_list": "" } } ``` ``` -------------------------------- ### Create or Get User Data and Directory Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/twitter/overview.md Asynchronous method to fetch or create user data and its directory. Requires CLI dictionary data with a 'path' parameter and user ID. Returns the user directory path object. This is a CLI mode interface; developers can define their own user directory creation logic. Defaults to PLEASE_SETUP_MODE directory if 'mode' is not set. ```python async def get_or_add_user_data(kwargs: dict, sec_user_id: str, db: AsyncUserDB) -> Path: user_path: Path = await db.get_or_add_user_data(sec_user_id=sec_user_id) return user_path ``` -------------------------------- ### GET /api/douyin/user/profile Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves the information of a specified user. ```APIDOC ## GET /api/douyin/user/profile ### Description Asynchronously retrieves the information of a specified user. ### Method GET ### Endpoint /api/douyin/user/profile ### Parameters #### Query Parameters - **sec_user_id** (str) - Required - User ID ### Request Example ``` GET /api/douyin/user/profile?sec_user_id=some_user_id ``` ### Response #### Success Response (200) - **UserProfileFilter** (model) - User data filter, includes _to_raw, _to_dict methods for user data. #### Response Example ```json { "UserProfileFilter": { "_to_raw": "", "_to_dict": "" } } ``` ``` -------------------------------- ### Manage Client Configuration Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/twitter/overview.md Use this class method to manage client configuration. It returns configuration values. ```python client_config() ``` -------------------------------- ### Get Friend Works Data Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves works from friends. ```APIDOC ## GET /user/friend/feed ### Description Asynchronously retrieves works from friends. ### Method GET ### Endpoint /user/friend/feed ### Parameters #### Query Parameters - **cursor** (str) - Optional - The page number, defaults to 0. - **level** (int) - Optional - The work level, defaults to 1. - **pull_type** (int) - Optional - The pull type, defaults to 0. Possible values: 0, 2, 18 (specific meanings not fully researched). - **max_counts** (int) - Optional - The maximum number of items, defaults to None. ### Response #### Success Response (200) - **FriendFeedFilter** (AsyncGenerator) - A filter for friend works data, with methods like _to_raw, _to_dict, and _to_list. ### Response Example ```json { "FriendFeedFilter": "" } ``` ``` -------------------------------- ### GET /api/douyin/user/live Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves live stream data for a specified user. ```APIDOC ## GET /api/douyin/user/live ### Description Asynchronously retrieves live stream data for a specified user. ### Method GET ### Endpoint /api/douyin/user/live ### Parameters #### Query Parameters - **webcast_id** (str) - Required - Live stream ID ### Request Example ``` GET /api/douyin/user/live?webcast_id=some_webcast_id ``` ### Response #### Success Response (200) - **webcast_data** (dict) - Live stream data dictionary, including live ID, title, status, viewer count, sub-partition, streamer nickname, etc. #### Response Example ```json { "webcast_data": { "live_id": "some_webcast_id", "title": "Live Stream Title", "status": "live", "viewers": 1000, "sub_partition": "Gaming", "nickname": "StreamerName" } } ``` ::: tip :bulb: 提示 - `webcast_id` and `room_id` are two independent parameters resolved by different interfaces. - For example, in `https://live.douyin.com/775841227732`, `775841227732` is the live stream ID (`webcast_id`/`live_id`). - When using a live stream link shared from the `APP` end, the resolved ID is `room_id`. You need to use the `fetch_user_live_videos_by_room_id` interface in that case. ::: ``` -------------------------------- ### Create User Record and Directory Source: https://github.com/johnserf-seed/f2/blob/main/docs/en/guide/apps/weibo/overview.md Asynchronous method to retrieve or create user data and generate a user directory. It's a CLI interface, allowing custom directory creation. Defaults to PLEASE_SETUP_MODE if mode is not set. ```python async def get_or_add_user_data( kwargs: dict, user_id: str, db: AsyncUserDB, ) -> Path: # ... (implementation details) pass # Example usage within CLI mode: # await get_or_add_user_data(kwargs=cli_args, user_id=user_id, db=user_db) ``` -------------------------------- ### GET /api/douyin/user/posts Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves a list of videos posted by a user. Supports pagination. ```APIDOC ## GET /api/douyin/user/posts ### Description Asynchronously retrieves a list of videos posted by a user. Supports pagination. ### Method GET ### Endpoint /api/douyin/user/posts ### Parameters #### Query Parameters - **sec_user_id** (str) - Required - User ID - **min_cursor** (int) - Optional - Minimum cursor for pagination, defaults to 0 - **max_cursor** (int) - Optional - Maximum cursor for pagination, defaults to 0 - **page_counts** (int) - Optional - Number of items per page, defaults to 20 - **max_counts** (int) - Optional - Maximum total items to retrieve, defaults to None ### Request Example ``` GET /api/douyin/user/posts?sec_user_id=some_user_id&page_counts=10 ``` ### Response #### Success Response (200) - **UserPostFilter** (AsyncGenerator) - Filter for posted video data, includes _to_raw, _to_dict, _to_list methods. #### Response Example ```json { "UserPostFilter": "" } ``` ``` -------------------------------- ### 添加f2命令到环境变量 Source: https://github.com/johnserf-seed/f2/blob/main/docs/faq.md 在非Windows系统上,如果f2命令未找到,需要将f2命令的路径添加到环境变量中。首先运行`which f2`查找路径,然后编辑`~/.bashrc`文件添加`export PATH="$PATH:/home/YOUR_NAME/.local/bin"`,最后运行`source ~/.bashrc`使配置生效。 ```shell which f2 ``` ```shell export PATH="$PATH:/home/YOUR_NAME/.local/bin" ``` ```shell source ~/.bashrc ``` -------------------------------- ### Get Twitter User Likes Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Retrieves a list of tweets that a Twitter user has liked. ```python from f2.apps.twitter.client import Client client = Client() likes = client.user_like("user_id") ``` -------------------------------- ### Download Douyin Likes using CLI (Windows) Source: https://github.com/johnserf-seed/f2/blob/main/docs/cli.md On Windows, use this CLI command to download liked videos by setting the mode to 'like'. This overrides any settings in the configuration file. ```sh $ f2 dy -M like ``` -------------------------------- ### Get Following User Data Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves the list of users followed by a specified user. ```APIDOC ## GET /user/following ### Description Asynchronously retrieves the list of users followed by a specified user. Only public followings can be retrieved. ### Method GET ### Endpoint /user/following ### Parameters #### Query Parameters - **user_id** (str) - Required - The user ID. - **sec_user_id** (str) - Required - The user ID. - **offset** (int) - Optional - The page number, defaults to 0. Valid only when `source_type` is 4. - **min_time** (int) - Optional - The earliest follow timestamp (in seconds), defaults to 0. - **max_time** (int) - Optional - The latest follow timestamp (in seconds), defaults to 0. - **count** (int) - Optional - The number of followed users per page, defaults to 20. - **source_type** (int) - Optional - The sorting type, defaults to 4. (1: recent follows, 3: earliest follows, 4: comprehensive sort). - **max_counts** (float) - Optional - The maximum number of items, defaults to None. ### Response #### Success Response (200) - **UserFollowingFilter** (AsyncGenerator) - A filter for following user data, with methods like _to_raw, _to_dict, and _to_list. ### Response Example ```json { "UserFollowingFilter": "" } ``` ### Notes - Using custom time ranges (`min_time`, `max_time`) is not recommended for data completeness, only for specific time-period data retrieval. - The `count` parameter should not be set too high; the default value is recommended. ``` -------------------------------- ### Handler API: Create User Record and Directory Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/twitter/overview.md Asynchronous method to get or create user data while also creating a user directory. This is a CLI mode interface, and developers can define their own user directory creation logic. If the 'mode' parameter is not set, it defaults to 'PLEASE_SETUP_MODE'. ```APIDOC ## POST /api/users/create_or_get ### Description Asynchronous method to get or create user data while also creating a user directory. ### Method POST ### Endpoint /api/users/create_or_get ### Parameters #### Request Body - **kwargs** (dict) - Required - CLI dictionary data, requires path parameters. - **sec_user_id** (str) - Required - User ID. - **db** (AsyncUserDB) - Required - User database. ### Response #### Success Response (200) - **user_path** (Path) - Description of the user directory path object. ### Request Example ```json { "kwargs": {}, "sec_user_id": "user123", "db": "" } ``` ### Response Example ```json { "user_path": "/path/to/user/directory" } ``` ``` -------------------------------- ### GET /api/douyin/user/collects Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves a list of the user's collection folders (not the videos within them). ```APIDOC ## GET /api/douyin/user/collects ### Description Asynchronously retrieves a list of the user's collection folders (not the videos within them). ### Method GET ### Endpoint /api/douyin/user/collects ### Parameters #### Query Parameters - **max_cursor** (int) - Optional - Cursor for pagination, defaults to 0 - **page_counts** (int) - Optional - Number of items per page, defaults to 20 - **max_counts** (int) - Optional - Maximum total items to retrieve, defaults to None ### Request Example ``` GET /api/douyin/user/collects?page_counts=30 ``` ### Response #### Success Response (200) - **UserCollectsFilter** (AsyncGenerator) - Filter for collection folder data, includes _to_raw, _to_dict, _to_list methods. #### Response Example ```json { "UserCollectsFilter": "" } ``` ``` -------------------------------- ### Manage Client Configuration Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Class method for managing client configuration settings. Returns configuration file values. ```python def get_client_config(cls) -> Any: """ 获取客户端配置 :return: """ return ClientConfig.get_config()) def set_client_config(cls, config: dict): """ 设置客户端配置 :param config: 配置字典 :return: """ ClientConfig.set_config(config) def get_client_config_value(cls, key: str) -> Any: """ 获取客户端配置值 :param key: 配置键 :return: """ return ClientConfig.get_config_value(key) def set_client_config_value(cls, key: str, value: Any): """ 设置客户端配置值 :param key: 配置键 :param value: 配置值 :return: """ ClientConfig.set_config_value(key, value) ``` -------------------------------- ### Get Weibo User Posts Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Fetches a list of posts created by a specific Weibo user. ```python from f2.apps.weibo.client import Client client = Client() posts = client.user_weibo("user_id") ``` -------------------------------- ### Get Twitter User Tweets Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Fetches a list of tweets created by a specific Twitter user. ```python from f2.apps.twitter.client import Client client = Client() tweets = client.user_tweet("user_id") ``` -------------------------------- ### Create User Record and Directory Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronous method to get or create user data and simultaneously create a user directory. Requires 'path' parameter from cli dictionary. ```python async def user_get_add(kwargs: dict, sec_user_id: str, db: AsyncUserDB) -> Path: """获取或创建用户数据,同时创建用户目录 :param kwargs: cli字典数据,需获取path参数 :param sec_user_id: 用户ID :param db: 用户数据库 :return: 用户目录路径对象 """ # ... (implementation details omitted for brevity) pass ``` -------------------------------- ### Get TikTok User Likes Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Retrieves a list of videos or posts that a TikTok user has liked. ```python from f2.apps.tiktok.client import Client client = Client() likes = client.user_like("12345678") ``` -------------------------------- ### Manage Client Configuration Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/weibo/overview.md Class method for managing client configuration. It retrieves configuration values. ```python def client_config(): """管理客户端配置 :return: 配置文件值 """ return _client_config ``` -------------------------------- ### Get Douyin User Likes Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Retrieves a list of videos or posts that a Douyin user has liked. ```python from f2.apps.douyin.client import Client client = Client() likes = client.user_like("12345678") ``` -------------------------------- ### Get Douyin User Follower List Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Retrieves the list of followers for a given Douyin user. ```python from f2.apps.douyin.client import Client client = Client() followers = client.user_follower("12345678") ``` -------------------------------- ### 创建直播流下载任务 Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Creates a live stream download task. ```APIDOC ## POST /api/downloads/create_live_stream_task ### Description Creates a live stream download task. ### Method POST ### Endpoint /api/downloads/create_live_stream_task ``` -------------------------------- ### Manage Client Configuration Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/bark/overview.md Used for managing client configuration. No specific parameters are required, and it returns configuration values. ```python from f2.apps.utils.client_config import ClientConfManager def main(): conf = ClientConfManager() print(conf.get_conf("host")) print(conf.get_conf("port")) if __name__ == "__main__": main() ``` -------------------------------- ### Bark Client Configuration Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Configuration for the Bark client. This snippet shows how to set up the client with necessary parameters. ```python from f2.apps.bark.client import Client client = Client(host="your_bark_host", token="your_bark_token") ``` -------------------------------- ### Initialize Live Danmaku (Bullet Chat) Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronous method to initialize the danmaku (bullet chat) system for a live stream. Requires a LiveImFetch object for request parameters. ```python async def initialize_live_danmaku(params: LiveImFetch) -> dict: """异步方法,用于获取直播弹幕初始化数据。 Args: params: 请求参数 Returns: 直播弹幕初始化数据 """ # ... implementation details ... return {} ``` -------------------------------- ### Get User Live Stream Data Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves live stream data for a specified user. ```APIDOC ## GET /user/live/stream ### Description Asynchronously retrieves live stream data for a specified user. ### Method GET ### Endpoint /user/live/stream ### Parameters #### Query Parameters - **room_id** (str) - Required - The ID of the live room. ### Response #### Success Response (200) - **webcast_data** (dict) - A dictionary containing live stream data, including live ID, title, status, viewer count, sub-partition, and anchor nickname. ### Response Example ```json { "webcast_data": { "live_id": "1234567890", "title": "My Awesome Live Stream", "status": "LIVE", "viewer_count": 1000, "sub_partition": "Gaming", "anchor_nickname": "GamerPro" } } ``` ``` -------------------------------- ### GET /api/douyin/user/mix/videos Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves a list of videos within a specified user's mix (compilation). ```APIDOC ## GET /api/douyin/user/mix/videos ### Description Asynchronously retrieves a list of videos within a specified user's mix (compilation). ### Method GET ### Endpoint /api/douyin/user/mix/videos ### Parameters #### Query Parameters - **mix_id** (str) - Required - Mix ID - **max_cursor** (int) - Optional - Cursor for pagination, defaults to 0 - **page_counts** (int) - Optional - Number of items per page, defaults to 20 - **max_counts** (int) - Optional - Maximum total items to retrieve, defaults to None ### Request Example ``` GET /api/douyin/user/mix/videos?mix_id=some_mix_id&page_counts=15 ``` ### Response #### Success Response (200) - **UserMixFilter** (AsyncGenerator) - Filter for mix video data, includes _to_raw, _to_dict, _to_list methods. #### Response Example ```json { "UserMixFilter": "" } ``` ::: tip :bulb: 提示 - The `mix_id` for mix videos is consistent. Use the `fetch_one_video` interface to obtain the `mix_id`. ::: ``` -------------------------------- ### Create User Record & Directory Source: https://github.com/johnserf-seed/f2/blob/main/docs/en/guide/apps/weibo/overview.md Asynchronous method to retrieve or create user data while also generating a user directory. This is a CLI mode interface, developers can define their own user directory creation functionality. If mode is not set, it defaults to the PLEASE_SETUP_MODE directory. ```APIDOC ## Create User Record & Directory ### Description Asynchronous method to retrieve or create user data while also generating a user directory. ### Method POST ### Endpoint /api/users/create_or_get ### Parameters #### Request Body - **user_id** (str) - Required - User ID - **db** (AsyncUserDB) - Required - User database - **mode** (str) - Optional - Specifies the directory mode. Defaults to PLEASE_SETUP_MODE. ### Request Example ```json { "user_id": "user123", "mode": "default" } ``` ### Response #### Success Response (200) - **user_path** (Path) - User directory path object #### Response Example ```json { "user_path": "/path/to/user/directory" } ``` ``` -------------------------------- ### 配置interval参数以解决作品未找到问题 Source: https://github.com/johnserf-seed/f2/blob/main/docs/faq.md 当出现'WARNING 没有找到符合条件的作品'时,检查并配置`interval`参数。如果配置文件中没有该参数,请添加`interval: all`。如果已有该参数,请确保其设置正确。CLI命令中可使用`-i all`参数。 ```yaml interval: all ``` ```shell -i all ``` -------------------------------- ### GET /api/douyin/user/collects/videos Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves a list of videos within a specified user's collection folder. ```APIDOC ## GET /api/douyin/user/collects/videos ### Description Asynchronously retrieves a list of videos within a specified user's collection folder. ### Method GET ### Endpoint /api/douyin/user/collects/videos ### Parameters #### Query Parameters - **collect_id** (str) - Required - Collection folder ID - **max_cursor** (int) - Optional - Cursor for pagination, defaults to 0 - **page_counts** (int) - Optional - Number of items per page, defaults to 20 - **max_counts** (int) - Optional - Maximum total items to retrieve, defaults to None ### Request Example ``` GET /api/douyin/user/collects/videos?collect_id=some_collect_id&max_cursor=20 ``` ### Response #### Success Response (200) - **UserCollectsVideosFilter** (AsyncGenerator) - Filter for collection videos data, includes _to_raw, _to_dict, _to_list methods. #### Response Example ```json { "UserCollectsVideosFilter": "" } ``` ``` -------------------------------- ### Download Single Douyin Video using CLI (Windows) Source: https://github.com/johnserf-seed/f2/blob/main/docs/cli.md On Windows, use this command to download a single Douyin video by specifying the 'one' mode and providing the video URL. F2 can intelligently parse various link formats. ```sh $ f2 dy -M one -u https://v.douyin.com/iRNBho6u/ ``` -------------------------------- ### Get User Profile Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronous method to retrieve information for a specified user. Returns a UserProfileFilter model. ```python async def user_profile(sec_user_id: str) -> UserProfileFilter: """获取指定用户的信息 :param sec_user_id: 用户ID :return: 用户数据过滤器 """ # ... (implementation details omitted for brevity) pass ``` -------------------------------- ### Manage Douyin User Download Directories Source: https://context7.com/johnserf-seed/f2/llms.txt Utilities for creating, renaming, and automatically managing user download folders based on nickname. Supports different download modes. ```python from pathlib import Path from f2.apps.douyin.utils import create_user_folder, rename_user_folder, create_or_rename_user_folder # 配置参数 kwargs = { "path": "Download", # 基础下载路径 "mode": "post", # 下载模式 } # 创建用户目录 user_path = create_user_folder(kwargs, nickname="用户昵称") print(f"用户目录: {user_path}") # 输出: Download/douyin/post/用户昵称 # 重命名用户目录 old_path = Path("Download/douyin/post/旧昵称") new_path = rename_user_folder(old_path, new_nickname="新昵称") print(f"重命名后的目录: {new_path}") # 创建或重命名用户目录(自动处理) local_user_data = {"nickname": "旧昵称"} # 数据库中的旧数据 current_nickname = "新昵称" # 当前最新昵称 user_path = create_or_rename_user_folder(kwargs, local_user_data, current_nickname) print(f"最终用户目录: {user_path}") ``` -------------------------------- ### Get Weibo User Detail Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Retrieves detailed information for a Weibo user. Requires a configured client. ```python from f2.apps.weibo.client import Client client = Client() details = client.user_detail("user_id") ``` -------------------------------- ### Get Twitter User Profile Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Retrieves the profile information for a Twitter user. Requires a configured client. ```python from f2.apps.twitter.client import Client client = Client() profile = client.user_profile("user_id") ``` -------------------------------- ### 创建原声下载任务 Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Creates an original audio download task. ```APIDOC ## POST /api/downloads/create_original_audio_task ### Description Creates an original audio download task. ### Method POST ### Endpoint /api/downloads/create_original_audio_task ``` -------------------------------- ### Forward Douyin Live Comments Source: https://github.com/johnserf-seed/f2/blob/main/docs/advance-guide.md This snippet demonstrates forwarding live comments from Douyin. It requires generating a guest account using `ttwid` to bypass account limitations. Ensure network stability and adequate device performance. Use separate WSS configurations for multiple live rooms to prevent comment mix-ups. ```python from f2.apps.douyin.downloader import DouyinDownloader async def user_live_im_fetch(): async with DouyinDownloader() as d: # type: DouyinDownloader # 1. 直播弹幕转发 await d.user_live_im_fetch( max_connections=10, # 允许的最大并发连接数 max_tasks=10, # 允许的最大并发任务数 # ... ) if __name__ == "__main__": import asyncio asyncio.run(user_live_im_fetch()) ``` -------------------------------- ### Get TikTok User Profile Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Retrieves the profile information for a TikTok user. Requires a configured client. ```python from f2.apps.tiktok.client import Client client = Client() profile = client.user_profile("12345678") ``` -------------------------------- ### Get TikTok User Posts Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Fetches a list of posts (videos) created by a specific TikTok user. ```python from f2.apps.tiktok.client import Client client = Client() posts = client.user_post("12345678") ``` -------------------------------- ### Create User Directory Source: https://github.com/johnserf-seed/f2/blob/main/docs/en/guide/apps/tiktok/overview.md Creates a user directory if it does not already exist. Supports absolute and relative paths, defaulting to 'Download'. ```python from TikTokApi import TikTokApi tikapi = TikTokApi() user_path = tikapi.user_folder.create_user_folder(kwargs={'custom_download_list': ['download']}, nickname='test_user') print(user_path) ``` -------------------------------- ### Get Douyin User Profile Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Retrieves the profile information for a Douyin user. Requires a configured client. ```python from f2.apps.douyin.client import Client client = Client() profile = client.user_profile("12345678") ``` -------------------------------- ### 创建下载任务 Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Creates a download task. ```APIDOC ## POST /api/downloads/create_task ### Description Creates a download task. ### Method POST ### Endpoint /api/downloads/create_task ``` -------------------------------- ### Get Douyin User Posts Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Fetches a list of posts (videos) created by a specific Douyin user. ```python from f2.apps.douyin.client import Client client = Client() posts = client.user_post("12345678") ``` -------------------------------- ### Get Douyin User Friends Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Fetches the list of friends for a Douyin user. This might be different from followers. ```python from f2.apps.douyin.client import Client client = Client() friends = client.user_friend("12345678") ``` -------------------------------- ### Create User Directory Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/tiktok/overview.md Creates a user directory if it does not already exist. The path is determined by configuration or defaults to 'Download'. ```python user_folder.create_user_folder(kwargs, nickname='example_user') ``` -------------------------------- ### Get Douyin User Following List Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Retrieves the list of users that a given Douyin user is following. ```python from f2.apps.douyin.client import Client client = Client() following = client.user_following("12345678") ``` -------------------------------- ### Build Static F2 Documentation Source: https://github.com/johnserf-seed/f2/blob/main/CONTRIBUTING.md Generate static HTML files for the F2 documentation using pnpm and VitePress. This command is typically run before committing changes to ensure the documentation builds correctly. ```bash pnpm docs:build ``` -------------------------------- ### Batch Fetch Douyin Lives Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Fetches live stream information in batches for multiple room IDs. Requires a configured client. ```python from f2.apps.douyin.client import Client client = Client() room_ids = ["123", "456"] lives = client.batch_lives(room_ids) ``` -------------------------------- ### Generate Localization POT Files (Windows) Source: https://github.com/johnserf-seed/f2/blob/main/CONTRIBUTING.md Execute the make_pot.bat script on Windows to generate .pot and .po files for localization. ```bash $ make_pot.bat ``` -------------------------------- ### Get Follower User Data Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves the list of followers for a specified user. Only public followers can be retrieved. ```APIDOC ## GET /user/follower ### Description Asynchronously retrieves the list of followers for a specified user. Only public followers can be retrieved. ### Method GET ### Endpoint /user/follower ### Parameters #### Query Parameters - **user_id** (str) - Required - The user ID. - **sec_user_id** (str) - Required - The user ID. - **offset** (int) - Optional - The page number, defaults to 0. Invalid when `source_type` is 1 or 2. - **min_time** (int) - Optional - The earliest follow timestamp (in seconds), defaults to 0. - **max_time** (int) - Optional - The latest follow timestamp (in seconds), defaults to 0. - **count** (int) - Optional - The number of followers per page, defaults to 20. - **source_type** (int) - Optional - The sorting type, defaults to 1. (1: comprehensive sort, 2: unclear meaning, returns no data). - **max_counts** (float) - Optional - The maximum number of followers, defaults to infinity. ### Response #### Success Response (200) - **UserFollowerFilter** (AsyncGenerator) - A filter for follower user data, with methods like _to_raw, _to_dict, and _to_list. ### Response Example ```json { "UserFollowerFilter": "" } ``` ### Notes - When `source_type` is 1, `max_time` must be set to specify the time range. - Using custom time ranges (`min_time`, `max_time`) is not recommended for data completeness, only for specific time-period data retrieval. - The `count` parameter should not be set too high; the default value is recommended. - `offset` parameter is invalid when `source_type` is 1 or 2. - When `source_type` is 2, no data is returned. ``` -------------------------------- ### Create Video Download Record - TikTok API Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/tiktok/overview.md Asynchronously creates or retrieves video data and sets up a video directory. Requires video data, an `AsyncVideoDB` instance, and an optional list of fields to ignore. ```python async def video_get_add(self, aweme_data: dict, db: AsyncVideoDB, ignore_fields: list = None): """获取或创建作品数据,同时创建作品目录 :param aweme_data: 作品数据字典 :param db: 作品数据库 :param ignore_fields: 忽略的字段列表 :return: """ return await self.fetch(GET_VIDEO_ADD_URL, aweme_data=aweme_data, db=db, ignore_fields=ignore_fields) ``` -------------------------------- ### Get User Home Feed Data Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves the recommended works for a specified user's homepage. ```APIDOC ## GET /user/feed ### Description Asynchronously retrieves the recommended works for a specified user's homepage. ### Method GET ### Endpoint /user/feed ### Parameters #### Query Parameters - **sec_user_id** (str) - Required - The user ID. - **max_cursor** (int) - Optional - The page number, defaults to 0. - **page_counts** (int) - Optional - The number of pages, defaults to 20. - **max_counts** (int) - Optional - The maximum number of items, defaults to None. ### Response #### Success Response (200) - **UserPostFilter** (AsyncGenerator) - A filter for recommended works data, with methods like _to_raw, _to_dict, and _to_list. ### Response Example ```json { "UserPostFilter": "" } ``` ``` -------------------------------- ### GET /api/douyin/user/likes Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronously retrieves a list of videos liked by a specified user. Requires the likes list to be public. ```APIDOC ## GET /api/douyin/user/likes ### Description Asynchronously retrieves a list of videos liked by a specified user. Requires the likes list to be public. ### Method GET ### Endpoint /api/douyin/user/likes ### Parameters #### Query Parameters - **sec_user_id** (str) - Required - User ID - **max_cursor** (int) - Optional - Cursor for pagination, defaults to 0 - **page_counts** (int) - Optional - Number of items per page, defaults to 20 - **max_counts** (int) - Optional - Maximum total items to retrieve, defaults to None ### Request Example ``` GET /api/douyin/user/likes?sec_user_id=some_user_id&max_cursor=100 ``` ### Response #### Success Response (200) - **UserPostFilter** (AsyncGenerator) - Filter for liked video data, includes _to_raw, _to_dict, _to_list methods. #### Response Example ```json { "UserPostFilter": "" } ``` ``` -------------------------------- ### Create Video Download Record Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Asynchronous method to get or create video data and simultaneously create a video directory. Can ignore specified fields. ```python async def video_get_add(aweme_data: dict, db: AsyncVideoDB, ignore_fields: list = None): """获取或创建作品数据,同时创建作品目录 :param aweme_data: 作品数据字典 :param db: 作品数据库 :param ignore_fields: 忽略的字段列表 :return: 无 """ # ... (implementation details omitted for brevity) pass ``` -------------------------------- ### Get Weibo Post ID Source: https://github.com/johnserf-seed/f2/blob/main/README.en.md Extracts the Weibo post ID from a URL. Useful for referencing specific posts. ```python from f2.apps.weibo.utils import weibo_id url = "weibo_post_url" post_id = weibo_id(url) print(f"Weibo ID: {post_id}") ``` -------------------------------- ### Client Configuration Management Source: https://github.com/johnserf-seed/f2/blob/main/docs/guide/apps/douyin/overview.md Class method for managing client configuration. ```APIDOC ## POST /api/utils/client-config ### Description Class method for managing client configuration. ### Method POST ### Endpoint /api/utils/client-config ### Parameters #### Request Body - **config_key** (str) - Required - The key of the configuration to manage. - **config_value** (Any) - Optional - The value to set for the configuration key. ### Response #### Success Response (200) - **config_value** (Any) - The value of the configuration setting. #### Response Example ```json { "config_value": "some_configuration_value" } ``` ```