dy-cli 0.2.0__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. dy_cli-0.2.0/.github/workflows/publish.yml +24 -0
  2. dy_cli-0.2.0/.gitignore +42 -0
  3. dy_cli-0.2.0/LICENSE +21 -0
  4. dy_cli-0.2.0/PKG-INFO +376 -0
  5. dy_cli-0.2.0/README.md +351 -0
  6. dy_cli-0.2.0/SCHEMA.md +29 -0
  7. dy_cli-0.2.0/SKILL.md +215 -0
  8. dy_cli-0.2.0/activate.sh +12 -0
  9. dy_cli-0.2.0/config/accounts.json.example +9 -0
  10. dy_cli-0.2.0/demo.gif +0 -0
  11. dy_cli-0.2.0/docs/claude-code-integration.md +57 -0
  12. dy_cli-0.2.0/docs/cli-guide.md +232 -0
  13. dy_cli-0.2.0/manifest.json +11 -0
  14. dy_cli-0.2.0/pyproject.toml +40 -0
  15. dy_cli-0.2.0/requirements.txt +6 -0
  16. dy_cli-0.2.0/scripts/chrome_launcher.py +71 -0
  17. dy_cli-0.2.0/scripts/douyin_analytics.py +99 -0
  18. dy_cli-0.2.0/scripts/douyin_login.py +64 -0
  19. dy_cli-0.2.0/scripts/douyin_publisher.py +199 -0
  20. dy_cli-0.2.0/setup.bat +53 -0
  21. dy_cli-0.2.0/setup.sh +135 -0
  22. dy_cli-0.2.0/src/dy_cli/__init__.py +3 -0
  23. dy_cli-0.2.0/src/dy_cli/commands/__init__.py +0 -0
  24. dy_cli-0.2.0/src/dy_cli/commands/account.py +103 -0
  25. dy_cli-0.2.0/src/dy_cli/commands/analytics.py +120 -0
  26. dy_cli-0.2.0/src/dy_cli/commands/auth.py +159 -0
  27. dy_cli-0.2.0/src/dy_cli/commands/config_cmd.py +67 -0
  28. dy_cli-0.2.0/src/dy_cli/commands/download.py +212 -0
  29. dy_cli-0.2.0/src/dy_cli/commands/init.py +200 -0
  30. dy_cli-0.2.0/src/dy_cli/commands/interact.py +140 -0
  31. dy_cli-0.2.0/src/dy_cli/commands/live.py +141 -0
  32. dy_cli-0.2.0/src/dy_cli/commands/profile.py +78 -0
  33. dy_cli-0.2.0/src/dy_cli/commands/publish.py +123 -0
  34. dy_cli-0.2.0/src/dy_cli/commands/search.py +131 -0
  35. dy_cli-0.2.0/src/dy_cli/commands/trending.py +82 -0
  36. dy_cli-0.2.0/src/dy_cli/engines/__init__.py +0 -0
  37. dy_cli-0.2.0/src/dy_cli/engines/api_client.py +665 -0
  38. dy_cli-0.2.0/src/dy_cli/engines/playwright_client.py +836 -0
  39. dy_cli-0.2.0/src/dy_cli/main.py +144 -0
  40. dy_cli-0.2.0/src/dy_cli/utils/__init__.py +0 -0
  41. dy_cli-0.2.0/src/dy_cli/utils/config.py +99 -0
  42. dy_cli-0.2.0/src/dy_cli/utils/envelope.py +49 -0
  43. dy_cli-0.2.0/src/dy_cli/utils/export.py +68 -0
  44. dy_cli-0.2.0/src/dy_cli/utils/index_cache.py +83 -0
  45. dy_cli-0.2.0/src/dy_cli/utils/output.py +283 -0
  46. dy_cli-0.2.0/src/dy_cli/utils/signature.py +183 -0
@@ -0,0 +1,24 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ environment: pypi
12
+ permissions:
13
+ id-token: write
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.12"
19
+ - name: Install build tools
20
+ run: pip install build
21
+ - name: Build package
22
+ run: python -m build
23
+ - name: Publish to PyPI
24
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,42 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ *.egg
9
+
10
+ # Virtual environment
11
+ .venv/
12
+ venv/
13
+ ENV/
14
+
15
+ # IDE
16
+ .vscode/
17
+ .idea/
18
+ *.swp
19
+ *.swo
20
+ *~
21
+
22
+ # OS
23
+ .DS_Store
24
+ Thumbs.db
25
+
26
+ # Project
27
+ cookies/
28
+ *.cookie
29
+ ~/.dy/
30
+ downloads/
31
+ *.mp4
32
+ *.mp3
33
+
34
+ # Playwright
35
+ .playwright/
36
+
37
+ # Logs
38
+ *.log
39
+
40
+ # Config (user-specific)
41
+ config/accounts.json
42
+ dist/
dy_cli-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
dy_cli-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,376 @@
1
+ Metadata-Version: 2.4
2
+ Name: dy-cli
3
+ Version: 0.2.0
4
+ Summary: 抖音命令行工具 — 发布、搜索、下载、互动、数据分析、热榜、直播
5
+ Project-URL: Homepage, https://github.com/Youhai020616/douyin
6
+ Project-URL: Repository, https://github.com/Youhai020616/douyin
7
+ Project-URL: Issues, https://github.com/Youhai020616/douyin/issues
8
+ Author-email: Youhai <youhai020616@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: automation,cli,douyin,dy,tiktok,抖音
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Utilities
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: browser-cookie3>=0.19
19
+ Requires-Dist: click>=8.0
20
+ Requires-Dist: httpx>=0.27.0
21
+ Requires-Dist: playwright>=1.40
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: rich>=13.0
24
+ Description-Content-Type: text/markdown
25
+
26
+ <p align="center">
27
+ <h1 align="center">🎬 douyin</h1>
28
+ <p align="center">AI-powered Douyin (抖音/TikTok China) automation — search, download, publish, engage, and analyze.</p>
29
+ </p>
30
+
31
+ <p align="center">
32
+ <a href="#cli-quick-start">CLI Quick Start</a> •
33
+ <a href="#features">Features</a> •
34
+ <a href="#commands">Commands</a> •
35
+ <a href="#scripts">Scripts</a> •
36
+ <a href="#claude-code-integration">Claude Code</a> •
37
+ <a href="./LICENSE">License</a>
38
+ </p>
39
+
40
+ ---
41
+
42
+ <p align="center">
43
+ <img src="./demo.gif" alt="dy-cli demo" width="800">
44
+ </p>
45
+
46
+ ## CLI Quick Start
47
+
48
+ The fastest way to get started — **3 commands** from zero to searching:
49
+
50
+ ```bash
51
+ # 1. Clone
52
+ git clone https://github.com/your-username/douyin.git
53
+ cd douyin
54
+
55
+ # 2. One-click install (auto: Python check → venv → pip install → Playwright Chromium)
56
+ bash setup.sh
57
+
58
+ # 3. Initialize (auto: install Chromium → config → QR login)
59
+ source activate.sh && dy init
60
+ ```
61
+
62
+ Then just use:
63
+
64
+ ```bash
65
+ dy search "AI创业" # Search
66
+ dy trending # Hot trending
67
+ dy download https://v.douyin.com/xxxxx/ # Download (no watermark)
68
+ dy publish -t "Hello" -c "My first post" -v video.mp4 # Publish
69
+ dy live info ROOM_ID # Live stream info
70
+ dy analytics # Dashboard
71
+ dy --help # All commands
72
+ ```
73
+
74
+ > 📖 Full CLI guide: [docs/cli-guide.md](docs/cli-guide.md)
75
+
76
+ ---
77
+
78
+ ## What is this?
79
+
80
+ A complete toolkit for automating Douyin (抖音/TikTok China) operations through two complementary engines:
81
+
82
+ | Engine | Technology | Use Cases | Startup |
83
+ |--------|-----------|-----------|---------|
84
+ | **API Client** | Python httpx, reverse-engineered API | Search, download, comments, trending, live | Instant |
85
+ | **Playwright** | Python Playwright, browser automation | Publish, login, analytics dashboard | On-demand |
86
+
87
+ Built as an [OpenClaw](https://github.com/openclaw/openclaw) Skill, but works standalone or with any MCP-compatible client (Claude Code, Cursor, etc.).
88
+
89
+ ## Features
90
+
91
+ - 🔍 **Search** — Keyword search with filters (sort, time, type)
92
+ - 📥 **Download** — No-watermark video/image download with progress bar
93
+ - 📝 **Publish** — Video and image posts with tags, scheduling, visibility
94
+ - 🔥 **Trending** — Real-time hot search rankings with watch mode
95
+ - 📺 **Live** — Live stream info, stream URL extraction, ffmpeg recording
96
+ - 💬 **Engage** — Comment, like, favorite, follow
97
+ - 📊 **Analytics** — Creator dashboard data export (CSV)
98
+ - 🔔 **Notifications** — Fetch interaction notifications
99
+ - 👤 **Profile** — Fetch any user's profile and posts
100
+ - 👥 **Multi-Account** — Isolated cookie storage per account
101
+ - 🔐 **QR Code Login** — Scan-to-login via Playwright, persistent cookie storage
102
+
103
+ ## Quick Start
104
+
105
+ ### Prerequisites
106
+
107
+ - Python 3.10+
108
+ - Playwright Chromium (auto-installed by `setup.sh`)
109
+ - ffmpeg (optional, for live recording: `brew install ffmpeg`)
110
+
111
+ ### 1. Clone & Install
112
+
113
+ ```bash
114
+ git clone https://github.com/your-username/douyin.git
115
+ cd douyin
116
+ bash setup.sh
117
+ ```
118
+
119
+ ### 2. Initialize & Login
120
+
121
+ ```bash
122
+ source activate.sh
123
+ dy init
124
+ ```
125
+
126
+ This will:
127
+ 1. Check your environment
128
+ 2. Install Playwright Chromium
129
+ 3. Configure proxy (optional)
130
+ 4. Open browser for QR code login
131
+
132
+ ### 3. Start Using
133
+
134
+ ```bash
135
+ dy search "旅行" # Search
136
+ dy trending # Hot topics
137
+ dy download URL # Download video
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Commands
143
+
144
+ ### Search & Discovery
145
+
146
+ ```bash
147
+ dy search "关键词" # Basic search
148
+ dy search "咖啡" --sort 最多点赞 # Sort by likes
149
+ dy search "春招" --time 一天内 --type video # Filters
150
+ dy trending # Hot trending list
151
+ dy trending --watch # Auto-refresh every 5 min
152
+ dy trending --json-output # JSON output
153
+ ```
154
+
155
+ ### Download
156
+
157
+ ```bash
158
+ dy download https://v.douyin.com/xxxxx/ # Share link
159
+ dy download https://www.douyin.com/video/123 # Full link
160
+ dy download 1234567890 # Video ID
161
+ dy download URL --music # Also download BGM
162
+ dy download URL -o ~/Videos # Custom output dir
163
+ ```
164
+
165
+ ### Publish
166
+
167
+ ```bash
168
+ # Video
169
+ dy publish -t "标题" -c "描述" -v video.mp4
170
+
171
+ # Image post
172
+ dy publish -t "标题" -c "描述" -i img1.jpg -i img2.jpg
173
+
174
+ # With tags
175
+ dy publish -t "旅行日记" -c "巴厘岛" -v trip.mp4 --tags 旅行 --tags 巴厘岛
176
+
177
+ # Private (test)
178
+ dy publish -t "测试" -c "测试" -v test.mp4 --visibility 仅自己可见
179
+
180
+ # Scheduled
181
+ dy publish -t "早安" -c "新的一天" -v morning.mp4 --schedule "2026-03-16T08:00:00+08:00"
182
+
183
+ # Preview only
184
+ dy publish -t "标题" -c "描述" -v video.mp4 --dry-run
185
+ ```
186
+
187
+ ### Video Detail & Comments
188
+
189
+ ```bash
190
+ dy detail AWEME_ID # Video detail
191
+ dy detail AWEME_ID --comments # With comments
192
+ dy comments AWEME_ID # Comments only
193
+ ```
194
+
195
+ ### Interaction
196
+
197
+ ```bash
198
+ dy like AWEME_ID # Like
199
+ dy favorite AWEME_ID # Favorite
200
+ dy comment AWEME_ID -c "Great!" # Comment
201
+ dy follow SEC_USER_ID # Follow user
202
+ ```
203
+
204
+ ### Live Stream
205
+
206
+ ```bash
207
+ dy live info ROOM_ID # Live info + stream URLs
208
+ dy live record ROOM_ID # Record with ffmpeg
209
+ dy live record ROOM_ID --quality HD1 # Specific quality
210
+ ```
211
+
212
+ ### Analytics & Notifications
213
+
214
+ ```bash
215
+ dy analytics # Creator dashboard
216
+ dy analytics --csv data.csv # Export CSV
217
+ dy notifications # Messages
218
+ ```
219
+
220
+ ### User Profile
221
+
222
+ ```bash
223
+ dy me # My info
224
+ dy profile SEC_USER_ID # User profile
225
+ dy profile SEC_USER_ID --posts # With post list
226
+ ```
227
+
228
+ ### Multi-Account
229
+
230
+ ```bash
231
+ dy account list # List accounts
232
+ dy account add work # Add & login
233
+ dy account default work # Set default
234
+ dy account remove work # Remove
235
+ ```
236
+
237
+ ### Configuration
238
+
239
+ ```bash
240
+ dy config show # Show config
241
+ dy config set api.proxy http://127.0.0.1:7897
242
+ dy config set default.download_dir ~/Videos
243
+ dy config reset # Reset to defaults
244
+ ```
245
+
246
+ ### Command Aliases
247
+
248
+ | Alias | Full Command |
249
+ |-------|-------------|
250
+ | `dy pub` | `dy publish` |
251
+ | `dy s` | `dy search` |
252
+ | `dy dl` | `dy download` |
253
+ | `dy t` | `dy trending` |
254
+ | `dy fav` | `dy favorite` |
255
+ | `dy noti` | `dy notifications` |
256
+ | `dy stat` | `dy status` |
257
+ | `dy acc` | `dy account` |
258
+ | `dy cfg` | `dy config` |
259
+
260
+ ---
261
+
262
+ ## Engine Architecture
263
+
264
+ | Engine | Features | Technology |
265
+ |--------|----------|------------|
266
+ | **API Client** | Search, download, comments, trending, live, user profile | httpx + reverse-engineered API |
267
+ | **Playwright** | Publish, login, analytics, notifications | Playwright browser automation |
268
+
269
+ Most commands auto-select the best engine. Only `publish`, `analytics`, and `login` require Playwright.
270
+
271
+ ---
272
+
273
+ ## Scripts
274
+
275
+ Standalone Python scripts for direct use without the CLI:
276
+
277
+ ```bash
278
+ # Login
279
+ python scripts/douyin_login.py --account default
280
+
281
+ # Publish video
282
+ python scripts/douyin_publisher.py -t "标题" -c "描述" -v video.mp4
283
+
284
+ # Publish images
285
+ python scripts/douyin_publisher.py -t "标题" -c "描述" -i img1.jpg img2.jpg
286
+
287
+ # Analytics
288
+ python scripts/douyin_analytics.py --csv output.csv
289
+
290
+ # Chrome management
291
+ python scripts/chrome_launcher.py
292
+ python scripts/chrome_launcher.py --kill
293
+ ```
294
+
295
+ ---
296
+
297
+ ## Claude Code Integration
298
+
299
+ See [docs/claude-code-integration.md](docs/claude-code-integration.md) for setup instructions.
300
+
301
+ ## Project Structure
302
+
303
+ ```
304
+ douyin/
305
+ ├── README.md # This file
306
+ ├── SKILL.md # OpenClaw skill definition
307
+ ├── pyproject.toml # CLI package config
308
+ ├── manifest.json # Skill metadata
309
+ ├── LICENSE # MIT License
310
+ ├── requirements.txt # Python dependencies
311
+ ├── setup.sh # One-click install (macOS/Linux)
312
+ ├── setup.bat # One-click install (Windows)
313
+ ├── activate.sh # Environment activation
314
+ ├── src/dy_cli/ # ⭐ CLI package
315
+ │ ├── main.py # Unified entry point (dy command)
316
+ │ ├── engines/
317
+ │ │ ├── api_client.py # Reverse-engineered API client
318
+ │ │ └── playwright_client.py # Playwright browser automation
319
+ │ ├── commands/
320
+ │ │ ├── init.py # dy init (guided setup)
321
+ │ │ ├── auth.py # dy login/logout/status
322
+ │ │ ├── publish.py # dy publish (Playwright)
323
+ │ │ ├── search.py # dy search/detail (API)
324
+ │ │ ├── download.py # dy download (API) ⭐
325
+ │ │ ├── interact.py # dy like/comment/favorite/follow
326
+ │ │ ├── trending.py # dy trending (API) ⭐
327
+ │ │ ├── live.py # dy live info/record ⭐
328
+ │ │ ├── analytics.py # dy analytics (Playwright)
329
+ │ │ ├── profile.py # dy me/profile
330
+ │ │ ├── account.py # dy account management
331
+ │ │ └── config_cmd.py # dy config
332
+ │ └── utils/
333
+ │ ├── config.py # ~/.dy/config.json management
334
+ │ ├── output.py # Rich formatted output
335
+ │ └── signature.py # Douyin signature utilities
336
+ ├── scripts/
337
+ │ ├── douyin_login.py # Login script
338
+ │ ├── douyin_publisher.py # Publish script
339
+ │ ├── douyin_analytics.py # Analytics script
340
+ │ └── chrome_launcher.py # Chrome lifecycle
341
+ ├── config/
342
+ │ └── accounts.json.example
343
+ └── docs/
344
+ ├── cli-guide.md # CLI usage guide
345
+ └── claude-code-integration.md # Claude Code setup
346
+ ```
347
+
348
+ ## Platform Support
349
+
350
+ | Component | macOS | Linux | Windows |
351
+ |-----------|:-----:|:-----:|:-------:|
352
+ | **dy CLI** | ✅ | ✅ | ✅ |
353
+ | API Client | ✅ | ✅ | ✅ |
354
+ | Playwright | ✅ | ✅ | ✅ |
355
+
356
+ ## Tips & Known Issues
357
+
358
+ - **Signature algorithm**: Douyin frequently updates `a-bogus`/`x-bogus` — some API calls may need browser-based signing
359
+ - **Login**: Cookie expires periodically, re-login with `dy login`
360
+ - **Rate limiting**: Avoid rapid-fire requests, add delays between batch operations
361
+ - **Proxy**: Outside China may need proxy: `dy config set api.proxy http://...`
362
+ - **Live recording**: Requires ffmpeg: `brew install ffmpeg` (macOS)
363
+
364
+ ## Contributing
365
+
366
+ Issues and PRs welcome! Areas where help is needed:
367
+
368
+ - [ ] Improved `a-bogus` signature algorithm
369
+ - [ ] Batch download by user/hashtag
370
+ - [ ] Playwright interaction (like/comment/follow)
371
+ - [ ] More analytics data points
372
+ - [ ] Test suite
373
+
374
+ ## License
375
+
376
+ [MIT](./LICENSE)