devart-dl 4.0.0__tar.gz → 4.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. {devart_dl-4.0.0 → devart_dl-4.0.2}/.env.example +2 -2
  2. devart_dl-4.0.2/PKG-INFO +94 -0
  3. devart_dl-4.0.2/README.md +60 -0
  4. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/__init__.py +1 -1
  5. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/api.py +14 -4
  6. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/cli.py +5 -3
  7. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/official_api.py +2 -0
  8. devart_dl-4.0.2/devart_dl.egg-info/PKG-INFO +94 -0
  9. {devart_dl-4.0.0 → devart_dl-4.0.2}/pyproject.toml +1 -2
  10. {devart_dl-4.0.0 → devart_dl-4.0.2}/tests/test_cli.py +5 -0
  11. devart_dl-4.0.0/PKG-INFO +0 -289
  12. devart_dl-4.0.0/README.md +0 -255
  13. devart_dl-4.0.0/devart_dl.egg-info/PKG-INFO +0 -289
  14. {devart_dl-4.0.0 → devart_dl-4.0.2}/LICENSE +0 -0
  15. {devart_dl-4.0.0 → devart_dl-4.0.2}/MANIFEST.in +0 -0
  16. {devart_dl-4.0.0 → devart_dl-4.0.2}/README_EN.md +0 -0
  17. {devart_dl-4.0.0 → devart_dl-4.0.2}/bin/devart-dl +0 -0
  18. {devart_dl-4.0.0 → devart_dl-4.0.2}/bin/install.sh +0 -0
  19. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/archive.py +0 -0
  20. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/auth.py +0 -0
  21. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/download.py +0 -0
  22. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/errors.py +0 -0
  23. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/http.py +0 -0
  24. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/manager.py +0 -0
  25. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/models.py +0 -0
  26. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/oauth.py +0 -0
  27. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/path.py +0 -0
  28. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/provider.py +0 -0
  29. {devart_dl-4.0.0 → devart_dl-4.0.2}/da_downloader/targets.py +0 -0
  30. {devart_dl-4.0.0 → devart_dl-4.0.2}/devart_dl.egg-info/SOURCES.txt +0 -0
  31. {devart_dl-4.0.0 → devart_dl-4.0.2}/devart_dl.egg-info/dependency_links.txt +0 -0
  32. {devart_dl-4.0.0 → devart_dl-4.0.2}/devart_dl.egg-info/entry_points.txt +0 -0
  33. {devart_dl-4.0.0 → devart_dl-4.0.2}/devart_dl.egg-info/requires.txt +0 -0
  34. {devart_dl-4.0.0 → devart_dl-4.0.2}/devart_dl.egg-info/top_level.txt +0 -0
  35. {devart_dl-4.0.0 → devart_dl-4.0.2}/requirements.txt +0 -0
  36. {devart_dl-4.0.0 → devart_dl-4.0.2}/setup.cfg +0 -0
  37. {devart_dl-4.0.0 → devart_dl-4.0.2}/setup.py +0 -0
  38. {devart_dl-4.0.0 → devart_dl-4.0.2}/tests/test_api.py +0 -0
  39. {devart_dl-4.0.0 → devart_dl-4.0.2}/tests/test_archive.py +0 -0
  40. {devart_dl-4.0.0 → devart_dl-4.0.2}/tests/test_download.py +0 -0
  41. {devart_dl-4.0.0 → devart_dl-4.0.2}/tests/test_http_downloader.py +0 -0
  42. {devart_dl-4.0.0 → devart_dl-4.0.2}/tests/test_manager.py +0 -0
  43. {devart_dl-4.0.0 → devart_dl-4.0.2}/tests/test_official_provider.py +0 -0
  44. {devart_dl-4.0.0 → devart_dl-4.0.2}/tests/test_path.py +0 -0
  45. {devart_dl-4.0.0 → devart_dl-4.0.2}/tests/test_provider.py +0 -0
  46. {devart_dl-4.0.0 → devart_dl-4.0.2}/tests/test_targets.py +0 -0
@@ -1,5 +1,5 @@
1
1
  # DeviantArt Downloader - 环境变量示例
2
- # 复制此文件为 .env 并填入你的配置(仅当你通过环境变量传递配置时使用)
2
+ # 本工具不会自动读取 .env;请把需要的值设置到终端或系统环境变量中。
3
3
 
4
4
  # ============================================
5
5
  # 认证配置 Authentication
@@ -34,6 +34,6 @@
34
34
  # ============================================
35
35
  # ⚠️ 重要:
36
36
  # 1. 不要将包含真实凭据的 .env 文件上传到 Git
37
- # 2. 不要分享你的 client_id / Cookie / OAuth 令牌
37
+ # 2. client_id 不是秘密,但不要分享 Cookie 或 OAuth 令牌
38
38
  # 3. Cookie 过期后需重新登录(推荐改用 OAuth,自动续期)
39
39
  # 4. 使用代理时注意代理服务器的安全性
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.4
2
+ Name: devart-dl
3
+ Version: 4.0.2
4
+ Summary: 专业的 DeviantArt 作品批量下载工具 - Professional DeviantArt batch downloader with anti-ban features
5
+ Author: DeviantArt Downloader Team
6
+ License-Expression: MIT
7
+ Keywords: deviantart,downloader,scraper,art,gallery,batch-download,async,cli,anti-ban
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: End Users/Desktop
10
+ Classifier: Topic :: Internet :: WWW/HTTP
11
+ Classifier: Topic :: Multimedia :: Graphics
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Environment :: Console
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: requests>=2.31.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.4.3; extra == "dev"
26
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
27
+ Requires-Dist: pytest-mock>=3.12.0; extra == "dev"
28
+ Requires-Dist: black>=23.12.0; extra == "dev"
29
+ Requires-Dist: mypy>=1.7.1; extra == "dev"
30
+ Requires-Dist: ruff>=0.1.7; extra == "dev"
31
+ Requires-Dist: pre-commit>=3.6.0; extra == "dev"
32
+ Requires-Dist: ipython>=8.18.0; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # DeviantArt Downloader
36
+
37
+ 一个可靠、聚焦的 DeviantArt 下载 / 归档命令行工具。
38
+
39
+ [English Documentation](README_EN.md) · [📖 完整文档](https://redtidev1918.github.io/deviantart-downloader/) · [更新日志](CHANGELOG.md)
40
+
41
+ [![CI](https://github.com/redtidev1918/deviantart-downloader/actions/workflows/ci.yml/badge.svg)](https://github.com/redtidev1918/deviantart-downloader/actions/workflows/ci.yml)
42
+ [![PyPI](https://img.shields.io/pypi/v/devart-dl.svg)](https://pypi.org/project/devart-dl/)
43
+ [![Python](https://img.shields.io/pypi/pyversions/devart-dl.svg)](https://pypi.org/project/devart-dl/)
44
+ [![Downloads](https://img.shields.io/pypi/dm/devart-dl.svg)](https://pypi.org/project/devart-dl/)
45
+ [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
46
+ [![Docs](https://img.shields.io/badge/Docs-文档站点-6366f1?style=flat-square)](https://redtidev1918.github.io/deviantart-downloader/)
47
+
48
+ ## 快速开始
49
+
50
+ 需要 Python 3.10 或更高版本。
51
+
52
+ ```bash
53
+ python -m pip install -U devart-dl
54
+
55
+ # 单张作品(也支持 fav.me 短链、裸 artwork id)
56
+ devart-dl https://www.deviantart.com/username/art/title-123456
57
+
58
+ # 画廊 / 作者全集
59
+ devart-dl https://www.deviantart.com/username/gallery
60
+
61
+ # 收藏夹 / 标签
62
+ devart-dl https://www.deviantart.com/username/favourites
63
+ devart-dl https://www.deviantart.com/tag/landscape
64
+ ```
65
+
66
+ 首次下载前建议使用 OAuth 登录:
67
+
68
+ ```bash
69
+ devart-dl login oauth --client-id 你的_PUBLIC_CLIENT_ID
70
+ devart-dl whoami
71
+ ```
72
+
73
+ 不会注册 OAuth 应用也可以使用 Cookie。完整图文式步骤见 **[登录与认证教程](https://redtidev1918.github.io/deviantart-downloader/#/LOGIN)**。
74
+
75
+ > 普通用户无需手动下载 GitHub Release 里的 `.whl`、`.tar.gz` 或 Source code,运行上面的 `pip install` 即可。文件区别和 SHA256 校验方法见[完整文档](https://redtidev1918.github.io/deviantart-downloader/#/?id=github-release-%e9%87%8c%e7%9a%84%e6%96%87%e4%bb%b6%e6%98%af%e4%bb%80%e4%b9%88)。
76
+
77
+ ## 核心特性
78
+
79
+ - **官方 API(OAuth)优先**:登录一次即可下载原图,无需导出 Cookie,也无需防封延时。
80
+ - **URL 优先**:直接粘贴作品 / 画廊 / 收藏夹 / 标签链接即可下载。
81
+ - **下载可靠**:HTTP Range 断点续传、自动重试、429 退避、原子落盘。
82
+ - **下载档案**:`--archive` 用 SQLite 记住已下载,跨会话自动跳过。
83
+ - **路径模板 + 元数据 sidecar**:`--directory`/`--filename` 模板与 `--write-info-json`。
84
+ - **代理与降级**:支持 `--proxy`;未登录 OAuth 时自动回退 Cookie。
85
+
86
+ 完整的安装、登录认证、下载模式、配置参数、命令速查、Python 调用与常见问题,请看 **📖 文档站点**:
87
+
88
+ 👉 https://redtidev1918.github.io/deviantart-downloader/
89
+
90
+ ## 许可证与免责声明
91
+
92
+ 本项目基于 [MIT License](LICENSE) 开源。
93
+
94
+ **注意**:本工具仅供个人学习和研究使用。使用者应遵守 DeviantArt 服务条款及版权规定,请勿用于商业用途或大规模抓取导致服务器过载。作者不对任何滥用后果负责。
@@ -0,0 +1,60 @@
1
+ # DeviantArt Downloader
2
+
3
+ 一个可靠、聚焦的 DeviantArt 下载 / 归档命令行工具。
4
+
5
+ [English Documentation](README_EN.md) · [📖 完整文档](https://redtidev1918.github.io/deviantart-downloader/) · [更新日志](CHANGELOG.md)
6
+
7
+ [![CI](https://github.com/redtidev1918/deviantart-downloader/actions/workflows/ci.yml/badge.svg)](https://github.com/redtidev1918/deviantart-downloader/actions/workflows/ci.yml)
8
+ [![PyPI](https://img.shields.io/pypi/v/devart-dl.svg)](https://pypi.org/project/devart-dl/)
9
+ [![Python](https://img.shields.io/pypi/pyversions/devart-dl.svg)](https://pypi.org/project/devart-dl/)
10
+ [![Downloads](https://img.shields.io/pypi/dm/devart-dl.svg)](https://pypi.org/project/devart-dl/)
11
+ [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
12
+ [![Docs](https://img.shields.io/badge/Docs-文档站点-6366f1?style=flat-square)](https://redtidev1918.github.io/deviantart-downloader/)
13
+
14
+ ## 快速开始
15
+
16
+ 需要 Python 3.10 或更高版本。
17
+
18
+ ```bash
19
+ python -m pip install -U devart-dl
20
+
21
+ # 单张作品(也支持 fav.me 短链、裸 artwork id)
22
+ devart-dl https://www.deviantart.com/username/art/title-123456
23
+
24
+ # 画廊 / 作者全集
25
+ devart-dl https://www.deviantart.com/username/gallery
26
+
27
+ # 收藏夹 / 标签
28
+ devart-dl https://www.deviantart.com/username/favourites
29
+ devart-dl https://www.deviantart.com/tag/landscape
30
+ ```
31
+
32
+ 首次下载前建议使用 OAuth 登录:
33
+
34
+ ```bash
35
+ devart-dl login oauth --client-id 你的_PUBLIC_CLIENT_ID
36
+ devart-dl whoami
37
+ ```
38
+
39
+ 不会注册 OAuth 应用也可以使用 Cookie。完整图文式步骤见 **[登录与认证教程](https://redtidev1918.github.io/deviantart-downloader/#/LOGIN)**。
40
+
41
+ > 普通用户无需手动下载 GitHub Release 里的 `.whl`、`.tar.gz` 或 Source code,运行上面的 `pip install` 即可。文件区别和 SHA256 校验方法见[完整文档](https://redtidev1918.github.io/deviantart-downloader/#/?id=github-release-%e9%87%8c%e7%9a%84%e6%96%87%e4%bb%b6%e6%98%af%e4%bb%80%e4%b9%88)。
42
+
43
+ ## 核心特性
44
+
45
+ - **官方 API(OAuth)优先**:登录一次即可下载原图,无需导出 Cookie,也无需防封延时。
46
+ - **URL 优先**:直接粘贴作品 / 画廊 / 收藏夹 / 标签链接即可下载。
47
+ - **下载可靠**:HTTP Range 断点续传、自动重试、429 退避、原子落盘。
48
+ - **下载档案**:`--archive` 用 SQLite 记住已下载,跨会话自动跳过。
49
+ - **路径模板 + 元数据 sidecar**:`--directory`/`--filename` 模板与 `--write-info-json`。
50
+ - **代理与降级**:支持 `--proxy`;未登录 OAuth 时自动回退 Cookie。
51
+
52
+ 完整的安装、登录认证、下载模式、配置参数、命令速查、Python 调用与常见问题,请看 **📖 文档站点**:
53
+
54
+ 👉 https://redtidev1918.github.io/deviantart-downloader/
55
+
56
+ ## 许可证与免责声明
57
+
58
+ 本项目基于 [MIT License](LICENSE) 开源。
59
+
60
+ **注意**:本工具仅供个人学习和研究使用。使用者应遵守 DeviantArt 服务条款及版权规定,请勿用于商业用途或大规模抓取导致服务器过载。作者不对任何滥用后果负责。
@@ -1,6 +1,6 @@
1
1
  """DeviantArt Downloader — a reliable, focused downloader and archival CLI."""
2
2
 
3
- __version__ = "4.0.0"
3
+ __version__ = "4.0.1"
4
4
  __author__ = "DeviantArt Downloader Team"
5
5
 
6
6
  from .download import Downloader, build_downloader, normalize_quality
@@ -324,14 +324,24 @@ class DeviantArtAPI:
324
324
  None,
325
325
  )
326
326
 
327
- if not full_view:
328
- logger.warning("Full view not found, using base URI")
327
+ # 现代 DA 的 baseUri 本身就是原始文件(以图片/视频扩展名结尾):
328
+ # 直接 baseUri + token 取原图即可。别拿它拼 fullview 的 /v1/fit|fill
329
+ # 变体模板——那些 URL 即使带 token 也可能返回 400/404(2026-09 实测)。
330
+ def _is_file_url(u: str) -> bool:
331
+ path = str(u).split('?', 1)[0].rstrip('/')
332
+ return bool(re.search(r'\.(?:png|jpe?g|gif|webp|mp4|m4v)$', path, re.I))
333
+
334
+ if _is_file_url(base_uri):
329
335
  url = base_uri
330
- elif full_view.get('b'):
336
+ elif full_view and full_view.get('b'):
331
337
  url = str(full_view['b'])
332
- elif 'c' in full_view:
338
+ elif full_view and 'c' in full_view:
333
339
  url = base_uri + str(full_view['c']).replace('<prettyName>', pretty_name)
340
+ elif full_view:
341
+ logger.warning("Full view has no usable URL, falling back to base URI")
342
+ url = base_uri
334
343
  else:
344
+ logger.warning("Full view not found, using base URI")
335
345
  url = base_uri
336
346
 
337
347
  if token:
@@ -50,7 +50,7 @@ Options (URL-first and subcommands):
50
50
  --filename TEMPLATE filename template (default "{id}_{title}.{ext}")
51
51
  --quality NAME original|best|preview (default best)
52
52
  --archive PATH SQLite archive to skip already-downloaded
53
- --cookies PATH cookies file (falls back to saved session)
53
+ --cookies PATH cookie file (otherwise env/session/cookies.txt)
54
54
  --write-info-json write a metadata .json next to each file
55
55
  --overwrite replace existing files
56
56
  --proxy URL --timeout S --retries N --limit N
@@ -72,7 +72,7 @@ def _version() -> str:
72
72
  try:
73
73
  return version("devart-dl")
74
74
  except PackageNotFoundError:
75
- return "4.0.0"
75
+ return "4.0.1"
76
76
 
77
77
 
78
78
  def _looks_like_target(value: str) -> bool:
@@ -93,7 +93,9 @@ def _load_cookies(cookies_path: Optional[str]) -> str:
93
93
  return path.read_text(encoding="utf-8").strip()
94
94
  print(f"warning: cookies file not found: {cookies_path}", file=sys.stderr)
95
95
  return ""
96
- return str(AuthManager().load_cookies() or "")
96
+ return os.environ.get("DEVIANTART_COOKIES", "").strip() or str(
97
+ AuthManager().load_cookies() or ""
98
+ )
97
99
 
98
100
 
99
101
  def _execute(
@@ -222,6 +222,8 @@ def resolve_uuid(
222
222
 
223
223
  query = {
224
224
  "deviationid": identifier,
225
+ # 该接口自 2026 年起把 type 列为必填枚举(art/journal),缺失返回 400。
226
+ "type": "art",
225
227
  "include_session": "false",
226
228
  "csrf_token": csrf,
227
229
  "mature_content": True,
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.4
2
+ Name: devart-dl
3
+ Version: 4.0.2
4
+ Summary: 专业的 DeviantArt 作品批量下载工具 - Professional DeviantArt batch downloader with anti-ban features
5
+ Author: DeviantArt Downloader Team
6
+ License-Expression: MIT
7
+ Keywords: deviantart,downloader,scraper,art,gallery,batch-download,async,cli,anti-ban
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: End Users/Desktop
10
+ Classifier: Topic :: Internet :: WWW/HTTP
11
+ Classifier: Topic :: Multimedia :: Graphics
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Environment :: Console
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: requests>=2.31.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.4.3; extra == "dev"
26
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
27
+ Requires-Dist: pytest-mock>=3.12.0; extra == "dev"
28
+ Requires-Dist: black>=23.12.0; extra == "dev"
29
+ Requires-Dist: mypy>=1.7.1; extra == "dev"
30
+ Requires-Dist: ruff>=0.1.7; extra == "dev"
31
+ Requires-Dist: pre-commit>=3.6.0; extra == "dev"
32
+ Requires-Dist: ipython>=8.18.0; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # DeviantArt Downloader
36
+
37
+ 一个可靠、聚焦的 DeviantArt 下载 / 归档命令行工具。
38
+
39
+ [English Documentation](README_EN.md) · [📖 完整文档](https://redtidev1918.github.io/deviantart-downloader/) · [更新日志](CHANGELOG.md)
40
+
41
+ [![CI](https://github.com/redtidev1918/deviantart-downloader/actions/workflows/ci.yml/badge.svg)](https://github.com/redtidev1918/deviantart-downloader/actions/workflows/ci.yml)
42
+ [![PyPI](https://img.shields.io/pypi/v/devart-dl.svg)](https://pypi.org/project/devart-dl/)
43
+ [![Python](https://img.shields.io/pypi/pyversions/devart-dl.svg)](https://pypi.org/project/devart-dl/)
44
+ [![Downloads](https://img.shields.io/pypi/dm/devart-dl.svg)](https://pypi.org/project/devart-dl/)
45
+ [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
46
+ [![Docs](https://img.shields.io/badge/Docs-文档站点-6366f1?style=flat-square)](https://redtidev1918.github.io/deviantart-downloader/)
47
+
48
+ ## 快速开始
49
+
50
+ 需要 Python 3.10 或更高版本。
51
+
52
+ ```bash
53
+ python -m pip install -U devart-dl
54
+
55
+ # 单张作品(也支持 fav.me 短链、裸 artwork id)
56
+ devart-dl https://www.deviantart.com/username/art/title-123456
57
+
58
+ # 画廊 / 作者全集
59
+ devart-dl https://www.deviantart.com/username/gallery
60
+
61
+ # 收藏夹 / 标签
62
+ devart-dl https://www.deviantart.com/username/favourites
63
+ devart-dl https://www.deviantart.com/tag/landscape
64
+ ```
65
+
66
+ 首次下载前建议使用 OAuth 登录:
67
+
68
+ ```bash
69
+ devart-dl login oauth --client-id 你的_PUBLIC_CLIENT_ID
70
+ devart-dl whoami
71
+ ```
72
+
73
+ 不会注册 OAuth 应用也可以使用 Cookie。完整图文式步骤见 **[登录与认证教程](https://redtidev1918.github.io/deviantart-downloader/#/LOGIN)**。
74
+
75
+ > 普通用户无需手动下载 GitHub Release 里的 `.whl`、`.tar.gz` 或 Source code,运行上面的 `pip install` 即可。文件区别和 SHA256 校验方法见[完整文档](https://redtidev1918.github.io/deviantart-downloader/#/?id=github-release-%e9%87%8c%e7%9a%84%e6%96%87%e4%bb%b6%e6%98%af%e4%bb%80%e4%b9%88)。
76
+
77
+ ## 核心特性
78
+
79
+ - **官方 API(OAuth)优先**:登录一次即可下载原图,无需导出 Cookie,也无需防封延时。
80
+ - **URL 优先**:直接粘贴作品 / 画廊 / 收藏夹 / 标签链接即可下载。
81
+ - **下载可靠**:HTTP Range 断点续传、自动重试、429 退避、原子落盘。
82
+ - **下载档案**:`--archive` 用 SQLite 记住已下载,跨会话自动跳过。
83
+ - **路径模板 + 元数据 sidecar**:`--directory`/`--filename` 模板与 `--write-info-json`。
84
+ - **代理与降级**:支持 `--proxy`;未登录 OAuth 时自动回退 Cookie。
85
+
86
+ 完整的安装、登录认证、下载模式、配置参数、命令速查、Python 调用与常见问题,请看 **📖 文档站点**:
87
+
88
+ 👉 https://redtidev1918.github.io/deviantart-downloader/
89
+
90
+ ## 许可证与免责声明
91
+
92
+ 本项目基于 [MIT License](LICENSE) 开源。
93
+
94
+ **注意**:本工具仅供个人学习和研究使用。使用者应遵守 DeviantArt 服务条款及版权规定,请勿用于商业用途或大规模抓取导致服务器过载。作者不对任何滥用后果负责。
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "devart-dl"
7
- version = "4.0.0"
7
+ version = "4.0.2"
8
8
  description = "专业的 DeviantArt 作品批量下载工具 - Professional DeviantArt batch downloader with anti-ban features"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -145,7 +145,6 @@ target-version = "py310"
145
145
 
146
146
  [tool.ruff.lint]
147
147
  # Enforced policy: high-signal checks only (real bugs), matching CI.
148
- # Style rules can be added per-directory once the legacy debt is paid.
149
148
  select = [
150
149
  "E9", # runtime errors (syntax error, undefined name, unused bind)
151
150
  "F", # pyflakes
@@ -65,6 +65,11 @@ def test_oauth_login_requires_client_id(monkeypatch, capsys) -> None:
65
65
  assert "client-id" in capsys.readouterr().err
66
66
 
67
67
 
68
+ def test_load_cookies_from_environment(monkeypatch) -> None:
69
+ monkeypatch.setenv("DEVIANTART_COOKIES", " auth=token; auth_secure=secret ")
70
+ assert cli._load_cookies(None) == "auth=token; auth_secure=secret"
71
+
72
+
68
73
  def test_oauth_whoami_without_session(monkeypatch, capsys) -> None:
69
74
  monkeypatch.setattr(cli.OAuthSession, "from_store", classmethod(lambda cls: None))
70
75
  assert cli._oauth_whoami([]) == 1
devart_dl-4.0.0/PKG-INFO DELETED
@@ -1,289 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: devart-dl
3
- Version: 4.0.0
4
- Summary: 专业的 DeviantArt 作品批量下载工具 - Professional DeviantArt batch downloader with anti-ban features
5
- Author: DeviantArt Downloader Team
6
- License-Expression: MIT
7
- Keywords: deviantart,downloader,scraper,art,gallery,batch-download,async,cli,anti-ban
8
- Classifier: Development Status :: 4 - Beta
9
- Classifier: Intended Audience :: End Users/Desktop
10
- Classifier: Topic :: Internet :: WWW/HTTP
11
- Classifier: Topic :: Multimedia :: Graphics
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.10
14
- Classifier: Programming Language :: Python :: 3.11
15
- Classifier: Programming Language :: Python :: 3.12
16
- Classifier: Programming Language :: Python :: 3.13
17
- Classifier: Programming Language :: Python :: 3.14
18
- Classifier: Operating System :: OS Independent
19
- Classifier: Environment :: Console
20
- Requires-Python: >=3.10
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
- Requires-Dist: requests>=2.31.0
24
- Provides-Extra: dev
25
- Requires-Dist: pytest>=7.4.3; extra == "dev"
26
- Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
27
- Requires-Dist: pytest-mock>=3.12.0; extra == "dev"
28
- Requires-Dist: black>=23.12.0; extra == "dev"
29
- Requires-Dist: mypy>=1.7.1; extra == "dev"
30
- Requires-Dist: ruff>=0.1.7; extra == "dev"
31
- Requires-Dist: pre-commit>=3.6.0; extra == "dev"
32
- Requires-Dist: ipython>=8.18.0; extra == "dev"
33
- Dynamic: license-file
34
-
35
- # DeviantArt Downloader
36
-
37
- 一个可靠、聚焦的 DeviantArt 下载 / 归档命令行工具。
38
-
39
- [English Documentation](README_EN.md)
40
-
41
- [![CI](https://github.com/redtidev1918/deviantart-downloader/actions/workflows/ci.yml/badge.svg)](https://github.com/redtidev1918/deviantart-downloader/actions/workflows/ci.yml)
42
- [![PyPI](https://img.shields.io/pypi/v/devart-dl.svg)](https://pypi.org/project/devart-dl/)
43
- [![Python](https://img.shields.io/pypi/pyversions/devart-dl.svg)](https://pypi.org/project/devart-dl/)
44
- [![Downloads](https://img.shields.io/pypi/dm/devart-dl.svg)](https://pypi.org/project/devart-dl/)
45
- [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
46
-
47
- 更新日志见 [CHANGELOG.md](CHANGELOG.md)。
48
-
49
- ---
50
-
51
- ## 核心特性
52
-
53
- - **官方 API(OAuth)优先**:登录一次即可下载原图,无需导出 Cookie,也无需防封延时。
54
- - **URL 优先**:`devart-dl URL` 直接下载作品 / 画廊 / 收藏夹 / 标签 / fav.me 短链。
55
- - **下载可靠**:HTTP Range 断点续传、自动重试、429 退避、HTML/空文件校验、原子落盘。
56
- - **下载档案**:`--archive` 用 SQLite 记住已下载内容,跨会话自动跳过。
57
- - **路径模板**:`--directory` / `--filename` 支持 `{id}` `{title}` `{author}` `{published}` `{ext}` 等字段,并做路径安全清洗。
58
- - **元数据**:`--write-info-json` 在每个作品旁写一份 `.json` 元数据。
59
- - **代理与降级**:支持 `--proxy` 与代理环境变量;未登录 OAuth 时自动回退 Cookie。
60
-
61
- ---
62
-
63
- ## 快速开始
64
-
65
- ### 安装
66
-
67
- 需要 Python 3.10 或更高版本。
68
-
69
- ```bash
70
- pip install devart-dl
71
- ```
72
-
73
- ### 基本用法(URL 优先)
74
-
75
- ```bash
76
- # 单张作品(也支持 fav.me 短链、裸 artwork id)
77
- devart-dl https://www.deviantart.com/username/art/title-123456
78
-
79
- # 画廊 / 作者全集
80
- devart-dl https://www.deviantart.com/username/gallery
81
-
82
- # 收藏夹
83
- devart-dl https://www.deviantart.com/username/favourites
84
-
85
- # 标签
86
- devart-dl https://www.deviantart.com/tag/landscape
87
- ```
88
-
89
- ### 登录(推荐 OAuth)
90
-
91
- ```bash
92
- devart-dl login oauth --client-id 你的_PUBLIC_CLIENT_ID
93
- devart-dl whoami # 验证登录状态
94
- devart-dl logout # 撤销令牌
95
- ```
96
-
97
- 在 [deviantart.com/developers](https://www.deviantart.com/developers/) 注册一个 **Public** OAuth 应用,把 `http://127.0.0.1:8765/callback` 加入白名单。登录在浏览器中完成,无需把密码或 `client_secret` 交给 CLI。完整步骤见 [docs/LOGIN.md](docs/LOGIN.md)。
98
-
99
- ---
100
-
101
- ## 主要功能
102
-
103
- ### 下载模式
104
-
105
- URL 优先是最简单的方式;也保留显式子命令:
106
-
107
- ```bash
108
- # URL 优先
109
- devart-dl https://www.deviantart.com/username/art/title-123456
110
- devart-dl https://www.deviantart.com/username/gallery
111
- devart-dl https://www.deviantart.com/username/gallery/12345 # 指定文件夹
112
- devart-dl https://www.deviantart.com/username/favourites
113
- devart-dl https://www.deviantart.com/tag/landscape
114
-
115
- # 显式子命令
116
- devart-dl url https://www.deviantart.com/username/art/title-123456
117
- devart-dl artist username
118
- devart-dl gallery username [gallery_id]
119
- devart-dl search all "digital art"
120
- devart-dl fav username folder_id
121
- ```
122
-
123
- > 说明:显式子命令沿用旧用法、保持兼容;官方 API 暂不提供搜索端点,`search` 走 Cookie 回退路径。
124
-
125
- ### 登录认证
126
-
127
- **官方 API(OAuth)优先**,Cookie 作为降级方案。
128
-
129
- 1. **OAuth 登录(推荐)**
130
-
131
- ```bash
132
- devart-dl login oauth --client-id 你的_PUBLIC_CLIENT_ID
133
- ```
134
-
135
- - 注册 **Public** OAuth 应用,白名单精确加入 `http://127.0.0.1:8765/callback`。
136
- - 登录会在浏览器中完成,令牌保存到 `~/.deviantart_dl/oauth.json`(0600),自动续期。
137
- - 登录后下载命令自动走官方 API,原图来自官方下载接口。
138
-
139
- 2. **Cookie 登录(降级方案)**
140
-
141
- ```bash
142
- devart-dl login interactive # 交互式输入 Cookie
143
- ```
144
-
145
- 或创建 `cookies.txt`、设置 `DEVIANTART_COOKIES` 环境变量。会话保存于 `~/.deviantart_dl/session.json`。
146
-
147
- ### 下载档案与断点续传
148
-
149
- ```bash
150
- # 用 SQLite 记住已下载内容,下次运行自动跳过(跨会话、跨目录都有效)
151
- devart-dl https://www.deviantart.com/username/gallery --archive ~/.devart-dl/archive.sqlite
152
-
153
- # 中断的下载从 .part 文件续传,无需重新下载整个文件
154
- ```
155
-
156
- ### 文件名 / 目录模板
157
-
158
- ```bash
159
- devart-dl URL \
160
- --directory "{author}/{published:%Y-%m}" \
161
- --filename "{id}_{title}.{ext}"
162
- ```
163
-
164
- 可用字段:`{id}` `{title}` `{author}` `{username}` `{published}` `{filename}` `{ext}` `{index}`。路径会自动清洗(去除非法字符、Windows 保留名、`..` 穿越、超长名),确保结果在下载目录之内。
165
-
166
- ### 元数据 sidecar
167
-
168
- ```bash
169
- devart-dl URL --write-info-json
170
- # 生成 artwork.jpg 与 artwork.json(标题、作者、URL、发布时间、mature、媒体地址等)
171
- ```
172
-
173
- ---
174
-
175
- ## 配置参数
176
-
177
- ### 常用选项
178
-
179
- | 选项 | 说明 | 默认值 |
180
- |------|------|--------|
181
- | `-d, --dest` | 下载根目录 | `./Downloads` |
182
- | `--directory` | 目录模板(如 `{author}/{published:%Y}`) | `{author}` |
183
- | `--filename` | 文件名模板(如 `{id}_{title}.{ext}`) | `{id}_{title}.{ext}` |
184
- | `--quality` | `original`(原图,需登录)/ `best`(默认)/ `preview`;旧 `o/f/p` 仍可用 | `best` |
185
- | `--archive` | SQLite 下载档案路径 | 无 |
186
- | `--write-info-json` | 写元数据 sidecar | 关 |
187
- | `--overwrite` | 覆盖已存在文件 | 关(跳过) |
188
- | `--cookies` | Cookie 文件路径 | 自动加载会话 |
189
- | `--proxy` | 代理地址 | 自动读环境变量 |
190
- | `--timeout` | 请求超时(秒) | `60` |
191
- | `--retries` | 最大重试次数 | `3` |
192
- | `--limit` | 每页数量 | `24` |
193
-
194
- ### 输出选项
195
-
196
- - `-v, --verbose`:显示详细运行信息(含跳过原因)。
197
- - `-q, --quiet`:静默模式,仅显示汇总与错误。
198
-
199
- ---
200
-
201
- ## 常用命令速查
202
-
203
- ```bash
204
- # URL 优先(推荐)
205
- devart-dl <URL>
206
-
207
- # 显式子命令
208
- devart-dl url <artwork_url>
209
- devart-dl artist <username>
210
- devart-dl gallery <username> [gallery_id]
211
- devart-dl search <username|all> <query>
212
- devart-dl fav <username> <folder_id>
213
-
214
- # 登录 / 会话
215
- devart-dl login oauth --client-id <ID> # OAuth 登录(推荐)
216
- devart-dl login interactive # Cookie 登录(降级)
217
- devart-dl whoami # 查看登录状态
218
- devart-dl logout # 撤销令牌并清除本地会话
219
-
220
- # 其他
221
- devart-dl version
222
- ```
223
-
224
- ---
225
-
226
- ## 高级用法
227
-
228
- ### 代理设置
229
-
230
- ```bash
231
- # 命令行参数
232
- devart-dl URL --proxy http://127.0.0.1:7890
233
-
234
- # 环境变量(HTTP/HTTPS 代理)
235
- export HTTP_PROXY=http://127.0.0.1:7890
236
- export HTTPS_PROXY=http://127.0.0.1:7890
237
- export ALL_PROXY=http://127.0.0.1:7890
238
- ```
239
-
240
- ### Python 脚本调用
241
-
242
- ```python
243
- from pathlib import Path
244
- from da_downloader import Downloader
245
- from da_downloader.download import build_downloader
246
-
247
- downloader = build_downloader(
248
- destination=Path('downloads'),
249
- archive=Path('archive.sqlite'), # 可选:已下载自动跳过
250
- quality='best', # original / best / preview
251
- write_info_json=True, # 每个作品旁写一份 metadata .json
252
- )
253
-
254
- results = downloader.download('https://www.deviantart.com/username/gallery')
255
- for r in results:
256
- print(r.status, r.path)
257
- ```
258
-
259
- 已通过 `devart-dl login oauth` 登录时自动走官方 API,否则回退到 Cookie。
260
-
261
- ---
262
-
263
- ## 常见问题
264
-
265
- **Q: 下载不完整 / 只下了一部分 / 像是跳着下?**
266
- A: 请升级到 **v3.4.0+**。旧版本只下载 Featured(精选)文件夹;v3.3.1 起遍历全部画廊文件夹,v3.4.0 起解析失败与网络失败会明确报错,且中断可 Range 续传。
267
-
268
- **Q: pip 安装后运行 `devart-dl` 报 ModuleNotFoundError?**
269
- A: 请升级到 **v3.4.0+**(`pip install -U devart-dl`),安装入口已修复。
270
-
271
- **Q: 出现 403 Forbidden?**
272
- A: 通常是未登录或 Cookie 过期。优先 `devart-dl login oauth`(官方 API);或 `devart-dl login interactive` 更新 Cookie。
273
-
274
- **Q: 出现 429 Too Many Requests?**
275
- A: 使用官方 API(OAuth 登录)通常不会触发;Cookie 路径下会自动退避重试,若仍频繁 429,请暂停一段时间再试。
276
-
277
- **Q: 下载速度慢?**
278
- A: 建议配置代理(`--proxy`),或降低画质(`--quality preview`)。
279
-
280
- **Q: 如何导出 Cookie?**
281
- A: 推荐 Chrome/Edge 开发者工具 (F12) → Application → Cookies,复制 `auth` 和 `auth_secure` 字段;或 `devart-dl login interactive` 按提示粘贴。
282
-
283
- ---
284
-
285
- ## 许可证与免责声明
286
-
287
- 本项目基于 [MIT License](LICENSE) 开源。
288
-
289
- **注意**:本工具仅供个人学习和研究使用。使用者应遵守 DeviantArt 服务条款及版权规定,请勿用于商业用途或大规模抓取导致服务器过载。作者不对任何滥用后果负责。