@jackwener/opencli 1.4.0 → 1.5.0
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.
- package/.github/actions/setup-chrome/action.yml +5 -4
- package/.github/workflows/build-extension.yml +2 -6
- package/.github/workflows/ci.yml +37 -3
- package/.github/workflows/e2e-headed.yml +16 -3
- package/CHANGELOG.md +23 -0
- package/PRIVACY.md +57 -0
- package/README.md +36 -7
- package/README.zh-CN.md +13 -6
- package/SKILL.md +103 -2
- package/dist/browser/cdp.d.ts +2 -1
- package/dist/browser/discover.d.ts +4 -1
- package/dist/browser/discover.js +6 -2
- package/dist/browser/errors.d.ts +2 -2
- package/dist/browser/errors.js +4 -12
- package/dist/browser/mcp.d.ts +2 -1
- package/dist/build-manifest.d.ts +2 -0
- package/dist/build-manifest.js +39 -14
- package/dist/build-manifest.test.js +21 -0
- package/dist/capabilityRouting.d.ts +2 -0
- package/dist/capabilityRouting.js +2 -1
- package/dist/cli-manifest.json +1838 -151
- package/dist/cli.js +34 -3
- package/dist/clis/36kr/article.d.ts +1 -0
- package/dist/clis/36kr/article.js +62 -0
- package/dist/clis/36kr/hot.d.ts +3 -0
- package/dist/clis/36kr/hot.js +80 -0
- package/dist/clis/36kr/hot.test.d.ts +1 -0
- package/dist/clis/36kr/hot.test.js +15 -0
- package/dist/clis/36kr/news.d.ts +1 -0
- package/dist/clis/36kr/news.js +51 -0
- package/dist/clis/36kr/news.test.d.ts +1 -0
- package/dist/clis/36kr/news.test.js +85 -0
- package/dist/clis/36kr/search.d.ts +1 -0
- package/dist/clis/36kr/search.js +72 -0
- package/dist/clis/apple-podcasts/search.js +2 -1
- package/dist/clis/arxiv/search.js +2 -2
- package/dist/clis/bbc/news.js +0 -1
- package/dist/clis/bilibili/comments.d.ts +5 -0
- package/dist/clis/bilibili/comments.js +40 -0
- package/dist/clis/bilibili/comments.test.d.ts +1 -0
- package/dist/clis/bilibili/comments.test.js +82 -0
- package/dist/clis/chatgpt/ask.js +29 -14
- package/dist/clis/chatgpt/ax.d.ts +6 -0
- package/dist/clis/chatgpt/ax.js +172 -1
- package/dist/clis/chatgpt/model.d.ts +1 -0
- package/dist/clis/chatgpt/model.js +24 -0
- package/dist/clis/chatgpt/send.js +12 -3
- package/dist/clis/ctrip/search.js +0 -1
- package/dist/clis/douban/download.d.ts +1 -0
- package/dist/clis/douban/download.js +67 -0
- package/dist/clis/douban/download.test.d.ts +1 -0
- package/dist/clis/douban/download.test.js +170 -0
- package/dist/clis/douban/photos.d.ts +1 -0
- package/dist/clis/douban/photos.js +34 -0
- package/dist/clis/douban/utils.d.ts +25 -0
- package/dist/clis/douban/utils.js +190 -1
- package/dist/clis/douban/utils.test.d.ts +1 -0
- package/dist/clis/douban/utils.test.js +64 -0
- package/dist/clis/douyin/_shared/browser-fetch.d.ts +10 -0
- package/dist/clis/douyin/_shared/browser-fetch.js +30 -0
- package/dist/clis/douyin/_shared/browser-fetch.test.d.ts +1 -0
- package/dist/clis/douyin/_shared/browser-fetch.test.js +31 -0
- package/dist/clis/douyin/_shared/creation-id.d.ts +1 -0
- package/dist/clis/douyin/_shared/creation-id.js +5 -0
- package/dist/clis/douyin/_shared/creation-id.test.d.ts +1 -0
- package/dist/clis/douyin/_shared/creation-id.test.js +22 -0
- package/dist/clis/douyin/_shared/imagex-upload.d.ts +20 -0
- package/dist/clis/douyin/_shared/imagex-upload.js +53 -0
- package/dist/clis/douyin/_shared/imagex-upload.test.d.ts +1 -0
- package/dist/clis/douyin/_shared/imagex-upload.test.js +87 -0
- package/dist/clis/douyin/_shared/sts2.d.ts +8 -0
- package/dist/clis/douyin/_shared/sts2.js +15 -0
- package/dist/clis/douyin/_shared/text-extra.d.ts +18 -0
- package/dist/clis/douyin/_shared/text-extra.js +15 -0
- package/dist/clis/douyin/_shared/text-extra.test.d.ts +1 -0
- package/dist/clis/douyin/_shared/text-extra.test.js +37 -0
- package/dist/clis/douyin/_shared/timing.d.ts +2 -0
- package/dist/clis/douyin/_shared/timing.js +22 -0
- package/dist/clis/douyin/_shared/timing.test.d.ts +1 -0
- package/dist/clis/douyin/_shared/timing.test.js +28 -0
- package/dist/clis/douyin/_shared/tos-upload-short-read.test.d.ts +11 -0
- package/dist/clis/douyin/_shared/tos-upload-short-read.test.js +83 -0
- package/dist/clis/douyin/_shared/tos-upload.d.ts +53 -0
- package/dist/clis/douyin/_shared/tos-upload.js +295 -0
- package/dist/clis/douyin/_shared/tos-upload.test.d.ts +1 -0
- package/dist/clis/douyin/_shared/tos-upload.test.js +229 -0
- package/dist/clis/douyin/_shared/transcode.d.ts +27 -0
- package/dist/clis/douyin/_shared/transcode.js +45 -0
- package/dist/clis/douyin/_shared/transcode.test.d.ts +1 -0
- package/dist/clis/douyin/_shared/transcode.test.js +93 -0
- package/dist/clis/douyin/_shared/types.d.ts +26 -0
- package/dist/clis/douyin/_shared/types.js +1 -0
- package/dist/clis/douyin/activities.d.ts +1 -0
- package/dist/clis/douyin/activities.js +20 -0
- package/dist/clis/douyin/activities.test.d.ts +1 -0
- package/dist/clis/douyin/activities.test.js +22 -0
- package/dist/clis/douyin/collections.d.ts +1 -0
- package/dist/clis/douyin/collections.js +22 -0
- package/dist/clis/douyin/collections.test.d.ts +1 -0
- package/dist/clis/douyin/collections.test.js +23 -0
- package/dist/clis/douyin/delete.d.ts +1 -0
- package/dist/clis/douyin/delete.js +18 -0
- package/dist/clis/douyin/delete.test.d.ts +1 -0
- package/dist/clis/douyin/delete.test.js +11 -0
- package/dist/clis/douyin/draft.d.ts +14 -0
- package/dist/clis/douyin/draft.js +237 -0
- package/dist/clis/douyin/draft.test.d.ts +1 -0
- package/dist/clis/douyin/draft.test.js +11 -0
- package/dist/clis/douyin/drafts.d.ts +1 -0
- package/dist/clis/douyin/drafts.js +23 -0
- package/dist/clis/douyin/drafts.test.d.ts +1 -0
- package/dist/clis/douyin/drafts.test.js +11 -0
- package/dist/clis/douyin/hashtag.d.ts +1 -0
- package/dist/clis/douyin/hashtag.js +45 -0
- package/dist/clis/douyin/hashtag.test.d.ts +1 -0
- package/dist/clis/douyin/hashtag.test.js +25 -0
- package/dist/clis/douyin/location.d.ts +1 -0
- package/dist/clis/douyin/location.js +24 -0
- package/dist/clis/douyin/location.test.d.ts +1 -0
- package/dist/clis/douyin/location.test.js +23 -0
- package/dist/clis/douyin/profile.d.ts +1 -0
- package/dist/clis/douyin/profile.js +28 -0
- package/dist/clis/douyin/profile.test.d.ts +1 -0
- package/dist/clis/douyin/profile.test.js +11 -0
- package/dist/clis/douyin/publish.d.ts +14 -0
- package/dist/clis/douyin/publish.js +288 -0
- package/dist/clis/douyin/publish.test.d.ts +1 -0
- package/dist/clis/douyin/publish.test.js +38 -0
- package/dist/clis/douyin/stats.d.ts +1 -0
- package/dist/clis/douyin/stats.js +27 -0
- package/dist/clis/douyin/stats.test.d.ts +1 -0
- package/dist/clis/douyin/stats.test.js +22 -0
- package/dist/clis/douyin/update.d.ts +1 -0
- package/dist/clis/douyin/update.js +31 -0
- package/dist/clis/douyin/update.test.d.ts +1 -0
- package/dist/clis/douyin/update.test.js +11 -0
- package/dist/clis/douyin/videos.d.ts +1 -0
- package/dist/clis/douyin/videos.js +34 -0
- package/dist/clis/douyin/videos.test.d.ts +1 -0
- package/dist/clis/douyin/videos.test.js +11 -0
- package/dist/clis/hackernews/search.yaml +1 -1
- package/dist/clis/imdb/person.d.ts +1 -0
- package/dist/clis/imdb/person.js +203 -0
- package/dist/clis/imdb/reviews.d.ts +1 -0
- package/dist/clis/imdb/reviews.js +88 -0
- package/dist/clis/imdb/search.d.ts +1 -0
- package/dist/clis/imdb/search.js +161 -0
- package/dist/clis/imdb/title.d.ts +1 -0
- package/dist/clis/imdb/title.js +93 -0
- package/dist/clis/imdb/top.d.ts +1 -0
- package/dist/clis/imdb/top.js +53 -0
- package/dist/clis/imdb/trending.d.ts +1 -0
- package/dist/clis/imdb/trending.js +52 -0
- package/dist/clis/imdb/utils.d.ts +46 -0
- package/dist/clis/imdb/utils.js +285 -0
- package/dist/clis/imdb/utils.test.d.ts +1 -0
- package/dist/clis/imdb/utils.test.js +88 -0
- package/dist/clis/instagram/search.yaml +2 -1
- package/dist/clis/jd/item.d.ts +4 -0
- package/dist/clis/jd/item.js +16 -15
- package/dist/clis/jd/item.test.js +16 -1
- package/dist/clis/linux-do/categories.yaml +38 -9
- package/dist/clis/linux-do/category.d.ts +1 -0
- package/dist/clis/linux-do/category.js +36 -0
- package/dist/clis/linux-do/feed.d.ts +45 -0
- package/dist/clis/linux-do/feed.js +397 -0
- package/dist/clis/linux-do/feed.test.d.ts +1 -0
- package/dist/clis/linux-do/feed.test.js +118 -0
- package/dist/clis/linux-do/hot.d.ts +1 -0
- package/dist/clis/linux-do/hot.js +25 -0
- package/dist/clis/linux-do/latest.d.ts +1 -0
- package/dist/clis/linux-do/latest.js +18 -0
- package/dist/clis/linux-do/search.yaml +3 -1
- package/dist/clis/linux-do/tags.yaml +41 -0
- package/dist/clis/linux-do/topic.yaml +41 -3
- package/dist/clis/linux-do/user-posts.yaml +67 -0
- package/dist/clis/linux-do/user-topics.yaml +54 -0
- package/dist/clis/medium/search.js +1 -1
- package/dist/clis/paperreview/commands.test.d.ts +3 -0
- package/dist/clis/paperreview/commands.test.js +243 -0
- package/dist/clis/paperreview/feedback.d.ts +1 -0
- package/dist/clis/paperreview/feedback.js +52 -0
- package/dist/clis/paperreview/review.d.ts +1 -0
- package/dist/clis/paperreview/review.js +37 -0
- package/dist/clis/paperreview/submit.d.ts +1 -0
- package/dist/clis/paperreview/submit.js +85 -0
- package/dist/clis/paperreview/utils.d.ts +46 -0
- package/dist/clis/paperreview/utils.js +197 -0
- package/dist/clis/paperreview/utils.test.d.ts +1 -0
- package/dist/clis/paperreview/utils.test.js +49 -0
- package/dist/clis/producthunt/browse.d.ts +1 -0
- package/dist/clis/producthunt/browse.js +99 -0
- package/dist/clis/producthunt/hot.d.ts +1 -0
- package/dist/clis/producthunt/hot.js +110 -0
- package/dist/clis/producthunt/posts.d.ts +1 -0
- package/dist/clis/producthunt/posts.js +28 -0
- package/dist/clis/producthunt/today.d.ts +1 -0
- package/dist/clis/producthunt/today.js +35 -0
- package/dist/clis/producthunt/utils.d.ts +29 -0
- package/dist/clis/producthunt/utils.js +99 -0
- package/dist/clis/producthunt/utils.test.d.ts +1 -0
- package/dist/clis/producthunt/utils.test.js +64 -0
- package/dist/clis/reuters/search.js +0 -1
- package/dist/clis/twitter/article.js +4 -28
- package/dist/clis/twitter/likes.d.ts +24 -0
- package/dist/clis/twitter/likes.js +217 -0
- package/dist/clis/twitter/likes.test.d.ts +1 -0
- package/dist/clis/twitter/likes.test.js +85 -0
- package/dist/clis/twitter/profile.js +4 -28
- package/dist/clis/twitter/search.js +7 -4
- package/dist/clis/twitter/search.test.js +56 -2
- package/dist/clis/twitter/shared.d.ts +6 -0
- package/dist/clis/twitter/shared.js +35 -0
- package/dist/clis/twitter/timeline.js +2 -13
- package/dist/clis/weibo/comments.d.ts +1 -0
- package/dist/clis/weibo/comments.js +53 -0
- package/dist/clis/weibo/feed.d.ts +1 -0
- package/dist/clis/weibo/feed.js +56 -0
- package/dist/clis/weibo/hot.js +0 -1
- package/dist/clis/weibo/me.d.ts +1 -0
- package/dist/clis/weibo/me.js +76 -0
- package/dist/clis/weibo/post.d.ts +1 -0
- package/dist/clis/weibo/post.js +75 -0
- package/dist/clis/weibo/user.d.ts +1 -0
- package/dist/clis/weibo/user.js +63 -0
- package/dist/clis/weibo/utils.d.ts +6 -0
- package/dist/clis/weibo/utils.js +30 -0
- package/dist/clis/weixin/download.d.ts +17 -0
- package/dist/clis/weixin/download.js +88 -20
- package/dist/clis/weread/book.js +2 -2
- package/dist/clis/weread/commands.test.d.ts +3 -0
- package/dist/clis/weread/commands.test.js +43 -0
- package/dist/clis/weread/highlights.js +2 -2
- package/dist/clis/weread/notebooks.js +2 -2
- package/dist/clis/weread/notes.js +3 -3
- package/dist/clis/weread/search.js +3 -2
- package/dist/clis/weread/shelf.js +2 -2
- package/dist/clis/weread/utils.d.ts +4 -4
- package/dist/clis/weread/utils.js +32 -14
- package/dist/clis/weread/utils.test.js +1 -28
- package/dist/clis/xiaohongshu/comments.d.ts +5 -0
- package/dist/clis/xiaohongshu/comments.js +74 -0
- package/dist/clis/xiaohongshu/comments.test.d.ts +1 -0
- package/dist/clis/xiaohongshu/comments.test.js +79 -0
- package/dist/clis/xiaohongshu/publish.js +114 -18
- package/dist/clis/xiaohongshu/publish.test.d.ts +1 -0
- package/dist/clis/xiaohongshu/publish.test.js +119 -0
- package/dist/clis/xueqiu/search.yaml +2 -1
- package/dist/clis/yahoo-finance/quote.js +0 -1
- package/dist/clis/youtube/channel.d.ts +1 -0
- package/dist/clis/youtube/channel.js +150 -0
- package/dist/clis/youtube/comments.d.ts +1 -0
- package/dist/clis/youtube/comments.js +95 -0
- package/dist/clis/youtube/search.js +0 -1
- package/dist/clis/zhihu/search.yaml +2 -1
- package/dist/commanderAdapter.d.ts +1 -0
- package/dist/commanderAdapter.js +176 -29
- package/dist/commanderAdapter.test.d.ts +1 -0
- package/dist/commanderAdapter.test.js +62 -0
- package/dist/daemon.js +17 -1
- package/dist/discovery.js +8 -14
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +9 -2
- package/dist/download/index.js +63 -51
- package/dist/download/index.test.js +17 -4
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +15 -32
- package/dist/execution.d.ts +1 -3
- package/dist/execution.js +21 -1
- package/dist/external-clis.yaml +0 -17
- package/dist/hooks.js +2 -0
- package/dist/main.js +5 -0
- package/dist/output.js +5 -1
- package/dist/pipeline/executor.js +3 -4
- package/dist/plugin-manifest.d.ts +70 -0
- package/dist/plugin-manifest.js +160 -0
- package/dist/plugin-manifest.test.d.ts +4 -0
- package/dist/plugin-manifest.test.js +179 -0
- package/dist/plugin.d.ts +38 -5
- package/dist/plugin.js +267 -33
- package/dist/plugin.test.js +220 -3
- package/dist/registry.d.ts +4 -0
- package/dist/registry.js +2 -0
- package/dist/runtime-detect.d.ts +21 -0
- package/dist/runtime-detect.js +32 -0
- package/dist/runtime-detect.test.d.ts +1 -0
- package/dist/runtime-detect.test.js +27 -0
- package/dist/runtime.js +1 -1
- package/dist/serialization.d.ts +2 -0
- package/dist/serialization.js +6 -0
- package/dist/types.d.ts +1 -0
- package/dist/update-check.d.ts +22 -0
- package/dist/update-check.js +112 -0
- package/dist/weixin-download.test.d.ts +1 -0
- package/dist/weixin-download.test.js +30 -0
- package/dist/weread-private-api-regression.test.d.ts +1 -0
- package/dist/weread-private-api-regression.test.js +122 -0
- package/dist/weread-search-regression.test.d.ts +1 -0
- package/dist/weread-search-regression.test.js +39 -0
- package/dist/yaml-schema.d.ts +3 -0
- package/dist/yaml-schema.js +18 -1
- package/docs/.vitepress/config.mts +17 -0
- package/docs/adapters/browser/36kr.md +47 -0
- package/docs/adapters/browser/douban.md +14 -0
- package/docs/adapters/browser/douyin.md +75 -0
- package/docs/adapters/browser/imdb.md +47 -0
- package/docs/adapters/browser/jd.md +2 -2
- package/docs/adapters/browser/linux-do.md +181 -20
- package/docs/adapters/browser/paperreview.md +43 -0
- package/docs/adapters/browser/producthunt.md +49 -0
- package/docs/adapters/browser/twitter.md +6 -0
- package/docs/adapters/desktop/chatgpt.md +5 -0
- package/docs/adapters/index.md +12 -3
- package/docs/advanced/download.md +4 -0
- package/docs/advanced/rate-limiter-plugin.md +99 -0
- package/docs/guide/electron-app-cli.md +200 -0
- package/docs/guide/getting-started.md +1 -0
- package/docs/guide/plugins.md +87 -0
- package/docs/zh/guide/electron-app-cli.md +188 -0
- package/docs/zh/guide/getting-started.md +1 -0
- package/docs/zh/guide/plugins.md +65 -0
- package/extension/dist/background.js +508 -518
- package/extension/manifest.json +6 -2
- package/extension/package.json +2 -1
- package/extension/popup.html +84 -0
- package/extension/popup.js +25 -0
- package/extension/scripts/package-release.mjs +179 -0
- package/extension/src/background.ts +22 -1
- package/package.json +4 -1
- package/scripts/postinstall.js +10 -0
- package/src/browser/cdp.ts +2 -1
- package/src/browser/discover.ts +8 -3
- package/src/browser/errors.ts +13 -14
- package/src/browser/mcp.ts +2 -1
- package/src/build-manifest.test.ts +23 -0
- package/src/build-manifest.ts +40 -15
- package/src/capabilityRouting.ts +2 -1
- package/src/cli.ts +35 -3
- package/src/clis/36kr/article.ts +69 -0
- package/src/clis/36kr/hot.test.ts +19 -0
- package/src/clis/36kr/hot.ts +100 -0
- package/src/clis/36kr/news.test.ts +90 -0
- package/src/clis/36kr/news.ts +54 -0
- package/src/clis/36kr/search.ts +78 -0
- package/src/clis/apple-podcasts/search.ts +2 -1
- package/src/clis/arxiv/search.ts +2 -2
- package/src/clis/bbc/news.ts +0 -1
- package/src/clis/bilibili/comments.test.ts +102 -0
- package/src/clis/bilibili/comments.ts +44 -0
- package/src/clis/chatgpt/ask.ts +28 -14
- package/src/clis/chatgpt/ax.ts +180 -1
- package/src/clis/chatgpt/model.ts +27 -0
- package/src/clis/chatgpt/send.ts +16 -6
- package/src/clis/ctrip/search.ts +0 -1
- package/src/clis/douban/download.test.ts +196 -0
- package/src/clis/douban/download.ts +78 -0
- package/src/clis/douban/photos.ts +36 -0
- package/src/clis/douban/utils.test.ts +97 -0
- package/src/clis/douban/utils.ts +232 -1
- package/src/clis/douyin/_shared/browser-fetch.test.ts +38 -0
- package/src/clis/douyin/_shared/browser-fetch.ts +45 -0
- package/src/clis/douyin/_shared/creation-id.test.ts +26 -0
- package/src/clis/douyin/_shared/creation-id.ts +8 -0
- package/src/clis/douyin/_shared/imagex-upload.test.ts +113 -0
- package/src/clis/douyin/_shared/imagex-upload.ts +76 -0
- package/src/clis/douyin/_shared/sts2.ts +20 -0
- package/src/clis/douyin/_shared/text-extra.test.ts +42 -0
- package/src/clis/douyin/_shared/text-extra.ts +33 -0
- package/src/clis/douyin/_shared/timing.test.ts +38 -0
- package/src/clis/douyin/_shared/timing.ts +22 -0
- package/src/clis/douyin/_shared/tos-upload-short-read.test.ts +102 -0
- package/src/clis/douyin/_shared/tos-upload.test.ts +281 -0
- package/src/clis/douyin/_shared/tos-upload.ts +444 -0
- package/src/clis/douyin/_shared/transcode.test.ts +117 -0
- package/src/clis/douyin/_shared/transcode.ts +78 -0
- package/src/clis/douyin/_shared/types.ts +29 -0
- package/src/clis/douyin/activities.test.ts +25 -0
- package/src/clis/douyin/activities.ts +23 -0
- package/src/clis/douyin/collections.test.ts +26 -0
- package/src/clis/douyin/collections.ts +25 -0
- package/src/clis/douyin/delete.test.ts +12 -0
- package/src/clis/douyin/delete.ts +20 -0
- package/src/clis/douyin/draft.test.ts +12 -0
- package/src/clis/douyin/draft.ts +282 -0
- package/src/clis/douyin/drafts.test.ts +12 -0
- package/src/clis/douyin/drafts.ts +27 -0
- package/src/clis/douyin/hashtag.test.ts +28 -0
- package/src/clis/douyin/hashtag.ts +56 -0
- package/src/clis/douyin/location.test.ts +26 -0
- package/src/clis/douyin/location.ts +27 -0
- package/src/clis/douyin/profile.test.ts +12 -0
- package/src/clis/douyin/profile.ts +37 -0
- package/src/clis/douyin/publish.test.ts +45 -0
- package/src/clis/douyin/publish.ts +340 -0
- package/src/clis/douyin/stats.test.ts +25 -0
- package/src/clis/douyin/stats.ts +30 -0
- package/src/clis/douyin/update.test.ts +12 -0
- package/src/clis/douyin/update.ts +43 -0
- package/src/clis/douyin/videos.test.ts +12 -0
- package/src/clis/douyin/videos.ts +49 -0
- package/src/clis/hackernews/search.yaml +1 -1
- package/src/clis/imdb/person.ts +232 -0
- package/src/clis/imdb/reviews.ts +111 -0
- package/src/clis/imdb/search.ts +179 -0
- package/src/clis/imdb/title.ts +121 -0
- package/src/clis/imdb/top.ts +67 -0
- package/src/clis/imdb/trending.ts +66 -0
- package/src/clis/imdb/utils.test.ts +117 -0
- package/src/clis/imdb/utils.ts +305 -0
- package/src/clis/instagram/search.yaml +2 -1
- package/src/clis/jd/item.test.ts +18 -1
- package/src/clis/jd/item.ts +18 -15
- package/src/clis/linux-do/categories.yaml +38 -9
- package/src/clis/linux-do/category.ts +37 -0
- package/src/clis/linux-do/feed.test.ts +132 -0
- package/src/clis/linux-do/feed.ts +501 -0
- package/src/clis/linux-do/hot.ts +26 -0
- package/src/clis/linux-do/latest.ts +19 -0
- package/src/clis/linux-do/search.yaml +3 -1
- package/src/clis/linux-do/tags.yaml +41 -0
- package/src/clis/linux-do/topic.yaml +41 -3
- package/src/clis/linux-do/user-posts.yaml +67 -0
- package/src/clis/linux-do/user-topics.yaml +54 -0
- package/src/clis/medium/search.ts +1 -1
- package/src/clis/paperreview/commands.test.ts +283 -0
- package/src/clis/paperreview/feedback.ts +64 -0
- package/src/clis/paperreview/review.ts +47 -0
- package/src/clis/paperreview/submit.ts +119 -0
- package/src/clis/paperreview/utils.test.ts +68 -0
- package/src/clis/paperreview/utils.ts +276 -0
- package/src/clis/producthunt/browse.ts +109 -0
- package/src/clis/producthunt/hot.ts +127 -0
- package/src/clis/producthunt/posts.ts +29 -0
- package/src/clis/producthunt/today.ts +37 -0
- package/src/clis/producthunt/utils.test.ts +72 -0
- package/src/clis/producthunt/utils.ts +122 -0
- package/src/clis/reuters/search.ts +0 -1
- package/src/clis/twitter/article.ts +5 -28
- package/src/clis/twitter/likes.test.ts +91 -0
- package/src/clis/twitter/likes.ts +256 -0
- package/src/clis/twitter/profile.ts +5 -28
- package/src/clis/twitter/search.test.ts +71 -2
- package/src/clis/twitter/search.ts +8 -4
- package/src/clis/twitter/shared.ts +45 -0
- package/src/clis/twitter/timeline.ts +2 -13
- package/src/clis/weibo/comments.ts +54 -0
- package/src/clis/weibo/feed.ts +57 -0
- package/src/clis/weibo/hot.ts +0 -1
- package/src/clis/weibo/me.ts +77 -0
- package/src/clis/weibo/post.ts +77 -0
- package/src/clis/weibo/user.ts +64 -0
- package/src/clis/weibo/utils.ts +32 -0
- package/src/clis/weixin/download.ts +114 -20
- package/src/clis/weread/book.ts +2 -2
- package/src/clis/weread/commands.test.ts +57 -0
- package/src/clis/weread/highlights.ts +2 -2
- package/src/clis/weread/notebooks.ts +2 -2
- package/src/clis/weread/notes.ts +3 -3
- package/src/clis/weread/search.ts +3 -2
- package/src/clis/weread/shelf.ts +2 -2
- package/src/clis/weread/utils.test.ts +1 -32
- package/src/clis/weread/utils.ts +41 -16
- package/src/clis/xiaohongshu/comments.test.ts +96 -0
- package/src/clis/xiaohongshu/comments.ts +81 -0
- package/src/clis/xiaohongshu/publish.test.ts +137 -0
- package/src/clis/xiaohongshu/publish.ts +129 -18
- package/src/clis/xueqiu/search.yaml +2 -1
- package/src/clis/yahoo-finance/quote.ts +0 -1
- package/src/clis/youtube/channel.ts +155 -0
- package/src/clis/youtube/comments.ts +97 -0
- package/src/clis/youtube/search.ts +0 -1
- package/src/clis/zhihu/search.yaml +2 -1
- package/src/commanderAdapter.test.ts +78 -0
- package/src/commanderAdapter.ts +188 -24
- package/src/daemon.ts +19 -1
- package/src/discovery.ts +8 -15
- package/src/doctor.ts +13 -2
- package/src/download/index.test.ts +14 -4
- package/src/download/index.ts +67 -55
- package/src/errors.ts +25 -66
- package/src/execution.ts +28 -3
- package/src/external-clis.yaml +0 -17
- package/src/hooks.ts +1 -0
- package/src/main.ts +6 -0
- package/src/output.ts +3 -1
- package/src/pipeline/executor.ts +4 -6
- package/src/plugin-manifest.test.ts +223 -0
- package/src/plugin-manifest.ts +206 -0
- package/src/plugin.test.ts +246 -2
- package/src/plugin.ts +338 -36
- package/src/registry.ts +6 -1
- package/src/runtime-detect.test.ts +30 -0
- package/src/runtime-detect.ts +36 -0
- package/src/runtime.ts +1 -1
- package/src/serialization.ts +4 -0
- package/src/types.ts +1 -0
- package/src/update-check.ts +114 -0
- package/src/weixin-download.test.ts +64 -0
- package/src/weread-private-api-regression.test.ts +150 -0
- package/src/weread-search-regression.test.ts +44 -0
- package/src/yaml-schema.ts +20 -0
- package/tests/e2e/browser-auth.test.ts +13 -9
- package/tests/e2e/browser-public-extended.test.ts +162 -0
- package/tests/e2e/browser-public.test.ts +55 -136
- package/tests/e2e/helpers.ts +2 -1
- package/tests/e2e/public-commands.test.ts +37 -3
- package/tests/smoke/api-health.test.ts +1 -1
- package/vitest.config.ts +34 -17
- package/dist/clis/linux-do/category.yaml +0 -51
- package/dist/clis/linux-do/hot.yaml +0 -50
- package/dist/clis/linux-do/latest.yaml +0 -40
- package/src/clis/linux-do/category.yaml +0 -51
- package/src/clis/linux-do/hot.yaml +0 -50
- package/src/clis/linux-do/latest.yaml +0 -40
|
@@ -57,14 +57,22 @@ async function injectImages(page, images) {
|
|
|
57
57
|
(async () => {
|
|
58
58
|
const images = ${payload};
|
|
59
59
|
|
|
60
|
-
//
|
|
60
|
+
// Only use image-capable file inputs. Do not fall back to a generic uploader,
|
|
61
|
+
// otherwise we can accidentally feed images into the video upload flow.
|
|
61
62
|
const inputs = Array.from(document.querySelectorAll('input[type="file"]'));
|
|
62
63
|
const input = inputs.find(el => {
|
|
63
64
|
const accept = el.getAttribute('accept') || '';
|
|
64
|
-
return
|
|
65
|
-
|
|
65
|
+
return (
|
|
66
|
+
accept.includes('image') ||
|
|
67
|
+
accept.includes('.jpg') ||
|
|
68
|
+
accept.includes('.jpeg') ||
|
|
69
|
+
accept.includes('.png') ||
|
|
70
|
+
accept.includes('.gif') ||
|
|
71
|
+
accept.includes('.webp')
|
|
72
|
+
);
|
|
73
|
+
});
|
|
66
74
|
|
|
67
|
-
if (!input) return { ok: false, count: 0, error: 'No file input found on page' };
|
|
75
|
+
if (!input) return { ok: false, count: 0, error: 'No image file input found on page' };
|
|
68
76
|
|
|
69
77
|
const dt = new DataTransfer();
|
|
70
78
|
for (const img of images) {
|
|
@@ -141,6 +149,99 @@ async function fillField(page, selectors, text, fieldName) {
|
|
|
141
149
|
throw new Error(`Could not find ${fieldName} input. Debug screenshot: /tmp/xhs_publish_${fieldName}_debug.png`);
|
|
142
150
|
}
|
|
143
151
|
}
|
|
152
|
+
async function selectImageTextTab(page) {
|
|
153
|
+
const result = await page.evaluate(`
|
|
154
|
+
() => {
|
|
155
|
+
const isVisible = (el) => {
|
|
156
|
+
if (!el || el.offsetParent === null) return false;
|
|
157
|
+
const rect = el.getBoundingClientRect();
|
|
158
|
+
return rect.width > 0 && rect.height > 0;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const normalize = (value) => (value || '').replace(/\\s+/g, ' ').trim();
|
|
162
|
+
const selector = 'button, [role="tab"], [role="button"], a, label, div, span, li';
|
|
163
|
+
const nodes = Array.from(document.querySelectorAll(selector));
|
|
164
|
+
const targets = ['上传图文', '图文', '图片'];
|
|
165
|
+
|
|
166
|
+
for (const target of targets) {
|
|
167
|
+
for (const node of nodes) {
|
|
168
|
+
if (!isVisible(node)) continue;
|
|
169
|
+
const text = normalize(node.innerText || node.textContent || '');
|
|
170
|
+
if (!text || text.includes('视频')) continue;
|
|
171
|
+
if (text === target || text.startsWith(target) || text.includes(target)) {
|
|
172
|
+
const clickable = node.closest('button, [role="tab"], [role="button"], a, label') || node;
|
|
173
|
+
clickable.click();
|
|
174
|
+
return { ok: true, target, text };
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const visibleTexts = [];
|
|
180
|
+
for (const node of nodes) {
|
|
181
|
+
if (!isVisible(node)) continue;
|
|
182
|
+
const text = normalize(node.innerText || node.textContent || '');
|
|
183
|
+
if (!text || text.length > 20) continue;
|
|
184
|
+
visibleTexts.push(text);
|
|
185
|
+
if (visibleTexts.length >= 20) break;
|
|
186
|
+
}
|
|
187
|
+
return { ok: false, visibleTexts };
|
|
188
|
+
}
|
|
189
|
+
`);
|
|
190
|
+
if (result?.ok) {
|
|
191
|
+
await page.wait({ time: 1 });
|
|
192
|
+
}
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
async function inspectPublishSurface(page) {
|
|
196
|
+
return page.evaluate(`
|
|
197
|
+
() => {
|
|
198
|
+
const text = (document.body?.innerText || '').replace(/\\s+/g, ' ').trim();
|
|
199
|
+
const hasTitleInput = !!Array.from(document.querySelectorAll('input, textarea')).find((el) => {
|
|
200
|
+
if (!el || el.offsetParent === null) return false;
|
|
201
|
+
const placeholder = (el.getAttribute('placeholder') || '').trim();
|
|
202
|
+
const cls = el.className ? String(el.className) : '';
|
|
203
|
+
const maxLength = Number(el.getAttribute('maxlength') || 0);
|
|
204
|
+
return (
|
|
205
|
+
placeholder.includes('标题') ||
|
|
206
|
+
/title/i.test(placeholder) ||
|
|
207
|
+
/title/i.test(cls) ||
|
|
208
|
+
maxLength === 20
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
const hasImageInput = !!Array.from(document.querySelectorAll('input[type="file"]')).find((el) => {
|
|
212
|
+
const accept = el.getAttribute('accept') || '';
|
|
213
|
+
return (
|
|
214
|
+
accept.includes('image') ||
|
|
215
|
+
accept.includes('.jpg') ||
|
|
216
|
+
accept.includes('.jpeg') ||
|
|
217
|
+
accept.includes('.png') ||
|
|
218
|
+
accept.includes('.gif') ||
|
|
219
|
+
accept.includes('.webp')
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
return {
|
|
223
|
+
hasTitleInput,
|
|
224
|
+
hasImageInput,
|
|
225
|
+
hasVideoSurface: text.includes('拖拽视频到此处点击上传') || text.includes('上传视频'),
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
`);
|
|
229
|
+
}
|
|
230
|
+
async function waitForImageTextSurface(page, maxWaitMs = 5_000) {
|
|
231
|
+
const pollMs = 500;
|
|
232
|
+
const maxAttempts = Math.max(1, Math.ceil(maxWaitMs / pollMs));
|
|
233
|
+
let surface = await inspectPublishSurface(page);
|
|
234
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
235
|
+
if (surface.hasTitleInput || surface.hasImageInput || !surface.hasVideoSurface) {
|
|
236
|
+
return surface;
|
|
237
|
+
}
|
|
238
|
+
if (i < maxAttempts - 1) {
|
|
239
|
+
await page.wait({ time: pollMs / 1_000 });
|
|
240
|
+
surface = await inspectPublishSurface(page);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return surface;
|
|
244
|
+
}
|
|
144
245
|
cli({
|
|
145
246
|
site: 'xiaohongshu',
|
|
146
247
|
name: 'publish',
|
|
@@ -189,21 +290,16 @@ cli({
|
|
|
189
290
|
'Re-capture browser login via: opencli xiaohongshu creator-profile');
|
|
190
291
|
}
|
|
191
292
|
// ── Step 2: Select 图文 (image+text) note type if tabs are present ─────────
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
293
|
+
const tabResult = await selectImageTextTab(page);
|
|
294
|
+
const surface = await waitForImageTextSurface(page, tabResult?.ok ? 5_000 : 2_000);
|
|
295
|
+
if (!surface.hasTitleInput && !surface.hasImageInput && surface.hasVideoSurface) {
|
|
296
|
+
await page.screenshot({ path: '/tmp/xhs_publish_tab_debug.png' });
|
|
297
|
+
const detail = tabResult?.ok
|
|
298
|
+
? `clicked "${tabResult.text}"`
|
|
299
|
+
: `visible candidates: ${(tabResult?.visibleTexts || []).join(' | ') || 'none'}`;
|
|
300
|
+
throw new Error('Still on the video publish page after trying to select 图文. ' +
|
|
301
|
+
`Details: ${detail}. Debug screenshot: /tmp/xhs_publish_tab_debug.png`);
|
|
201
302
|
}
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
`);
|
|
205
|
-
if (tabClicked)
|
|
206
|
-
await page.wait({ time: 1 });
|
|
207
303
|
// ── Step 3: Upload images ──────────────────────────────────────────────────
|
|
208
304
|
if (imageData.length > 0) {
|
|
209
305
|
const upload = await injectImages(page, imageData);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './publish.js';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as os from 'node:os';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { getRegistry } from '../../registry.js';
|
|
6
|
+
import './publish.js';
|
|
7
|
+
function createPageMock(evaluateResults) {
|
|
8
|
+
const evaluate = vi.fn();
|
|
9
|
+
for (const result of evaluateResults) {
|
|
10
|
+
evaluate.mockResolvedValueOnce(result);
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
goto: vi.fn().mockResolvedValue(undefined),
|
|
14
|
+
evaluate,
|
|
15
|
+
snapshot: vi.fn().mockResolvedValue(undefined),
|
|
16
|
+
click: vi.fn().mockResolvedValue(undefined),
|
|
17
|
+
typeText: vi.fn().mockResolvedValue(undefined),
|
|
18
|
+
pressKey: vi.fn().mockResolvedValue(undefined),
|
|
19
|
+
scrollTo: vi.fn().mockResolvedValue(undefined),
|
|
20
|
+
getFormState: vi.fn().mockResolvedValue({ forms: [], orphanFields: [] }),
|
|
21
|
+
wait: vi.fn().mockResolvedValue(undefined),
|
|
22
|
+
tabs: vi.fn().mockResolvedValue([]),
|
|
23
|
+
closeTab: vi.fn().mockResolvedValue(undefined),
|
|
24
|
+
newTab: vi.fn().mockResolvedValue(undefined),
|
|
25
|
+
selectTab: vi.fn().mockResolvedValue(undefined),
|
|
26
|
+
networkRequests: vi.fn().mockResolvedValue([]),
|
|
27
|
+
consoleMessages: vi.fn().mockResolvedValue([]),
|
|
28
|
+
scroll: vi.fn().mockResolvedValue(undefined),
|
|
29
|
+
autoScroll: vi.fn().mockResolvedValue(undefined),
|
|
30
|
+
installInterceptor: vi.fn().mockResolvedValue(undefined),
|
|
31
|
+
getInterceptedRequests: vi.fn().mockResolvedValue([]),
|
|
32
|
+
getCookies: vi.fn().mockResolvedValue([]),
|
|
33
|
+
screenshot: vi.fn().mockResolvedValue(''),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
describe('xiaohongshu publish', () => {
|
|
37
|
+
it('selects the image-text tab and publishes successfully', async () => {
|
|
38
|
+
const cmd = getRegistry().get('xiaohongshu/publish');
|
|
39
|
+
expect(cmd?.func).toBeTypeOf('function');
|
|
40
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'opencli-xhs-publish-'));
|
|
41
|
+
const imagePath = path.join(tempDir, 'demo.jpg');
|
|
42
|
+
fs.writeFileSync(imagePath, Buffer.from([0xff, 0xd8, 0xff, 0xd9]));
|
|
43
|
+
const page = createPageMock([
|
|
44
|
+
'https://creator.xiaohongshu.com/publish/publish?from=menu_left',
|
|
45
|
+
{ ok: true, target: '上传图文', text: '上传图文' },
|
|
46
|
+
{ hasTitleInput: true, hasImageInput: true, hasVideoSurface: false },
|
|
47
|
+
{ ok: true, count: 1 },
|
|
48
|
+
false,
|
|
49
|
+
{ ok: true, sel: 'input[maxlength="20"]' },
|
|
50
|
+
{ ok: true, sel: '[contenteditable="true"][class*="content"]' },
|
|
51
|
+
true,
|
|
52
|
+
'https://creator.xiaohongshu.com/publish/success',
|
|
53
|
+
'发布成功',
|
|
54
|
+
]);
|
|
55
|
+
const result = await cmd.func(page, {
|
|
56
|
+
title: 'DeepSeek别乱问',
|
|
57
|
+
content: '一篇真实一点的小红书正文',
|
|
58
|
+
images: imagePath,
|
|
59
|
+
topics: '',
|
|
60
|
+
draft: false,
|
|
61
|
+
});
|
|
62
|
+
const evaluateCalls = page.evaluate.mock.calls.map((args) => String(args[0]));
|
|
63
|
+
expect(evaluateCalls.some((code) => code.includes("const targets = ['上传图文', '图文', '图片']"))).toBe(true);
|
|
64
|
+
expect(evaluateCalls.some((code) => code.includes("No image file input found on page"))).toBe(true);
|
|
65
|
+
expect(result).toEqual([
|
|
66
|
+
{
|
|
67
|
+
status: '✅ 发布成功',
|
|
68
|
+
detail: '"DeepSeek别乱问" · 1张图片 · 发布成功',
|
|
69
|
+
},
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
it('fails early with a clear error when still on the video page', async () => {
|
|
73
|
+
const cmd = getRegistry().get('xiaohongshu/publish');
|
|
74
|
+
expect(cmd?.func).toBeTypeOf('function');
|
|
75
|
+
const page = createPageMock([
|
|
76
|
+
'https://creator.xiaohongshu.com/publish/publish?from=menu_left',
|
|
77
|
+
{ ok: false, visibleTexts: ['上传视频', '上传图文'] },
|
|
78
|
+
{ hasTitleInput: false, hasImageInput: false, hasVideoSurface: true },
|
|
79
|
+
{ hasTitleInput: false, hasImageInput: false, hasVideoSurface: true },
|
|
80
|
+
{ hasTitleInput: false, hasImageInput: false, hasVideoSurface: true },
|
|
81
|
+
{ hasTitleInput: false, hasImageInput: false, hasVideoSurface: true },
|
|
82
|
+
]);
|
|
83
|
+
await expect(cmd.func(page, {
|
|
84
|
+
title: 'DeepSeek别乱问',
|
|
85
|
+
content: '一篇真实一点的小红书正文',
|
|
86
|
+
topics: '',
|
|
87
|
+
draft: false,
|
|
88
|
+
})).rejects.toThrow('Still on the video publish page after trying to select 图文');
|
|
89
|
+
expect(page.screenshot).toHaveBeenCalledWith({ path: '/tmp/xhs_publish_tab_debug.png' });
|
|
90
|
+
});
|
|
91
|
+
it('waits for the image-text surface to appear after clicking the tab', async () => {
|
|
92
|
+
const cmd = getRegistry().get('xiaohongshu/publish');
|
|
93
|
+
expect(cmd?.func).toBeTypeOf('function');
|
|
94
|
+
const page = createPageMock([
|
|
95
|
+
'https://creator.xiaohongshu.com/publish/publish?from=menu_left',
|
|
96
|
+
{ ok: true, target: '上传图文', text: '上传图文' },
|
|
97
|
+
{ hasTitleInput: false, hasImageInput: false, hasVideoSurface: true },
|
|
98
|
+
{ hasTitleInput: true, hasImageInput: true, hasVideoSurface: false },
|
|
99
|
+
{ ok: true, sel: 'input[maxlength="20"]' },
|
|
100
|
+
{ ok: true, sel: '[contenteditable="true"][class*="content"]' },
|
|
101
|
+
true,
|
|
102
|
+
'https://creator.xiaohongshu.com/publish/success',
|
|
103
|
+
'发布成功',
|
|
104
|
+
]);
|
|
105
|
+
const result = await cmd.func(page, {
|
|
106
|
+
title: '延迟切换也能过',
|
|
107
|
+
content: '图文页切换慢一点也继续等',
|
|
108
|
+
topics: '',
|
|
109
|
+
draft: false,
|
|
110
|
+
});
|
|
111
|
+
expect(page.wait.mock.calls).toContainEqual([{ time: 0.5 }]);
|
|
112
|
+
expect(result).toEqual([
|
|
113
|
+
{
|
|
114
|
+
status: '✅ 发布成功',
|
|
115
|
+
detail: '"延迟切换也能过" · 无图 · 发布成功',
|
|
116
|
+
},
|
|
117
|
+
]);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
@@ -48,7 +48,8 @@ pipeline:
|
|
|
48
48
|
exchange: ${{ item.exchange }}
|
|
49
49
|
price: ${{ item.price }}
|
|
50
50
|
changePercent: ${{ item.changePercent }}
|
|
51
|
+
url: ${{ item.url }}
|
|
51
52
|
|
|
52
53
|
- limit: ${{ args.limit }}
|
|
53
54
|
|
|
54
|
-
columns: [symbol, name, exchange, price, changePercent]
|
|
55
|
+
columns: [symbol, name, exchange, price, changePercent, url]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YouTube channel — get channel info and recent videos via InnerTube API.
|
|
3
|
+
*/
|
|
4
|
+
import { cli, Strategy } from '../../registry.js';
|
|
5
|
+
import { CommandExecutionError } from '../../errors.js';
|
|
6
|
+
cli({
|
|
7
|
+
site: 'youtube',
|
|
8
|
+
name: 'channel',
|
|
9
|
+
description: 'Get YouTube channel info and recent videos',
|
|
10
|
+
domain: 'www.youtube.com',
|
|
11
|
+
strategy: Strategy.COOKIE,
|
|
12
|
+
args: [
|
|
13
|
+
{ name: 'id', required: true, positional: true, help: 'Channel ID (UCxxxx) or handle (@name)' },
|
|
14
|
+
{ name: 'limit', type: 'int', default: 10, help: 'Max recent videos (max 30)' },
|
|
15
|
+
],
|
|
16
|
+
columns: ['field', 'value'],
|
|
17
|
+
func: async (page, kwargs) => {
|
|
18
|
+
const channelId = String(kwargs.id);
|
|
19
|
+
const limit = Math.min(kwargs.limit || 10, 30);
|
|
20
|
+
await page.goto('https://www.youtube.com');
|
|
21
|
+
await page.wait(2);
|
|
22
|
+
const data = await page.evaluate(`
|
|
23
|
+
(async () => {
|
|
24
|
+
const channelId = ${JSON.stringify(channelId)};
|
|
25
|
+
const limit = ${limit};
|
|
26
|
+
const cfg = window.ytcfg?.data_ || {};
|
|
27
|
+
const apiKey = cfg.INNERTUBE_API_KEY;
|
|
28
|
+
const context = cfg.INNERTUBE_CONTEXT;
|
|
29
|
+
if (!apiKey || !context) return {error: 'YouTube config not found'};
|
|
30
|
+
|
|
31
|
+
// Resolve handle to browseId if needed
|
|
32
|
+
let browseId = channelId;
|
|
33
|
+
if (channelId.startsWith('@')) {
|
|
34
|
+
const resolveResp = await fetch('/youtubei/v1/navigation/resolve_url?key=' + apiKey + '&prettyPrint=false', {
|
|
35
|
+
method: 'POST', credentials: 'include',
|
|
36
|
+
headers: {'Content-Type': 'application/json'},
|
|
37
|
+
body: JSON.stringify({context, url: 'https://www.youtube.com/' + channelId})
|
|
38
|
+
});
|
|
39
|
+
if (resolveResp.ok) {
|
|
40
|
+
const resolveData = await resolveResp.json();
|
|
41
|
+
browseId = resolveData.endpoint?.browseEndpoint?.browseId || channelId;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Fetch channel data
|
|
46
|
+
const resp = await fetch('/youtubei/v1/browse?key=' + apiKey + '&prettyPrint=false', {
|
|
47
|
+
method: 'POST', credentials: 'include',
|
|
48
|
+
headers: {'Content-Type': 'application/json'},
|
|
49
|
+
body: JSON.stringify({context, browseId})
|
|
50
|
+
});
|
|
51
|
+
if (!resp.ok) return {error: 'Channel API returned HTTP ' + resp.status};
|
|
52
|
+
const data = await resp.json();
|
|
53
|
+
|
|
54
|
+
// Channel metadata
|
|
55
|
+
const metadata = data.metadata?.channelMetadataRenderer || {};
|
|
56
|
+
const header = data.header?.pageHeaderRenderer || data.header?.c4TabbedHeaderRenderer || {};
|
|
57
|
+
|
|
58
|
+
// Subscriber count from header
|
|
59
|
+
let subscriberCount = '';
|
|
60
|
+
try {
|
|
61
|
+
const rows = header.content?.pageHeaderViewModel?.metadata?.contentMetadataViewModel?.metadataRows || [];
|
|
62
|
+
for (const row of rows) {
|
|
63
|
+
for (const part of (row.metadataParts || [])) {
|
|
64
|
+
const text = part.text?.content || '';
|
|
65
|
+
if (text.includes('subscriber')) subscriberCount = text;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
} catch {}
|
|
69
|
+
// Fallback for old c4TabbedHeaderRenderer format
|
|
70
|
+
if (!subscriberCount && header.subscriberCountText?.simpleText) {
|
|
71
|
+
subscriberCount = header.subscriberCountText.simpleText;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Extract recent videos from Home tab
|
|
75
|
+
const tabs = data.contents?.twoColumnBrowseResultsRenderer?.tabs || [];
|
|
76
|
+
const homeTab = tabs.find(t => t.tabRenderer?.selected);
|
|
77
|
+
const recentVideos = [];
|
|
78
|
+
|
|
79
|
+
if (homeTab) {
|
|
80
|
+
const sections = homeTab.tabRenderer?.content?.sectionListRenderer?.contents || [];
|
|
81
|
+
for (const section of sections) {
|
|
82
|
+
for (const shelf of (section.itemSectionRenderer?.contents || [])) {
|
|
83
|
+
for (const item of (shelf.shelfRenderer?.content?.horizontalListRenderer?.items || [])) {
|
|
84
|
+
// New lockupViewModel format
|
|
85
|
+
const lvm = item.lockupViewModel;
|
|
86
|
+
if (lvm && lvm.contentType === 'LOCKUP_CONTENT_TYPE_VIDEO' && recentVideos.length < limit) {
|
|
87
|
+
const meta = lvm.metadata?.lockupMetadataViewModel;
|
|
88
|
+
const rows = meta?.metadata?.contentMetadataViewModel?.metadataRows || [];
|
|
89
|
+
const viewsAndTime = (rows[0]?.metadataParts || []).map(p => p.text?.content).filter(Boolean).join(' | ');
|
|
90
|
+
let duration = '';
|
|
91
|
+
for (const ov of (lvm.contentImage?.thumbnailViewModel?.overlays || [])) {
|
|
92
|
+
for (const b of (ov.thumbnailBottomOverlayViewModel?.badges || [])) {
|
|
93
|
+
if (b.thumbnailBadgeViewModel?.text) duration = b.thumbnailBadgeViewModel.text;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
recentVideos.push({
|
|
97
|
+
title: meta?.title?.content || '',
|
|
98
|
+
duration,
|
|
99
|
+
views: viewsAndTime,
|
|
100
|
+
url: 'https://www.youtube.com/watch?v=' + lvm.contentId,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// Legacy gridVideoRenderer format
|
|
104
|
+
if (item.gridVideoRenderer && recentVideos.length < limit) {
|
|
105
|
+
const v = item.gridVideoRenderer;
|
|
106
|
+
recentVideos.push({
|
|
107
|
+
title: v.title?.runs?.[0]?.text || v.title?.simpleText || '',
|
|
108
|
+
duration: v.thumbnailOverlays?.[0]?.thumbnailOverlayTimeStatusRenderer?.text?.simpleText || '',
|
|
109
|
+
views: (v.shortViewCountText?.simpleText || '') + (v.publishedTimeText?.simpleText ? ' | ' + v.publishedTimeText.simpleText : ''),
|
|
110
|
+
url: 'https://www.youtube.com/watch?v=' + v.videoId,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
name: metadata.title || '',
|
|
120
|
+
channelId: metadata.externalId || browseId,
|
|
121
|
+
handle: metadata.vanityChannelUrl?.split('/').pop() || '',
|
|
122
|
+
description: (metadata.description || '').substring(0, 500),
|
|
123
|
+
subscribers: subscriberCount,
|
|
124
|
+
url: metadata.channelUrl || 'https://www.youtube.com/channel/' + browseId,
|
|
125
|
+
keywords: metadata.keywords || '',
|
|
126
|
+
recentVideos,
|
|
127
|
+
};
|
|
128
|
+
})()
|
|
129
|
+
`);
|
|
130
|
+
if (!data || typeof data !== 'object')
|
|
131
|
+
throw new CommandExecutionError('Failed to fetch channel data');
|
|
132
|
+
if (data.error)
|
|
133
|
+
throw new CommandExecutionError(String(data.error));
|
|
134
|
+
const result = data;
|
|
135
|
+
const videos = result.recentVideos;
|
|
136
|
+
delete result.recentVideos;
|
|
137
|
+
// Channel info as field/value pairs + recent videos as table
|
|
138
|
+
const rows = Object.entries(result).map(([field, value]) => ({
|
|
139
|
+
field,
|
|
140
|
+
value: String(value),
|
|
141
|
+
}));
|
|
142
|
+
if (videos && videos.length > 0) {
|
|
143
|
+
rows.push({ field: '---', value: '--- Recent Videos ---' });
|
|
144
|
+
for (const v of videos) {
|
|
145
|
+
rows.push({ field: v.title, value: `${v.duration} | ${v.views} | ${v.url}` });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return rows;
|
|
149
|
+
},
|
|
150
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YouTube comments — get video comments via InnerTube API.
|
|
3
|
+
*/
|
|
4
|
+
import { cli, Strategy } from '../../registry.js';
|
|
5
|
+
import { CommandExecutionError } from '../../errors.js';
|
|
6
|
+
import { parseVideoId } from './utils.js';
|
|
7
|
+
cli({
|
|
8
|
+
site: 'youtube',
|
|
9
|
+
name: 'comments',
|
|
10
|
+
description: 'Get YouTube video comments',
|
|
11
|
+
domain: 'www.youtube.com',
|
|
12
|
+
strategy: Strategy.COOKIE,
|
|
13
|
+
args: [
|
|
14
|
+
{ name: 'url', required: true, positional: true, help: 'YouTube video URL or video ID' },
|
|
15
|
+
{ name: 'limit', type: 'int', default: 20, help: 'Max comments (max 100)' },
|
|
16
|
+
],
|
|
17
|
+
columns: ['rank', 'author', 'text', 'likes', 'replies', 'time'],
|
|
18
|
+
func: async (page, kwargs) => {
|
|
19
|
+
const videoId = parseVideoId(kwargs.url);
|
|
20
|
+
const limit = Math.min(kwargs.limit || 20, 100);
|
|
21
|
+
await page.goto(`https://www.youtube.com/watch?v=${videoId}`);
|
|
22
|
+
await page.wait(3);
|
|
23
|
+
const data = await page.evaluate(`
|
|
24
|
+
(async () => {
|
|
25
|
+
const videoId = ${JSON.stringify(videoId)};
|
|
26
|
+
const limit = ${limit};
|
|
27
|
+
const cfg = window.ytcfg?.data_ || {};
|
|
28
|
+
const apiKey = cfg.INNERTUBE_API_KEY;
|
|
29
|
+
const context = cfg.INNERTUBE_CONTEXT;
|
|
30
|
+
if (!apiKey || !context) return {error: 'YouTube config not found'};
|
|
31
|
+
|
|
32
|
+
// Step 1: Get comment continuation token
|
|
33
|
+
let continuationToken = null;
|
|
34
|
+
|
|
35
|
+
// Try from current page ytInitialData
|
|
36
|
+
if (window.ytInitialData) {
|
|
37
|
+
const results = window.ytInitialData.contents?.twoColumnWatchNextResults?.results?.results?.contents || [];
|
|
38
|
+
const commentSection = results.find(i => i.itemSectionRenderer?.targetId === 'comments-section');
|
|
39
|
+
continuationToken = commentSection?.itemSectionRenderer?.contents?.[0]?.continuationItemRenderer?.continuationEndpoint?.continuationCommand?.token;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Fallback: fetch via next API
|
|
43
|
+
if (!continuationToken) {
|
|
44
|
+
const nextResp = await fetch('/youtubei/v1/next?key=' + apiKey + '&prettyPrint=false', {
|
|
45
|
+
method: 'POST', credentials: 'include',
|
|
46
|
+
headers: {'Content-Type': 'application/json'},
|
|
47
|
+
body: JSON.stringify({context, videoId})
|
|
48
|
+
});
|
|
49
|
+
if (!nextResp.ok) return {error: 'Failed to get video data: HTTP ' + nextResp.status};
|
|
50
|
+
const nextData = await nextResp.json();
|
|
51
|
+
const results = nextData.contents?.twoColumnWatchNextResults?.results?.results?.contents || [];
|
|
52
|
+
const commentSection = results.find(i => i.itemSectionRenderer?.targetId === 'comments-section');
|
|
53
|
+
continuationToken = commentSection?.itemSectionRenderer?.contents?.[0]?.continuationItemRenderer?.continuationEndpoint?.continuationCommand?.token;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!continuationToken) return {error: 'No comment section found — comments may be disabled'};
|
|
57
|
+
|
|
58
|
+
// Step 2: Fetch comments
|
|
59
|
+
const commentResp = await fetch('/youtubei/v1/next?key=' + apiKey + '&prettyPrint=false', {
|
|
60
|
+
method: 'POST', credentials: 'include',
|
|
61
|
+
headers: {'Content-Type': 'application/json'},
|
|
62
|
+
body: JSON.stringify({context, continuation: continuationToken})
|
|
63
|
+
});
|
|
64
|
+
if (!commentResp.ok) return {error: 'Failed to fetch comments: HTTP ' + commentResp.status};
|
|
65
|
+
const commentData = await commentResp.json();
|
|
66
|
+
|
|
67
|
+
// Parse from frameworkUpdates (new ViewModel format)
|
|
68
|
+
const mutations = commentData.frameworkUpdates?.entityBatchUpdate?.mutations || [];
|
|
69
|
+
const commentEntities = mutations.filter(m => m.payload?.commentEntityPayload);
|
|
70
|
+
|
|
71
|
+
return commentEntities.slice(0, limit).map((m, i) => {
|
|
72
|
+
const p = m.payload.commentEntityPayload;
|
|
73
|
+
const props = p.properties || {};
|
|
74
|
+
const author = p.author || {};
|
|
75
|
+
const toolbar = p.toolbar || {};
|
|
76
|
+
return {
|
|
77
|
+
rank: i + 1,
|
|
78
|
+
author: author.displayName || '',
|
|
79
|
+
text: (props.content?.content || '').substring(0, 300),
|
|
80
|
+
likes: toolbar.likeCountNotliked || '0',
|
|
81
|
+
replies: toolbar.replyCount || '0',
|
|
82
|
+
time: props.publishedTime || '',
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
})()
|
|
86
|
+
`);
|
|
87
|
+
if (!Array.isArray(data)) {
|
|
88
|
+
const errMsg = data && typeof data === 'object' ? String(data.error || '') : '';
|
|
89
|
+
if (errMsg)
|
|
90
|
+
throw new CommandExecutionError(errMsg);
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
return data;
|
|
94
|
+
},
|
|
95
|
+
});
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { Command } from 'commander';
|
|
13
13
|
import { type CliCommand } from './registry.js';
|
|
14
|
+
export declare function normalizeArgValue(argType: string | undefined, value: unknown, name: string): unknown;
|
|
14
15
|
/**
|
|
15
16
|
* Register a single CliCommand as a Commander subcommand.
|
|
16
17
|
*/
|