### Installation Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115imghost/readme.md Install the p115imghost client using pip. ```APIDOC ## Installation You can install from [pypi](https://pypi.org/project/p115imghost/) ```console pip install -U p115imghost ``` ``` -------------------------------- ### Query File by Path Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115tiny302/readme.md Examples for querying a file using its path. Paths can start with '/' or '>' and can be specified directly or with the 'path' parameter. ```http http://localhost:8000/电影/Novembre.2022.FRENCH.2160p.BluRay.DV.HEVC.DTS-HD.MA.5.1.mkv ``` ```http http://localhost:8000//电影/Novembre.2022.FRENCH.2160p.BluRay.DV.HEVC.DTS-HD.MA.5.1.mkv ``` ```http http://localhost:8000?/电影/Novembre.2022.FRENCH.2160p.BluRay.DV.HEVC.DTS-HD.MA.5.1.mkv ``` ```http http://localhost:8000?path=/电影/Novembre.2022.FRENCH.2160p.BluRay.DV.HEVC.DTS-HD.MA.5.1.mkv ``` -------------------------------- ### Install p115open302 Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115open302/readme.md Install the p115open302 library using pip. Ensure you have the latest version. ```console pip install -U p115open302 ``` -------------------------------- ### Install p115client from GitHub Source: https://github.com/chenyanggao/p115client/blob/main/docs/index.md Install the latest development version of the p115client library directly from its GitHub repository. ```console pip install -U git+https://github.com/ChenyangGao/p115client@main ``` -------------------------------- ### P115FileSystem Operations Source: https://context7.com/chenyanggao/p115client/llms.txt Provides examples of using the `P115FileSystem` class for high-level file system operations, mimicking Python's `os` and `pathlib`. Includes getting the current directory, listing contents, changing directories, and creating new directories. ```python from p115client import P115Client from p115client.fs import P115FileSystem client = P115Client.from_path() fs = P115FileSystem(client) # Get current working directory print(fs.getcwd()) # Output: "/" print(fs.getcid()) # Output: 0 (root directory ID) # List directory contents files = fs.listdir() # Returns list of names attrs = fs.listdir_attr() # Returns list of attribute dicts paths = fs.listdir_path() # Returns list of P115Path objects # Navigate directories fs.chdir("/Movies/2024") print(fs.getcwd()) # Output: "/Movies/2024" # Get file/directory attributes attr = fs.get_attr("/path/to/file.mp4") print(f"Name: {attr['name']}, Size: {attr['size']}, ID: {attr['id']}") # Create directories fs.mkdir(0, "new_folder") # Create in root fs.makedirs("/path/to/nested/folder", exist_ok=True) ``` -------------------------------- ### Install p115client from PyPI Source: https://github.com/chenyanggao/p115client/blob/main/docs/index.md Install the latest stable version of the p115client library from the Python Package Index. ```console pip install -U p115client ``` -------------------------------- ### Install Dependencies Source: https://github.com/chenyanggao/p115client/blob/main/docs/example/03.推送aria2下载.md Install the necessary Python packages for using ariarpc and p115client. ```console pip install -U ariarpc p115client ``` -------------------------------- ### Install p115oss Client Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115oss/readme.md Install the p115oss client library using pip. This command ensures you have the latest version for uploading to 115 OSS. ```console pip install -U p115oss ``` -------------------------------- ### Install p115imghost Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115imghost/readme.md Install the p115imghost package using pip. This command ensures you have the latest version. ```console pip install -U p115imghost ``` -------------------------------- ### Install p115pickcode Package Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115pickcode/readme.md Install the p115pickcode library using pip. This command ensures you have the latest version. ```bash pip install -U p115pickcode ``` -------------------------------- ### GET /api/1.0/web/1.0/life/recent_browse Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves the user's recent browsing history. Supports pagination with start and limit parameters. ```APIDOC ## GET /api/1.0/web/1.0/life/recent_browse ### Description Retrieves the user's recent browsing history. ### Method GET ### Endpoint https://life.115.com/api/1.0/web/1.0/life/recent_browse ### Query Parameters - **start** (int) - Optional - The starting index for the results. Defaults to 0. - **limit** (int) - Optional - The maximum number of results to return. Defaults to 1000. ### Response #### Success Response (200) - **data** (dict) - Contains the list of recent browse records. - **state** (str) - Indicates the status of the request. #### Response Example ```json { "data": [ { "title": "Example File", "time": "2023-10-27 10:00:00", "type": "file" } ], "state": "SUCCESS" } ``` ``` -------------------------------- ### Upload Sample Init Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/const.md Initializes a sample upload. ```APIDOC ## POST /3.0/sampleinitupload.php ### Description Initializes a sample upload. ### Method POST ### Endpoint https://uplb.115.com/3.0/sampleinitupload.php ### Parameters #### Query Parameters - **param1** (type) - Required/Optional - Description ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example { "example": "response body" } ``` -------------------------------- ### Initialize P115Client Instance Source: https://context7.com/chenyanggao/p115client/llms.txt Demonstrates different ways to initialize the P115Client, including using cookies strings, cookie files, and default paths. Shows how to make both synchronous and asynchronous API calls. ```python from p115client import P115Client from pathlib import Path # Initialize with cookies string cookies = "UID=...;CID=...;SEID=..." client = P115Client(cookies) # Initialize from cookies file with auto re-login client = P115Client( Path("~/115-cookies.txt").expanduser(), check_for_relogin=True ) # Simplified initialization from default path client = P115Client.from_path() # All API methods support both sync and async modes # Synchronous call response = client.fs_files({"cid": 0}) # Asynchronous call response = await client.fs_files({"cid": 0}, async_=True) ``` -------------------------------- ### Recommended Initialization for Open API Usage Source: https://github.com/chenyanggao/p115client/blob/main/docs/index.md This setup initializes both a standard P115Client with cookie support and an open API client, which is automatically authorized. ```python from p115client import P115Client, P115OpenClient from pathlib import Path client = P115Client(Path("~/115-cookies.txt").expanduser(), check_for_relogin=True) client_open = client.login_another_open() ``` -------------------------------- ### GET /open/folder/get_info - Get Folder/File Info Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves detailed information about a specific file or directory. Supports both GET and POST methods. Requires either `file_id` or `path` to be provided. ```APIDOC ## GET /open/folder/get_info ### Description Retrieves detailed information about a specific file or directory. Supports both GET and POST methods. Requires either `file_id` or `path` to be provided. ### Method GET, POST ### Endpoint https://proapi.115.com/open/folder/get_info ### Parameters #### Query Parameters - **file_id** (int | str) - Required - The ID of the file or directory. - **path** (str) - Required - The path to the file or directory. Separators can be '/' or '>'. Must start with a separator. ### Request Example ```json { "file_id": "12345" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the file or directory information. - **cid** (int) - Directory ID. - **name** (str) - Name of the file or directory. - **size** (int) - Size of the file in bytes. - **ico** (str) - Icon identifier. - **type** (int) - Type of the item (e.g., 0 for folder, 1 for file). - **last_modify** (str) - Last modification timestamp. - **create_time** (str) - Creation timestamp. - **is_dir** (bool) - True if it's a directory, false otherwise. - **is_file** (bool) - True if it's a file, false otherwise. #### Response Example ```json { "code": 200, "message": "OK", "data": { "cid": 12345, "name": "example_file.txt", "size": 1024, "ico": "txt", "type": 1, "last_modify": "2023-10-27 10:00:00", "create_time": "2023-10-26 09:00:00", "is_dir": false, "is_file": true } } ``` ``` -------------------------------- ### Directory Creation Source: https://github.com/chenyanggao/p115client/blob/main/modules/@p115/readme.md Demonstrates how to create empty directories using the `mkdir` and `makedirs` methods. ```APIDOC ## POST /api/fs/mkdir ### Description Creates an empty directory. ### Method POST ### Endpoint `/api/fs/mkdir` ### Parameters #### Request Body - **name** (string) - Required - The name of the directory to create. Can include escaped slashes (`\/`). - **parent_id** (integer) - Optional - The ID of the parent directory. Defaults to root (0). ### Request Example ```json { "name": "new_directory" } ``` ### Response #### Success Response (200) - **name** (string) - The name of the created directory. - **is_directory** (boolean) - True, indicating it's a directory. - **id** (integer) - The unique ID of the created directory. - **parent_id** (integer) - The ID of the parent directory. - **path** (string) - The full path to the created directory. #### Response Example ```json { "name": "test", "is_directory": true, "size": null, "id": 2793068685969850230, "parent_id": 0, "sha1": null, "etime": "2023-12-19T16:48:53", "utime": "2023-12-19T16:48:53", "ptime": "2023-12-19T16:48:53", "open_time": "1970-01-01T08:00:00", "time": "2023-12-19T16:48:53", "pick_code": "fd4lr0lh0cqf525y6u", "star": false, "lastest_update": "2023-12-19T16:48:53.571815", "path": "/test" } ``` ## POST /api/fs/makedirs ### Description Creates multiple levels of empty directories. ### Method POST ### Endpoint `/api/fs/makedirs` ### Parameters #### Request Body - **path** (string) - Required - The path for the directories to create. Slashes should be escaped (`\/`). - **exist_ok** (boolean) - Optional - If True, no error is raised if the directory already exists. Defaults to False. ### Request Example ```json { "path": "parent\/child\/grandchild", "exist_ok": true } ``` ### Response #### Success Response (200) - **name** (string) - The name of the last directory created in the path. - **is_directory** (boolean) - True, indicating it's a directory. - **id** (integer) - The unique ID of the last directory created. - **parent_id** (integer) - The ID of the parent directory of the last created directory. - **path** (string) - The full path to the last created directory. #### Response Example ```json { "name": "test/4", "is_directory": true, "size": null, "id": 2793068979713736021, "parent_id": 2793068974135311685, "sha1": null, "etime": "2023-12-19T16:49:28", "utime": "2023-12-19T16:49:28", "ptime": "2023-12-19T16:49:28", "open_time": "1970-01-01T08:00:00", "time": "2023-12-19T16:49:28", "pick_code": "fd4lr0njs9jm3d5y6u", "star": false, "lastest_update": "2023-12-19T16:49:28.578537" } ``` ``` -------------------------------- ### GET /files/file - Get File or Directory Skim Info Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves skim information (brief details) for files or directories. Supports both GET and POST methods for potentially large numbers of IDs. ```APIDOC ## GET/POST /files/file ### Description Gets the skim information (brief details) of files or directories. ### Method GET or POST ### Endpoint https://webapi.115.com/files/file ### Parameters #### Query Parameters (for GET) - **payload** (int | str | Iterable[int | str] | dict) - Required - The ID(s) of the file or directory. Multiple IDs can be comma-separated. - **method** (str) - Optional - Defaults to 'GET'. Specify 'POST' if querying a large number of IDs. #### Request Body (for POST) - **payload** (int | str | Iterable[int | str] | dict) - Required - The ID(s) of the file or directory. Multiple IDs can be comma-separated. ### Request Example (GET) ```json { "payload": "id1,id2,id3" } ``` ### Request Example (POST) ```json { "payload": "id1,id2,id3" } ``` ### Response #### Success Response (200) - **data** (dict) - Contains skim information for the requested files or directories. - **info** (str) - A message indicating the status. - **error_code** (int) - The error code, 0 for success. #### Response Example ```json { "data": [ { "id": "12345", "name": "example.txt", "size": 1024 } ], "info": "success", "error_code": 0 } ``` ``` -------------------------------- ### Recommended P115Client Initialization Source: https://github.com/chenyanggao/p115client/blob/main/docs/index.md This is the recommended way to initialize P115Client, loading cookies from a file and enabling automatic relogin checks. ```python from p115client import P115Client from pathlib import Path client = P115Client(Path("~/115-cookies.txt").expanduser(), check_for_relogin=True) ``` -------------------------------- ### Install p115rsacipher Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115rsacipher/readme.md Install the p115rsacipher package using pip. This command ensures you have the latest version. ```console pip install -U p115rsacipher ``` -------------------------------- ### Initialize P115Client with Simplified Path Loading Source: https://github.com/chenyanggao/p115client/blob/main/readme.md Use the convenient `from_path()` class method to initialize P115Client, automatically loading cookies from the default file path. ```python client = P115Client.from_path() ``` -------------------------------- ### Install p115image302 Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115image302/readme.md Install the p115image302 package using pip. This command ensures you have the latest version. ```console pip install -U p115image302 ``` -------------------------------- ### Initialize P115OpenClient with Refresh Token Source: https://github.com/chenyanggao/p115client/blob/main/docs/index.md Create a P115OpenClient instance directly using a provided refresh token. This token is typically used once. ```python from p115client import P115OpenClient client_open = P115OpenClient(refresh_token) ``` -------------------------------- ### Install p115cipher Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115cipher/readme.md Install the p115cipher package using pip. This command ensures you have the latest version. ```console pip install -U p115cipher ``` -------------------------------- ### upload_file_sample_init Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Initializes the upload process for files on the web. This is a wrapper around upload_sample_init and does not support instant uploads. ```APIDOC ## POST /api/upload_file_sample_init ### Description Initializes the upload process for files on the web. This is a wrapper around upload_sample_init and does not support instant uploads. ### Method POST ### Endpoint /api/upload_file_sample_init ### Parameters #### Query Parameters - **filename** (str) - Optional - Filename, defaults to a new uuid4 string representation. - **dirname** (str) - Optional - Save directory, a relative path within the pid directory, defaults to the pid directory itself. - **pid** (int | str) - Optional - The ID or pickcode of the directory to upload the file to, or a specified target (format: f"U_{aid}_{pid}"). - **base_url** (str | Callable[[], str]) - Optional - The base URL for the API, defaults to 'https://uplb.115.com'. - **async** (Literal[False]) - Optional - Whether to perform the operation asynchronously. Defaults to False. - **request_kwargs** - Optional - Additional request parameters. ### Response #### Success Response (200) - **dict** - A dictionary containing the response from the API. ``` -------------------------------- ### GET /files/desc - Get File/Directory Description Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves the description (remark) for a specified file or directory. ```APIDOC ## GET /files/desc ### Description Retrieves the description (remark) for a specified file or directory. ### Method GET ### Endpoint https://webapi.115.com/files/desc ### Parameters #### Query Parameters - **payload** (str | dict) - Required - The identifier for the file or directory. - **file_id** (int | str) - Required - The ID of the file or directory. - **field** (str) - Optional - Specifies the field to retrieve. Example value: "pass". - **compat** (0 | 1) - Optional - Compatibility flag. Defaults to 1. - **new_html** (0 | 1) - Optional - Flag for new HTML format. Defaults to system default. ### Request Example ```json { "file_id": "abcde", "field": "pass" } ``` ### Response #### Success Response (200) - **data** (dict) - Contains the description information. - **id** (str) - The ID of the file or directory. - **title** (str) - The name of the file or directory. - **desc** (str) - The description of the file or directory. #### Response Example ```json { "code": 0, "data": { "id": "abcde", "title": "My Document.txt", "desc": "This is an important document." } } ``` ``` -------------------------------- ### Create Directories Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Create multiple directories at once. Specify the parent directory ID and the names of the directories to create. ```python client.fs_makedirs_app(payload={'name': 'new_dir1', 'next_dir': {'name': 'new_dir2'}}, pid=1, app='chrome') ``` -------------------------------- ### Initialize P115Client with Cookies Source: https://github.com/chenyanggao/p115client/blob/main/docs/index.md Create an instance of P115Client using a string of cookies. If cookies are not provided, a QR code scan will be required for login. ```python cookies = "UID=...; CID=...; SEID=...; KID=..." client = P115Client(cookies) ``` -------------------------------- ### Display Help Message Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115tiny302/readme.md Run the command with -h to display the help message and available options. ```console $ p115tiny302 -h ``` -------------------------------- ### GET /files/music - Get Music Information Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves information about a music file, primarily its download link. ```APIDOC ## GET /files/music ### Description Retrieves information about a music file, primarily its download link. ### Method GET ### Endpoint https://webapi.115.com/files/music ### Parameters #### Query Parameters - **pickcode** (str) - Required - The pick code of the music file. - **topic_id** (int) - Optional - The topic ID. - **music_id** (int) - Optional - The music ID. - **download** (int) - Optional - A flag to indicate download, value may vary. #### Request Body - **payload** (str | dict) - Not typically used for GET requests, but may contain additional parameters if applicable. - **base_url** (str | Callable[[], str]) - Optional - The base URL for the API. Defaults to 'https://webapi.115.com'. - **async_** (Literal[False]) - Optional - Specifies synchronous operation. Defaults to False. ### Request Example ```json { "pickcode": "abcdef12345" } ``` ### Response #### Success Response (200) - **download_url** (str) - The download URL for the music file. #### Response Example ```json { "download_url": "https://example.com/music.mp3" } ``` ``` -------------------------------- ### Setup BlackSheep Application Source: https://github.com/chenyanggao/p115client/blob/main/docs/example/02.302后台服务.md Sets up a BlackSheep application with a router and a cache for URLs. The application shows error details only in debug mode. ```python from binascii import crc32 from urllib.parse import parse_qsl, urlsplit from blacksheep import json, redirect, Application, Request from cachedict import TLRUDict app = Application(show_error_details=__debug__) cached_urls = TLRUDict(1024) ``` -------------------------------- ### Get Single File Download URL Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Encapsulates the process of getting a single file's download URL. ```APIDOC ## GET /api/download/url ### Description Retrieves the download URL for a file using its pick code. This is a wrapper around `download_url_info`. ### Method GET ### Endpoint [Endpoint details not explicitly provided in the source, but implied to be a GET request for a single URL] ### Parameters #### Query Parameters - **pickcode** (str) - Required - The pick code for the file. - **strict** (bool) - Optional - If True, raises `IsADirectoryError` if the target is a directory. Defaults to True. - **user_agent** (str | None) - Optional - Sets the 'user-agent' request header. - **async** (bool) - Optional - Whether to perform the operation asynchronously. Defaults to False. ### Response #### Success Response (200) - **P115URL** - An object containing the download URL and related information. #### Response Example ```json { "url": "https://example.com/download/file?t=...&u=...&c=...&f=..." } ``` ### NOTE Query parameters in the direct link: - `t`: Expiration timestamp - `u`: User ID - `c`: Allowed concurrent opens (0 for unlimited) - `f`: Request header requirement: - Empty: No requirement - 1: Requires `user-agent` (same as request) - 3: Requires `user-agent` (same as request) and `Cookie` (from `Set-Cookie` response header during the request) ``` -------------------------------- ### GET /android/music/musicplay - Get Music Information (App) Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves information about a music file within the application context. ```APIDOC ## GET /android/music/musicplay ### Description Retrieves information about a music file within the application context. ### Method GET ### Endpoint https://proapi.115.com/android/music/musicplay ### Parameters #### Query Parameters - **pickcode** (str) - Required - The pick code of the music file. - **music_id** (int) - Optional - The music ID. - **topic_id** (int) - Optional - The topic ID. #### Request Body - **payload** (str | dict) - Not typically used for GET requests, but may contain additional parameters if applicable. - **app** (str) - Optional - The application context. Defaults to 'android'. - **base_url** (str | Callable[[], str]) - Optional - The base URL for the API. Defaults to 'https://proapi.115.com'. - **async_** (Literal[False]) - Optional - Specifies synchronous operation. Defaults to False. ### Request Example ```json { "pickcode": "ghijkl67890" } ``` ### Response #### Success Response (200) - **info** (dict) - Contains information about the music file. #### Response Example ```json { "info": { "name": "Song Title", "artist": "Artist Name" } } ``` ### Notes This endpoint may return some information even if the file format is incorrect or too large (over 200 MB). If the target is a directory, the information returned will be sparse. ``` -------------------------------- ### Usage Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115imghost/readme.md Command-line usage for the p115imghost tool. ```APIDOC ## Usage ```console $ p115imghost -h usage: p115imghost [-h] [-b BASE_URL] [-c COOKIES] [-cp COOKIES_PATH] [-v] [-l] [file ...] 115 图床(每张图片不大于 50 MB) positional arguments: file 图片路径或链接 options: -h, --help show this help message and exit -b, --base-url BASE_URL 图片的基地址 - 如果不传,上传到 U_4_-1,获取永久的图片链接 - 如果传 "", 上传到 U_4_-1,获取一次性的图片链接,有效时间 1 小时 - 其它(例如 "http://localhost:8000?image=1"),上传到 U_12_0,视为 302 代理,会把 user_id、id、pickcode、sha1 和 size 作为查询参数拼接到其后 -c, --cookies COOKIES cookies 字符串,优先级高于 -cp/--cookies-path -cp, --cookies-path COOKIES_PATH cookies 文件保存路径,默认为当前工作目录下的 115-cookies.txt -v, --version 输出版本号 -l, --license 输出授权信 ``` ``` -------------------------------- ### POST /open/upload/init Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Initializes an upload task, potentially enabling rapid upload (file transfer in seconds). ```APIDOC ## POST /open/upload/init ### Description Initializes an upload task, potentially enabling rapid upload (file transfer in seconds). ### Method POST ### Endpoint https://proapi.115.com/open/upload/init ### Parameters #### Request Body - **file_name** (str) - Required - The name of the file. - **fileid** (str) - Required - The SHA1 hash of the file. - **file_size** (int) - Required - The size of the file in bytes. - **target** (str) - Required - The upload target, formatted as `U_{aid}_{pid}`. - **topupload** (int) - Optional, defaults to 0 - Upload scheduling file type scheduling mark. - 0: Single file upload task identifier, 1 separate file upload record. - 1: Directory task scheduling's first sub-file upload request identifier, 1 directory upload record. - 2: Subsequent sub-file upload requests in a directory task scheduling that are not recorded as separate uploads. - -1: No such parameter. - **sign_key** (str) - Optional, defaults to "" - The range of the file to read for secondary verification. - **sign_val** (str) - Optional, defaults to "" - The signature value for secondary verification. ### Request Example ```json { "file_name": "example.txt", "fileid": "a1b2c3d4e5f678901234567890abcdef12345678", "file_size": 1024, "target": "U_1_0", "topupload": 0, "sign_key": "", "sign_val": "" } ``` ### Response #### Success Response (200) - **upload_id** (str) - The ID of the upload task. - **host** (str) - The host for uploading. - **path** (str) - The path for uploading. #### Response Example ```json { "code": 200, "message": "OK", "data": { "upload_id": "upload_task_123", "host": "upload.115.com", "path": "/upload/path" } } ``` ``` -------------------------------- ### GET /files/move_progress - Get Move Task Progress Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves the progress status of a file or directory move operation. ```APIDOC ## GET /files/move_progress ### Description Retrieves the progress status of a file or directory move operation. ### Method GET ### Endpoint https://webapi.115.com/files/move_progress ### Parameters #### Query Parameters - **move_proid** (str) - Required - The ID of the move task. #### Request Body - **payload** (int | str | dict) - Not typically used for GET requests, but may contain task-related information if applicable. - **base_url** (str | Callable[[], str]) - Optional - The base URL for the API. Defaults to 'https://webapi.115.com'. - **async_** (Literal[False]) - Optional - Specifies synchronous operation. Defaults to False. ### Request Example ```json { "move_proid": "task123" } ``` ### Response #### Success Response (200) - **progress** (str) - The current progress of the move task. #### Response Example ```json { "progress": "50%" } ``` ``` -------------------------------- ### Get File/Directory Stat with stat Source: https://github.com/chenyanggao/p115client/blob/main/modules/@p115/readme.md Use the `stat` method to get partial file or directory information, analogous to `os.stat`. ```python >>> fs.stat("Love.Death.and.Robots.S01E01.Sonnies.Edge.1080p.NF.WEB-DL.DDP5.1.x264-NTG.mkv") os.stat_result(st_mode=33279, st_ino=2576931481393823441, st_dev=2576931481024724685, st_nlink=1, st_uid=306576686, st_gid=1, st_size=924544482, st_atime=1688662230.0, st_mtime=1677210171.0, st_ctime=1677210171.0) ``` -------------------------------- ### Install p115tiny302 Package Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115tiny302/readme.md Install the p115tiny302 package and its dependencies using pip. Ensure you are using the latest version with the -U flag. ```bash pip install -U p115tiny302 ``` -------------------------------- ### Initialize and Connect P115 Client Source: https://github.com/chenyanggao/p115client/blob/main/docs/example/04.拉取websocket消息.md This snippet demonstrates how to initialize the P115Client with a cookie file path and then establish a connection to the WebSocket. The Path object is expanded to handle user home directory shortcuts. ```python if __name__ == "__main__": from pathlib import Path client = P115Client(Path("~/115-cookies.txt").expanduser()) connect_to_websocket(client) ``` -------------------------------- ### Initialize P115OpenClient with AppID Source: https://github.com/chenyanggao/p115client/blob/main/docs/index.md Initialize P115OpenClient by providing the AppID. This will typically prompt for a QR code scan to authorize the application. ```python from p115client import P115OpenClient client_open = P115OpenClient(app_id) ``` -------------------------------- ### GET /android/files/desc - Get File/Directory Description (App) Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves the description (remark) for a specified file or directory using the app API. ```APIDOC ## GET /android/files/desc ### Description Retrieves the description (remark) for a specified file or directory using the app API. ### Method GET ### Endpoint https://proapi.115.com/android/files/desc ### Parameters #### Query Parameters - **payload** (str | dict) - Required - The identifier for the file or directory. - **file_id** (int | str) - Required - The ID of the file or directory. - **field** (str) - Optional - Specifies the field to retrieve. Example value: "pass". - **compat** (0 | 1) - Optional - Compatibility flag. Defaults to 1. - **new_html** (0 | 1) - Optional - Flag for new HTML format. Defaults to system default. ### Request Example ```json { "file_id": "fghij", "field": "pass" } ``` ### Response #### Success Response (200) - **data** (dict) - Contains the description information. - **id** (str) - The ID of the file or directory. - **title** (str) - The name of the file or directory. - **desc** (str) - The description of the file or directory. #### Response Example ```json { "code": 0, "data": { "id": "fghij", "title": "Another File.docx", "desc": "Contains project details." } } ``` ``` -------------------------------- ### View p115imghost Help Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115imghost/readme.md Display the help message for the p115imghost command-line tool to understand its usage and available options. ```console $ p115imghost -h ``` -------------------------------- ### GET /files/get_info - Get File or Directory Info Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves basic information about a specific file or directory. This endpoint is part of the webapi service. ```APIDOC ## GET /files/get_info ### Description Gets the basic information of a file or directory. ### Method GET ### Endpoint https://webapi.115.com/files/get_info ### Parameters #### Query Parameters - **payload** (int | str | dict) - Required - The ID of the file or directory. Cannot be 0. Only one ID can be provided; if multiple are given, only the first one is used. ### Request Example ```json { "payload": "your_file_id" } ``` ### Response #### Success Response (200) - **data** (dict) - Contains detailed information about the file or directory. - **info** (str) - A message indicating the status. - **error_code** (int) - The error code, 0 for success. #### Response Example ```json { "data": { "id": "12345", "name": "example.txt", "size": 1024, "type": 0, "last_modified": "2023-10-27T10:00:00Z" }, "info": "success", "error_code": 0 } ``` ``` -------------------------------- ### Display Help Message Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115dav/readme.md Use the -h or --help flag to display the help message and a list of all available command-line options. ```console $ p115dav -h ``` -------------------------------- ### Custom HTTP Requests with p115client Source: https://context7.com/chenyanggao/p115client/llms.txt Demonstrates using custom HTTP request backends like httpx and aiohttp with the P115Client. Also shows how to make direct requests with custom parameters and headers. ```python from p115client import P115Client client = P115Client.from_path() # Using httpx for requests from httpx_request import request resp = client.fs_files( {"cid": 0}, request=request # Use httpx backend ) ``` ```python # Using aiohttp for async requests from aiohttp_client_request import request resp = await client.fs_files( {"cid": 0}, async_=True, request=request # Use aiohttp backend ) ``` ```python # Direct request method with custom parameters resp = client.request( url="https://webapi.115.com/files", method="GET", params={"cid": 0, "show_dir": 1}, headers={"User-Agent": "Custom/1.0"} ) ``` -------------------------------- ### GET /android/2.0/ufile/export_dir - Get Export Directory Status Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves the completion status of an exported directory tree. This endpoint is part of the proapi service. ```APIDOC ## GET /android/2.0/ufile/export_dir ### Description Gets the completion status of the export directory tree. ### Method GET ### Endpoint https://proapi.115.com/android/2.0/ufile/export_dir ### Parameters #### Query Parameters - **payload** (int | str | dict) - Required - The task ID for the export operation. - **app** (str) - Optional - Defaults to 'android'. Specifies the application context. ### Request Example ```json { "payload": "your_export_id" } ``` ### Response #### Success Response (200) - **data** (dict) - Contains the status information of the export directory. - **info** (str) - A message indicating the status. - **error_code** (int) - The error code, 0 for success. #### Response Example ```json { "data": { "status": 1, "percent": 100, "error_code": 0 }, "info": "success", "error_code": 0 } ``` ``` -------------------------------- ### Initialize Open API Client with Authorization Source: https://github.com/chenyanggao/p115client/blob/main/docs/index.md Obtain an authorized P115OpenClient instance by calling login_another_open on an existing P115Client instance. This process includes automatic QR code scanning and authorization. ```python app_id = <开放接口应用的 AppID> # 可以不传 app_id,因为有一个默认值 client_open = client.login_another_open(app_id) ``` -------------------------------- ### Install p115updatedb Package Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115updatedb/readme.md Install or update the p115updatedb package using pip. This command ensures you have the latest version for exporting 115 Cloud Drive data. ```console pip install -U p115updatedb ``` -------------------------------- ### GET /files - Get File List and Basic Info Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves a list of files and their basic information within a directory. Supports various hints for traversal and searching. ```APIDOC ## GET /files ### Description Gets the list of files and basic information in a directory. ### Method GET ### Endpoint https://webapi.115.com/files ### Parameters #### Query Parameters - **payload** (int | str | dict) - Optional - Defaults to 0. Can specify directory ID or other criteria. - **cid** (int) - Optional - Category ID. If not specified or invalid, defaults to 0. - **star** (int) - Optional - Filter by starred status (1 for starred). - **suffix** (str) - Optional - Filter by file suffix. - **type** (int) - Optional - Filter by file type. - **show_dir** (int) - Optional - Whether to show directories (0 or 1). - **cur** (int) - Optional - Pagination cursor, defaults to 0. - **natsort** (int) - Optional - Natural sorting (1 for enabled). ### Request Example ```json { "cid": 123, "show_dir": 1 } ``` ### Response #### Success Response (200) - **data** (dict) - Contains the list of files and directory information. - **info** (str) - A message indicating the status. - **error_code** (int) - The error code, 0 for success. #### Response Example ```json { "data": { "list": [ { "id": "12345", "name": "document.pdf", "size": 2048, "type": 0 } ], "count": 10 }, "info": "success", "error_code": 0 } ``` ``` -------------------------------- ### Custom Request Example Source: https://github.com/chenyanggao/p115client/blob/main/readme.md Shows how to create a custom client by subclassing P115Client and defining new methods like 'foo' and 'bar'. These methods utilize the base class's 'request' method for API interactions, supporting both synchronous and asynchronous calls. ```python from collections.abc import Coroutine from typing import overload, Any, Literal from p115client import P115Client class MyCustom115Client(P115Client): @overload def foo( self, payload: dict, /, async_: Literal[False] = False, **request_kwargs, ) -> dict: ... @overload def foo( self, payload: dict, /, async_: Literal[True], **request_kwargs, ) -> Coroutine[Any, Any, dict]: ... def foo( self, payload: dict, /, async_: bool = False, **request_kwargs, ) -> dict | Coroutine[Any, Any, dict]: api = "https://webapi.115.com/foo" return self.request( api, method="GET", params=payload, async_=async_, **request_kwargs, ) @overload def bar( self, payload: dict, /, async_: Literal[False] = False, **request_kwargs, ) -> dict: ... @overload def bar( self, payload: dict, /, async_: Literal[True], **request_kwargs, ) -> Coroutine[Any, Any, dict]: ... def bar( self, payload: dict, /, async_: bool = False, **request_kwargs, ) -> dict | Coroutine[Any, Any, dict]: api = "https://webapi.115.com/bar" return self.request( api, method="POST", data=payload, async_=async_, **request_kwargs, ) ``` -------------------------------- ### GET /share/snap - Get Shared Content List Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves a list of files and subdirectories within a shared directory. This endpoint can be used for both logged-in and non-logged-in users, with specific behavior noted for logged-in users viewing their own shares. ```APIDOC ## GET /share/snap ### Description Gets a list of files and subdirectories within a specified shared directory, including detailed information. ### Method GET ### Endpoint https://webapi.115.com/share/snap ### Parameters #### Query Parameters - **share_code** (str) - Required - The share code. - **receive_code** (str) - Optional - The password for accessing the shared item. If logged in and viewing own share, this might not be needed. - **cid** (int | str) - Optional - The directory ID. Defaults to 0 (root). - **limit** (int) - Optional - The maximum number of items to return. Defaults to 32. - **offset** (int) - Optional - The starting offset for pagination. Defaults to 0. - **asc** (0 | 1) - Optional - Whether to sort in ascending order. Defaults to system default. - **o** (str) - Optional - The field to sort by. Options: "file_name", "file_size", "user_ptime". Defaults to system default. ### Response #### Success Response (200) - **data** (dict) - Contains the list of files and directories. #### Response Example ```json { "code": 0, "message": "Success", "data": { "list": [ { "id": "123", "name": "example.txt", "size": 1024, "type": "file", "ptime": 1678886400 } ], "count": 1 } } ``` ``` -------------------------------- ### Use p115open302 as a Module Source: https://github.com/chenyanggao/p115client/blob/main/modules/p115open302/readme.md Initialize and run the 115 backend application. Requires authentication cookies or a refresh token. The application is configured to run on 0.0.0.0:8000. ```python from p115client import P115Client from p115open302 import make_application from uvicorn import run # 授权登录 cookies = "UID=...; CID=...; SEID=...; KID=..." app_id = 100195125 client = P115Client(cookies, ensure_cookies=True, check_for_relogin=True) client.login_another_open(replace=True) # 或者直接用 refresh_token refresh_token = "..." client = P115Client("", heck_for_relogin=True) client.refresh_token = refresh_token client.refresh_access_token() run( make_application(client, debug=True), host="0.0.0.0", port=8000, proxy_headers=True, server_header=False, forwarded_allow_ips="*", timeout_graceful_shutdown=1, ) ``` -------------------------------- ### GET /open/user/info Source: https://github.com/chenyanggao/p115client/blob/main/docs/reference/module/client.md Retrieves user information. ```APIDOC ## GET /open/user/info ### Description Retrieves user information. ### Method GET ### Endpoint https://proapi.115.com/open/user/info ### Parameters ### Request Example ### Response #### Success Response (200) - **user_id** (string) - The user's unique identifier. - **user_name** (string) - The user's name. - **vip_status** (integer) - The user's VIP status. #### Response Example ```json { "code": 200, "message": "OK", "data": { "user_id": "user123", "user_name": "TestUser", "vip_status": 1 } } ``` ```