# 123 WebDAV
## 安装
你可以通过 [pypi](https://pypi.org/project/p123dav/) 安装
```console
pip install -U p123dav
```
## 用法
### 作为模块
```python
from p123client import P123Client
from p123dav import P123FileSystemProvider
from wsgidav.wsgidav_app import WsgiDAVApp
from wsgidav.server.server_cli import SUPPORTED_SERVERS
config = {
"server": "cheroot",
"host": "0.0.0.0",
"port": 8123,
"mount_path": "",
"simple_dc": {"user_mapping": {"*": True}},
"provider_mapping": {"/": P123FileSystemProvider(
username="",
password="",
ttl=10,
refresh=False,
)},
}
app = WsgiDAVApp(config)
server = config["server"]
handler = SUPPORTED_SERVERS.get(server)
if not handler:
raise RuntimeError(
"Unsupported server type {!r} (expected {!r})".format(
server, "', '".join(SUPPORTED_SERVERS.keys())
)
)
handler(app, config, server)
```
### 作为命令
```console
usage: p123dav [-h] [-u USERNAME] [-p PASSWORD] [-t TOKEN] [--ttl TTL] [-r]
[-H HOST] [-P PORT] [-v] [-l]
📺 123 WebDav 🎬
options:
-h, --help show this help message and exit
-u USERNAME, --username USERNAME
登录账号,手机号或邮箱,或者 client_id
-p PASSWORD, --password PASSWORD
登录密码,或者 client_secret
-t TOKEN, --token TOKEN
123 网盘的 access_token
--ttl TTL 文件列表缓存时间,默认值:10,单位:秒
-r, --refresh 更新文件列表缓存时,强制更新全部,如果不指定此参数,则会用一种预写的算法,尽量少地拉取数据以更新缓存(但可能出错)
-H HOST, --host HOST ip 或 hostname,默认值:'0.0.0.0'
-P PORT, --port PORT 端口号,默认值:8123
-v, --version 输出版本号
-l, --license 输出授权信息
✈️ 关于登录
登录时,可以选择其一:
1. 账号和密码,或 client_id 和 client_secret(-u/--user 和 -p/--password)
2. 访问令牌(-t/--token)
🔨 关于使用
当你访问首页时,会罗列你的网盘入口(路径为 /0)和所有分享入口(路径为 /分享码 或 /分享码:密码)
http://localhost:8123/
当你访问这个链接路径之下,就是你自己网盘的文件
http://localhost:8123/0/网盘下的路径
当你访问这个路径之下,则是这个分享下的文件
http://localhost:8123/分享码/分享下的路径
http://localhost:8123/分享码:密码/分享下的路径
你可以随意指定一个有效的分享码和路径,而不用管这个分享是不是你自己创建的
```
Raw data
{
"_id": null,
"home_page": "https://github.com/ChenyangGao/p123client/tree/main/modules/p123dav",
"name": "p123dav",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.12",
"maintainer_email": null,
"keywords": "python-123, webdav",
"author": "ChenyangGao",
"author_email": "wosiwujm@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8a/50/cc631589269c538fca845a217f0f16393e1d69406c7dff56469360113d23/p123dav-0.0.3.1.tar.gz",
"platform": null,
"description": "# 123 WebDAV\n\n## \u5b89\u88c5\n\n\u4f60\u53ef\u4ee5\u901a\u8fc7 [pypi](https://pypi.org/project/p123dav/) \u5b89\u88c5\n\n```console\npip install -U p123dav\n```\n\n## \u7528\u6cd5\n\n### \u4f5c\u4e3a\u6a21\u5757\n\n```python\nfrom p123client import P123Client\nfrom p123dav import P123FileSystemProvider\nfrom wsgidav.wsgidav_app import WsgiDAVApp\nfrom wsgidav.server.server_cli import SUPPORTED_SERVERS\n\nconfig = {\n \"server\": \"cheroot\", \n \"host\": \"0.0.0.0\", \n \"port\": 8123, \n \"mount_path\": \"\", \n \"simple_dc\": {\"user_mapping\": {\"*\": True}}, \n \"provider_mapping\": {\"/\": P123FileSystemProvider(\n username=\"\", \n password=\"\", \n ttl=10, \n refresh=False, \n )}, \n}\napp = WsgiDAVApp(config)\nserver = config[\"server\"]\nhandler = SUPPORTED_SERVERS.get(server)\nif not handler:\n raise RuntimeError(\n \"Unsupported server type {!r} (expected {!r})\".format(\n server, \"', '\".join(SUPPORTED_SERVERS.keys())\n )\n )\nhandler(app, config, server)\n```\n\n### \u4f5c\u4e3a\u547d\u4ee4\n\n```console\nusage: p123dav [-h] [-u USERNAME] [-p PASSWORD] [-t TOKEN] [--ttl TTL] [-r]\n [-H HOST] [-P PORT] [-v] [-l]\n\n \ud83d\udcfa 123 WebDav \ud83c\udfac\n\noptions:\n -h, --help show this help message and exit\n -u USERNAME, --username USERNAME\n \u767b\u5f55\u8d26\u53f7\uff0c\u624b\u673a\u53f7\u6216\u90ae\u7bb1\uff0c\u6216\u8005 client_id\n -p PASSWORD, --password PASSWORD\n \u767b\u5f55\u5bc6\u7801\uff0c\u6216\u8005 client_secret\n -t TOKEN, --token TOKEN\n 123 \u7f51\u76d8\u7684 access_token\n --ttl TTL \u6587\u4ef6\u5217\u8868\u7f13\u5b58\u65f6\u95f4\uff0c\u9ed8\u8ba4\u503c\uff1a10\uff0c\u5355\u4f4d\uff1a\u79d2\n -r, --refresh \u66f4\u65b0\u6587\u4ef6\u5217\u8868\u7f13\u5b58\u65f6\uff0c\u5f3a\u5236\u66f4\u65b0\u5168\u90e8\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\u6b64\u53c2\u6570\uff0c\u5219\u4f1a\u7528\u4e00\u79cd\u9884\u5199\u7684\u7b97\u6cd5\uff0c\u5c3d\u91cf\u5c11\u5730\u62c9\u53d6\u6570\u636e\u4ee5\u66f4\u65b0\u7f13\u5b58\uff08\u4f46\u53ef\u80fd\u51fa\u9519\uff09\n -H HOST, --host HOST ip \u6216 hostname\uff0c\u9ed8\u8ba4\u503c\uff1a'0.0.0.0'\n -P PORT, --port PORT \u7aef\u53e3\u53f7\uff0c\u9ed8\u8ba4\u503c\uff1a8123\n -v, --version \u8f93\u51fa\u7248\u672c\u53f7\n -l, --license \u8f93\u51fa\u6388\u6743\u4fe1\u606f\n\n\u2708\ufe0f \u5173\u4e8e\u767b\u5f55\n\n\u767b\u5f55\u65f6\uff0c\u53ef\u4ee5\u9009\u62e9\u5176\u4e00\uff1a\n 1. \u8d26\u53f7\u548c\u5bc6\u7801\uff0c\u6216 client_id \u548c client_secret\uff08-u/--user \u548c -p/--password\uff09\n 2. \u8bbf\u95ee\u4ee4\u724c\uff08-t/--token\uff09\n\n\ud83d\udd28 \u5173\u4e8e\u4f7f\u7528\n\n\u5f53\u4f60\u8bbf\u95ee\u9996\u9875\u65f6\uff0c\u4f1a\u7f57\u5217\u4f60\u7684\u7f51\u76d8\u5165\u53e3\uff08\u8def\u5f84\u4e3a /0\uff09\u548c\u6240\u6709\u5206\u4eab\u5165\u53e3\uff08\u8def\u5f84\u4e3a /\u5206\u4eab\u7801 \u6216 /\u5206\u4eab\u7801:\u5bc6\u7801\uff09\n\n http://localhost:8123/\n\n\u5f53\u4f60\u8bbf\u95ee\u8fd9\u4e2a\u94fe\u63a5\u8def\u5f84\u4e4b\u4e0b\uff0c\u5c31\u662f\u4f60\u81ea\u5df1\u7f51\u76d8\u7684\u6587\u4ef6\n\n http://localhost:8123/0/\u7f51\u76d8\u4e0b\u7684\u8def\u5f84\n\n\u5f53\u4f60\u8bbf\u95ee\u8fd9\u4e2a\u8def\u5f84\u4e4b\u4e0b\uff0c\u5219\u662f\u8fd9\u4e2a\u5206\u4eab\u4e0b\u7684\u6587\u4ef6\n\n http://localhost:8123/\u5206\u4eab\u7801/\u5206\u4eab\u4e0b\u7684\u8def\u5f84\n http://localhost:8123/\u5206\u4eab\u7801:\u5bc6\u7801/\u5206\u4eab\u4e0b\u7684\u8def\u5f84\n\n\u4f60\u53ef\u4ee5\u968f\u610f\u6307\u5b9a\u4e00\u4e2a\u6709\u6548\u7684\u5206\u4eab\u7801\u548c\u8def\u5f84\uff0c\u800c\u4e0d\u7528\u7ba1\u8fd9\u4e2a\u5206\u4eab\u662f\u4e0d\u662f\u4f60\u81ea\u5df1\u521b\u5efa\u7684\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "123 WebDAV",
"version": "0.0.3.1",
"project_urls": {
"Homepage": "https://github.com/ChenyangGao/p123client/tree/main/modules/p123dav",
"Repository": "https://github.com/ChenyangGao/p123client/tree/main/modules/p123dav"
},
"split_keywords": [
"python-123",
" webdav"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "36474d065f26d9b767dbbc18c0099a91190437f4d936a5caaacffb9e2a8287b1",
"md5": "029f0ed2ac5b89713f35e342edc400d7",
"sha256": "eeb734d749d8546b7b39a8e7d46085d6e5a3cf4d46ebac7f02c99ea7c8cb28be"
},
"downloads": -1,
"filename": "p123dav-0.0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "029f0ed2ac5b89713f35e342edc400d7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.12",
"size": 44580,
"upload_time": "2025-07-25T13:09:20",
"upload_time_iso_8601": "2025-07-25T13:09:20.851264Z",
"url": "https://files.pythonhosted.org/packages/36/47/4d065f26d9b767dbbc18c0099a91190437f4d936a5caaacffb9e2a8287b1/p123dav-0.0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8a50cc631589269c538fca845a217f0f16393e1d69406c7dff56469360113d23",
"md5": "c6f88e28c14c5330d035ac1a354fba5a",
"sha256": "ff2b31fff2f63f0218147e6f47a62dcb424d272a1f49af3cb887c309eec94920"
},
"downloads": -1,
"filename": "p123dav-0.0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "c6f88e28c14c5330d035ac1a354fba5a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.12",
"size": 30611,
"upload_time": "2025-07-25T13:09:21",
"upload_time_iso_8601": "2025-07-25T13:09:21.987989Z",
"url": "https://files.pythonhosted.org/packages/8a/50/cc631589269c538fca845a217f0f16393e1d69406c7dff56469360113d23/p123dav-0.0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-25 13:09:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ChenyangGao",
"github_project": "p123client",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "p123dav"
}