koishi-plugin-kkk 1.0.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/CHANGELOG.md +57 -0
- package/LICENSE +674 -0
- package/README.md +98 -0
- package/assets/web/assets/CronEditor-CYgFpX-g.js +1 -0
- package/assets/web/assets/DesktopLayout-iI43ij11.js +1 -0
- package/assets/web/assets/MobileLayout-CziU8MCR.js +1 -0
- package/assets/web/assets/ThemeSwitch-DFohhwd9.js +1 -0
- package/assets/web/assets/index-BRROK0vh.js +47 -0
- package/assets/web/assets/index-Dj-StEiS.css +2 -0
- package/assets/web/assets/separator-CxcFlCzz.js +1 -0
- package/assets/web/favicon.svg +1 -0
- package/assets/web/icons.svg +24 -0
- package/assets/web/index.html +15 -0
- package/assets/webui.html +115 -0
- package/client/index.ts +63 -0
- package/config/default_config/app.yaml +64 -0
- package/config/default_config/bilibili.yaml +116 -0
- package/config/default_config/config.json +157 -0
- package/config/default_config/cookies.yaml +11 -0
- package/config/default_config/douyin.yaml +99 -0
- package/config/default_config/kuaishou.yaml +8 -0
- package/config/default_config/pushlist.yaml +37 -0
- package/config/default_config/request.yaml +22 -0
- package/config/default_config/upload.yaml +50 -0
- package/config/default_config/xiaohongshu.yaml +23 -0
- package/dist/index.js +1 -0
- package/lib/compat/axios.js +23 -0
- package/lib/compat/cron.js +77 -0
- package/lib/compat/esm.js +15 -0
- package/lib/compat/express.js +23 -0
- package/lib/compat/heroui.js +12 -0
- package/lib/compat/lodash.js +33 -0
- package/lib/compat/logger.js +118 -0
- package/lib/compat/node-karin.js +1053 -0
- package/lib/compat/phosphor-icons.js +27 -0
- package/lib/compat/qqcard.js +256 -0
- package/lib/compat/root.js +44 -0
- package/lib/compat/runtime.js +87 -0
- package/lib/compat/segment.js +167 -0
- package/lib/compat/sqlite3.js +117 -0
- package/lib/compat/start.js +7 -0
- package/lib/compat/syncConfig.js +65 -0
- package/lib/compat/template-react.js +30 -0
- package/lib/compat/text.js +65 -0
- package/lib/compat/yaml.js +13 -0
- package/lib/configBridge.js +91 -0
- package/lib/index.js +775 -0
- package/lib/karin/app.js +34 -0
- package/lib/karin/apps/__ready.js +9 -0
- package/lib/karin/apps/admin.js +136 -0
- package/lib/karin/apps/help.js +233 -0
- package/lib/karin/apps/push.js +291 -0
- package/lib/karin/apps/qrlogin.js +176 -0
- package/lib/karin/apps/statistics.js +209 -0
- package/lib/karin/apps/testPush.js +247 -0
- package/lib/karin/apps/tools.js +473 -0
- package/lib/karin/apps/update.js +252 -0
- package/lib/karin/index.js +37 -0
- package/lib/karin/module/db/bilibili.js +831 -0
- package/lib/karin/module/db/douyin.js +918 -0
- package/lib/karin/module/db/index.js +165 -0
- package/lib/karin/module/db/migration.js +199 -0
- package/lib/karin/module/db/statistics.js +559 -0
- package/lib/karin/module/index.js +94 -0
- package/lib/karin/module/server/constants/routes.js +48 -0
- package/lib/karin/module/server/controllers/bots.js +230 -0
- package/lib/karin/module/server/controllers/config.js +75 -0
- package/lib/karin/module/server/controllers/video.js +208 -0
- package/lib/karin/module/server/index.js +26 -0
- package/lib/karin/module/server/middlewares/auth.js +133 -0
- package/lib/karin/module/server/routes/amagi.js +57 -0
- package/lib/karin/module/server/routes/api.js +40 -0
- package/lib/karin/module/server/routes/index.js +97 -0
- package/lib/karin/module/server/routes/ssr.js +16 -0
- package/lib/karin/module/server/routes/static.js +43 -0
- package/lib/karin/module/utils/Base.js +403 -0
- package/lib/karin/module/utils/CardParser.js +487 -0
- package/lib/karin/module/utils/Common.js +418 -0
- package/lib/karin/module/utils/Config.js +434 -0
- package/lib/karin/module/utils/EmojiReaction.js +242 -0
- package/lib/karin/module/utils/ErrorHandler/handler.js +114 -0
- package/lib/karin/module/utils/ErrorHandler/index.js +55 -0
- package/lib/karin/module/utils/ErrorHandler/render.js +182 -0
- package/lib/karin/module/utils/ErrorHandler/sender.js +206 -0
- package/lib/karin/module/utils/ErrorHandler/strategy.js +41 -0
- package/lib/karin/module/utils/ErrorHandler/types.js +2 -0
- package/lib/karin/module/utils/ErrorHandler/utils.js +108 -0
- package/lib/karin/module/utils/FFmpeg.js +298 -0
- package/lib/karin/module/utils/ImageHelper.js +91 -0
- package/lib/karin/module/utils/ImageSlice.js +429 -0
- package/lib/karin/module/utils/MotionPhoto.js +250 -0
- package/lib/karin/module/utils/Network/Downloader.js +413 -0
- package/lib/karin/module/utils/Network/ImageDownloader.js +250 -0
- package/lib/karin/module/utils/Network/Network.js +332 -0
- package/lib/karin/module/utils/Network/ThrottleStream.js +71 -0
- package/lib/karin/module/utils/Network/constants.js +129 -0
- package/lib/karin/module/utils/Network/helpers.js +174 -0
- package/lib/karin/module/utils/Network/index.js +34 -0
- package/lib/karin/module/utils/Network/types.js +12 -0
- package/lib/karin/module/utils/Networks.js +17 -0
- package/lib/karin/module/utils/ParseLock.js +34 -0
- package/lib/karin/module/utils/ParseOverride.js +88 -0
- package/lib/karin/module/utils/QqCardResolve.js +114 -0
- package/lib/karin/module/utils/QqPanel.js +879 -0
- package/lib/karin/module/utils/Render/coverTheme.js +256 -0
- package/lib/karin/module/utils/Render/index.js +582 -0
- package/lib/karin/module/utils/amagiClient.js +338 -0
- package/lib/karin/module/utils/avatar.js +201 -0
- package/lib/karin/module/utils/bot.js +141 -0
- package/lib/karin/module/utils/build-metadata.js +50 -0
- package/lib/karin/module/utils/changelog.js +166 -0
- package/lib/karin/module/utils/index.js +26 -0
- package/lib/karin/module/utils/loginSession.js +259 -0
- package/lib/karin/module/utils/parseTip.js +93 -0
- package/lib/karin/module/utils/runtime-report.js +140 -0
- package/lib/karin/module/utils/semver.js +72 -0
- package/lib/karin/module/utils/statisticsAggregate.js +415 -0
- package/lib/karin/platform/bilibili/bilibili.js +1805 -0
- package/lib/karin/platform/bilibili/comments.js +294 -0
- package/lib/karin/platform/bilibili/danmaku.js +555 -0
- package/lib/karin/platform/bilibili/dynamic-text.js +827 -0
- package/lib/karin/platform/bilibili/genParams.js +37 -0
- package/lib/karin/platform/bilibili/getID.js +159 -0
- package/lib/karin/platform/bilibili/index.js +24 -0
- package/lib/karin/platform/bilibili/live-status.js +40 -0
- package/lib/karin/platform/bilibili/login.js +132 -0
- package/lib/karin/platform/bilibili/push.js +1397 -0
- package/lib/karin/platform/bilibili/riskControl.js +133 -0
- package/lib/karin/platform/bilibili/search.js +299 -0
- package/lib/karin/platform/common/danmaku-types.js +12 -0
- package/lib/karin/platform/douyin/comments.js +310 -0
- package/lib/karin/platform/douyin/danmaku.js +893 -0
- package/lib/karin/platform/douyin/douyin.js +1145 -0
- package/lib/karin/platform/douyin/getID.js +94 -0
- package/lib/karin/platform/douyin/index.js +24 -0
- package/lib/karin/platform/douyin/login.js +230 -0
- package/lib/karin/platform/douyin/push/favorite.js +75 -0
- package/lib/karin/platform/douyin/push/index.js +21 -0
- package/lib/karin/platform/douyin/push/live.js +69 -0
- package/lib/karin/platform/douyin/push/post.js +60 -0
- package/lib/karin/platform/douyin/push/recommend.js +74 -0
- package/lib/karin/platform/douyin/push/render.js +621 -0
- package/lib/karin/platform/douyin/push/types.js +2 -0
- package/lib/karin/platform/douyin/push.js +1128 -0
- package/lib/karin/platform/douyin/types.js +13 -0
- package/lib/karin/platform/douyin/videoQuality.js +222 -0
- package/lib/karin/platform/douyin/workType.js +182 -0
- package/lib/karin/platform/index.js +20 -0
- package/lib/karin/platform/kuaishou/comments.js +91 -0
- package/lib/karin/platform/kuaishou/getID.js +43 -0
- package/lib/karin/platform/kuaishou/getdata.js +41 -0
- package/lib/karin/platform/kuaishou/index.js +20 -0
- package/lib/karin/platform/kuaishou/kuaishou.js +122 -0
- package/lib/karin/platform/xiaohongshu/comments.js +162 -0
- package/lib/karin/platform/xiaohongshu/getID.js +129 -0
- package/lib/karin/platform/xiaohongshu/index.js +18 -0
- package/lib/karin/platform/xiaohongshu/xiaohongshu.js +643 -0
- package/lib/karin/root.js +73 -0
- package/lib/karin/setup.js +99 -0
- package/lib/karin/types/config/amagi.js +2 -0
- package/lib/karin/types/config/app.js +2 -0
- package/lib/karin/types/config/bilibili.js +2 -0
- package/lib/karin/types/config/cookies.js +2 -0
- package/lib/karin/types/config/douyin.js +2 -0
- package/lib/karin/types/config/index.js +2 -0
- package/lib/karin/types/config/kuaishou.js +2 -0
- package/lib/karin/types/config/pushlist.js +2 -0
- package/lib/karin/types/config/request.js +2 -0
- package/lib/karin/types/config/upload.js +2 -0
- package/lib/karin/types/config/xiaohongshu.js +2 -0
- package/lib/karin/types/datatypes.js +2 -0
- package/lib/karin/types/index.js +18 -0
- package/lib/karin/types/netrorks/NetworksConfigType.js +2 -0
- package/lib/karin/types/netrorks/index.js +17 -0
- package/lib/karin/web.config.js +49 -0
- package/lib/ktr/registry.js +82 -0
- package/lib/ktr/template/_preview/components/PreviewInfoCard.js +10 -0
- package/lib/ktr/template/_preview/components/PreviewLayout.js +10 -0
- package/lib/ktr/template/_preview/components/PreviewVideoCard.js +8 -0
- package/lib/ktr/template/_preview/render.js +142 -0
- package/lib/ktr/template/_preview/types.js +2 -0
- package/lib/ktr/template/_preview/utils/status.js +31 -0
- package/lib/ktr/template/_preview/utils/time.js +12 -0
- package/lib/ktr/template/bilibili/bangumi/components/bangumi.js +127 -0
- package/lib/ktr/template/bilibili/bangumi/components/types.js +2 -0
- package/lib/ktr/template/bilibili/bangumi/index.js +12 -0
- package/lib/ktr/template/bilibili/comment/components/Comment.js +193 -0
- package/lib/ktr/template/bilibili/comment/components/types.js +2 -0
- package/lib/ktr/template/bilibili/comment/index.js +10 -0
- package/lib/ktr/template/bilibili/components/Icons.js +66 -0
- package/lib/ktr/template/bilibili/components/shared.js +93 -0
- package/lib/ktr/template/bilibili/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/DYNAMIC_TYPE_ARTICLE.js +66 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/DYNAMIC_TYPE_AV.js +87 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/DYNAMIC_TYPE_DRAW.js +93 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/DYNAMIC_TYPE_FORWARD.js +132 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/DYNAMIC_TYPE_LIVE_RCMD.js +84 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/DYNAMIC_TYPE_WORD.js +38 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/components/AdditionalCard.js +59 -0
- package/lib/ktr/template/bilibili/dynamic/components/CommonComponents.js +30 -0
- package/lib/ktr/template/bilibili/dynamic/types.js +2 -0
- package/lib/ktr/template/bilibili/qrcodeImg/components/qrcodeImg.js +48 -0
- package/lib/ktr/template/bilibili/qrcodeImg/components/types.js +3 -0
- package/lib/ktr/template/bilibili/qrcodeImg/index.js +10 -0
- package/lib/ktr/template/bilibili/userlist/components/UserList.js +53 -0
- package/lib/ktr/template/bilibili/userlist/components/types.js +3 -0
- package/lib/ktr/template/bilibili/userlist/index.js +13 -0
- package/lib/ktr/template/bilibili/videoInfo/components/types.js +2 -0
- package/lib/ktr/template/bilibili/videoInfo/components/videoInfo.js +62 -0
- package/lib/ktr/template/bilibili/videoInfo/index.js +10 -0
- package/lib/ktr/template/components/AmbientCover.js +36 -0
- package/lib/ktr/template/components/DefaultLayout.js +33 -0
- package/lib/ktr/template/components/GlowImage.js +276 -0
- package/lib/ktr/template/components/QRCodeWithAvatar.js +34 -0
- package/lib/ktr/template/components/RolldownLogo.js +6 -0
- package/lib/ktr/template/components/ViteLogo.js +6 -0
- package/lib/ktr/template/components/iconRegistry.js +173 -0
- package/lib/ktr/template/douyin/article-work/components/ArticleWork.js +99 -0
- package/lib/ktr/template/douyin/article-work/components/types.js +3 -0
- package/lib/ktr/template/douyin/article-work/index.js +10 -0
- package/lib/ktr/template/douyin/comment/components/Comment.js +189 -0
- package/lib/ktr/template/douyin/comment/components/types.js +2 -0
- package/lib/ktr/template/douyin/comment/index.js +10 -0
- package/lib/ktr/template/douyin/components/Icons.js +29 -0
- package/lib/ktr/template/douyin/components/types.js +3 -0
- package/lib/ktr/template/douyin/dynamic/components/Dynamic.js +90 -0
- package/lib/ktr/template/douyin/dynamic/components/types.js +3 -0
- package/lib/ktr/template/douyin/dynamic/index.js +10 -0
- package/lib/ktr/template/douyin/favorite-list/components/FavoriteList.js +30 -0
- package/lib/ktr/template/douyin/favorite-list/components/types.js +3 -0
- package/lib/ktr/template/douyin/favorite-list/index.js +10 -0
- package/lib/ktr/template/douyin/image-work/components/ImageWork.js +136 -0
- package/lib/ktr/template/douyin/image-work/components/types.js +2 -0
- package/lib/ktr/template/douyin/image-work/index.js +10 -0
- package/lib/ktr/template/douyin/live/components/Live.js +51 -0
- package/lib/ktr/template/douyin/live/components/types.js +3 -0
- package/lib/ktr/template/douyin/live/index.js +10 -0
- package/lib/ktr/template/douyin/musicinfo/components/MusicInfo.js +60 -0
- package/lib/ktr/template/douyin/musicinfo/components/types.js +3 -0
- package/lib/ktr/template/douyin/musicinfo/index.js +10 -0
- package/lib/ktr/template/douyin/qrcodeImg/components/qrcodeImg.js +39 -0
- package/lib/ktr/template/douyin/qrcodeImg/components/types.js +3 -0
- package/lib/ktr/template/douyin/qrcodeImg/index.js +9 -0
- package/lib/ktr/template/douyin/recommend-list/components/RecommendList.js +30 -0
- package/lib/ktr/template/douyin/recommend-list/components/types.js +3 -0
- package/lib/ktr/template/douyin/recommend-list/index.js +10 -0
- package/lib/ktr/template/douyin/user_profile/components/UserVideoList.js +54 -0
- package/lib/ktr/template/douyin/user_profile/components/types.js +3 -0
- package/lib/ktr/template/douyin/user_profile/index.js +9 -0
- package/lib/ktr/template/douyin/userlist/components/UserList.js +50 -0
- package/lib/ktr/template/douyin/userlist/components/types.js +3 -0
- package/lib/ktr/template/douyin/userlist/index.js +13 -0
- package/lib/ktr/template/douyin/video-work/components/VideoWork.js +127 -0
- package/lib/ktr/template/douyin/video-work/components/types.js +2 -0
- package/lib/ktr/template/douyin/video-work/index.js +10 -0
- package/lib/ktr/template/kuaishou/comment/components/Comment.js +88 -0
- package/lib/ktr/template/kuaishou/comment/components/types.js +2 -0
- package/lib/ktr/template/kuaishou/comment/index.js +10 -0
- package/lib/ktr/template/other/changelog/components/changelog.js +117 -0
- package/lib/ktr/template/other/changelog/components/types.js +3 -0
- package/lib/ktr/template/other/changelog/index.js +9 -0
- package/lib/ktr/template/other/handlerError/components/errorTitles.js +227 -0
- package/lib/ktr/template/other/handlerError/components/handlerError.js +392 -0
- package/lib/ktr/template/other/handlerError/components/stackHighlight.js +109 -0
- package/lib/ktr/template/other/handlerError/components/types.js +2 -0
- package/lib/ktr/template/other/handlerError/index.js +9 -0
- package/lib/ktr/template/other/help/components/Help.js +79 -0
- package/lib/ktr/template/other/help/components/types.js +3 -0
- package/lib/ktr/template/other/help/index.js +12 -0
- package/lib/ktr/template/other/live-photo-tip/components/LivePhotoTip.js +80 -0
- package/lib/ktr/template/other/live-photo-tip/components/types.js +3 -0
- package/lib/ktr/template/other/live-photo-tip/index.js +9 -0
- package/lib/ktr/template/other/qrlogin/components/qrlogin.js +58 -0
- package/lib/ktr/template/other/qrlogin/components/types.js +3 -0
- package/lib/ktr/template/other/qrlogin/index.js +9 -0
- package/lib/ktr/template/other/runtime/components/runtime.js +101 -0
- package/lib/ktr/template/other/runtime/components/types.js +3 -0
- package/lib/ktr/template/other/runtime/index.js +9 -0
- package/lib/ktr/template/other/version_warning/components/VersionWarning.js +38 -0
- package/lib/ktr/template/other/version_warning/components/types.js +3 -0
- package/lib/ktr/template/other/version_warning/index.js +9 -0
- package/lib/ktr/template/statistics/components/BoxplotGuide.js +17 -0
- package/lib/ktr/template/statistics/components/ChartCard.js +15 -0
- package/lib/ktr/template/statistics/components/KpiCard.js +14 -0
- package/lib/ktr/template/statistics/components/PlatformTable.js +20 -0
- package/lib/ktr/template/statistics/components/RankList.js +61 -0
- package/lib/ktr/template/statistics/components/SSRChart.js +22 -0
- package/lib/ktr/template/statistics/components/chartPresets.js +630 -0
- package/lib/ktr/template/statistics/components/chartTheme.js +226 -0
- package/lib/ktr/template/statistics/components/format.js +38 -0
- package/lib/ktr/template/statistics/components/types.js +9 -0
- package/lib/ktr/template/statistics/global/components/GlobalStatistics.js +246 -0
- package/lib/ktr/template/statistics/global/components/types.js +3 -0
- package/lib/ktr/template/statistics/global/index.js +9 -0
- package/lib/ktr/template/statistics/group/components/GroupStatistics.js +181 -0
- package/lib/ktr/template/statistics/group/components/types.js +3 -0
- package/lib/ktr/template/statistics/group/index.js +9 -0
- package/lib/ktr/template/types/ctx.js +2 -0
- package/lib/ktr/template/xiaohongshu/comment/components/Comment.js +99 -0
- package/lib/ktr/template/xiaohongshu/comment/components/types.js +3 -0
- package/lib/ktr/template/xiaohongshu/comment/index.js +9 -0
- package/lib/ktr/template/xiaohongshu/noteInfo/components/noteInfo.js +93 -0
- package/lib/ktr/template/xiaohongshu/noteInfo/components/types.js +2 -0
- package/lib/ktr/template/xiaohongshu/noteInfo/index.js +9 -0
- package/lib/ktr/utils/QRCodeAvatar.js +99 -0
- package/lib/ktr/utils/QRcode.js +56 -0
- package/lib/ktr/utils/avatarProxy.js +45 -0
- package/lib/ktr/utils/cn.js +11 -0
- package/lib/ktr/utils/theme.js +12 -0
- package/lib/qqFields.json +75 -0
- package/lib/qqOptions.js +44 -0
- package/lib/richtext/index.js +25 -0
- package/lib/richtext/parse/index.js +232 -0
- package/lib/richtext/react/cn.js +11 -0
- package/lib/richtext/react/index.js +221 -0
- package/lib/richtext/types.js +2 -0
- package/lib/schema.js +352 -0
- package/lib/webui.js +341 -0
- package/package.json +88 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_BV.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_GOODS.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_LOTTERY.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_VIEW_PICTURE.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_VOTE.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_WEB.svg +1 -0
- package/resources/image/bilibili/bilibili-dark.png +0 -0
- package/resources/image/bilibili/bilibili-light.png +0 -0
- package/resources/image/bilibili/bilibili.png +0 -0
- package/resources/image/bilibili/id-dark.svg +1 -0
- package/resources/image/bilibili/id-light.svg +1 -0
- package/resources/image/bilibili/level/lv0.svg +1 -0
- package/resources/image/bilibili/level/lv1.svg +1 -0
- package/resources/image/bilibili/level/lv2.svg +1 -0
- package/resources/image/bilibili/level/lv3.svg +1 -0
- package/resources/image/bilibili/level/lv4.svg +1 -0
- package/resources/image/bilibili/level/lv5.svg +1 -0
- package/resources/image/bilibili/level/lv6.svg +1 -0
- package/resources/image/bilibili/level/lv7.svg +1 -0
- package/resources/image/bilibili/like-dark.svg +6 -0
- package/resources/image/bilibili/like-light.svg +6 -0
- package/resources/image/bilibili/play.svg +28 -0
- package/resources/image/bilibili/res-local1.png +0 -0
- package/resources/image/bilibili/up_pb.svg +1 -0
- package/resources/image/bilibili//347/233/264/346/222/255/344/270/255.png +0 -0
- package/resources/image/douyin/douyin.png +0 -0
- package/resources/image/douyin/dylogo-dark.svg +23 -0
- package/resources/image/douyin/dylogo-light.svg +38 -0
- package/resources/image/douyin/search-dark.svg +1 -0
- package/resources/image/douyin/search-light.svg +3 -0
- package/resources/image/douyin//346/212/226/351/237/263-/347/233/264/346/222/255/344/270/255.png +0 -0
- package/resources/image/frame-logo.png +0 -0
- package/resources/image/kuaishou/logo.png +0 -0
- package/resources/image/other/handlerError/Milky.png +0 -0
- package/resources/image/other/handlerError/chronocat.svg +43 -0
- package/resources/image/other/handlerError/conwechat.webp +0 -0
- package/resources/image/other/handlerError/gocq-http.webp +0 -0
- package/resources/image/other/handlerError/lagrange.webp +0 -0
- package/resources/image/other/handlerError/llonebot.webp +0 -0
- package/resources/image/other/handlerError/napcat.webp +0 -0
- package/resources/image/other/handlerError/onebot.png +0 -0
- package/resources/image/other/handlerError/satori.png +0 -0
- package/resources/image/xiaohongshu/logo.png +0 -0
- package/resources/template/style.css +23708 -0
- package/resources/vite.svg +130 -0
- package/scripts/build.mjs +129 -0
- package/scripts/check-schema.cjs +55 -0
- package/scripts/deploy.mjs +78 -0
- package/scripts/make-demo-placeholders.mjs +112 -0
- package/scripts/patch-deps.mjs +46 -0
- package/scripts/patch-webui.mjs +112 -0
- package/scripts/smoke-commands.cjs +39 -0
- package/scripts/smoke-config.cjs +122 -0
- package/scripts/smoke-douyin.cjs +170 -0
- package/scripts/smoke-koishi-commands.cjs +210 -0
- package/scripts/smoke-login.cjs +110 -0
- package/scripts/smoke-parse.cjs +54 -0
- package/scripts/smoke-push-mock.cjs +114 -0
- package/scripts/smoke-push.cjs +104 -0
- package/scripts/smoke-qq.cjs +147 -0
- package/scripts/smoke-qqcard.cjs +108 -0
- package/scripts/smoke-qqpanel.cjs +205 -0
- package/scripts/smoke-render.cjs +106 -0
- package/scripts/smoke-server.cjs +94 -0
- package/src/compat/axios.ts +5 -0
- package/src/compat/cron.ts +86 -0
- package/src/compat/esm.ts +13 -0
- package/src/compat/express.ts +5 -0
- package/src/compat/heroui.tsx +53 -0
- package/src/compat/lodash.ts +32 -0
- package/src/compat/logger.ts +121 -0
- package/src/compat/node-karin.ts +1064 -0
- package/src/compat/phosphor-icons.tsx +25 -0
- package/src/compat/qqcard.ts +251 -0
- package/src/compat/root.ts +44 -0
- package/src/compat/runtime.ts +120 -0
- package/src/compat/segment.ts +161 -0
- package/src/compat/sqlite3.ts +123 -0
- package/src/compat/start.ts +3 -0
- package/src/compat/syncConfig.ts +64 -0
- package/src/compat/template-react.ts +54 -0
- package/src/compat/text.ts +58 -0
- package/src/compat/yaml.ts +6 -0
- package/src/configBridge.ts +94 -0
- package/src/index.ts +769 -0
- package/src/karin/app.ts +1 -0
- package/src/karin/apps/__ready.ts +14 -0
- package/src/karin/apps/admin.ts +127 -0
- package/src/karin/apps/help.ts +228 -0
- package/src/karin/apps/push.ts +327 -0
- package/src/karin/apps/qrlogin.ts +160 -0
- package/src/karin/apps/statistics.ts +203 -0
- package/src/karin/apps/testPush.ts +226 -0
- package/src/karin/apps/tools.ts +510 -0
- package/src/karin/apps/update.ts +239 -0
- package/src/karin/index.ts +9 -0
- package/src/karin/module/db/bilibili.ts +1089 -0
- package/src/karin/module/db/douyin.ts +1218 -0
- package/src/karin/module/db/index.ts +159 -0
- package/src/karin/module/db/migration.ts +249 -0
- package/src/karin/module/db/statistics.ts +817 -0
- package/src/karin/module/index.ts +37 -0
- package/src/karin/module/server/constants/routes.ts +53 -0
- package/src/karin/module/server/controllers/bots.ts +289 -0
- package/src/karin/module/server/controllers/config.ts +85 -0
- package/src/karin/module/server/controllers/video.ts +212 -0
- package/src/karin/module/server/index.ts +11 -0
- package/src/karin/module/server/middlewares/auth.ts +147 -0
- package/src/karin/module/server/routes/amagi.ts +57 -0
- package/src/karin/module/server/routes/api.ts +42 -0
- package/src/karin/module/server/routes/index.ts +68 -0
- package/src/karin/module/server/routes/ssr.ts +14 -0
- package/src/karin/module/server/routes/static.ts +43 -0
- package/src/karin/module/utils/Base.ts +497 -0
- package/src/karin/module/utils/CardParser.ts +503 -0
- package/src/karin/module/utils/Common.ts +448 -0
- package/src/karin/module/utils/Config.ts +443 -0
- package/src/karin/module/utils/EmojiReaction.ts +268 -0
- package/src/karin/module/utils/ErrorHandler/handler.ts +124 -0
- package/src/karin/module/utils/ErrorHandler/index.ts +48 -0
- package/src/karin/module/utils/ErrorHandler/render.ts +180 -0
- package/src/karin/module/utils/ErrorHandler/sender.ts +192 -0
- package/src/karin/module/utils/ErrorHandler/strategy.ts +41 -0
- package/src/karin/module/utils/ErrorHandler/types.ts +122 -0
- package/src/karin/module/utils/ErrorHandler/utils.ts +108 -0
- package/src/karin/module/utils/FFmpeg.ts +357 -0
- package/src/karin/module/utils/ImageHelper.ts +90 -0
- package/src/karin/module/utils/ImageSlice.ts +383 -0
- package/src/karin/module/utils/MotionPhoto.ts +297 -0
- package/src/karin/module/utils/Network/Downloader.ts +481 -0
- package/src/karin/module/utils/Network/ImageDownloader.ts +291 -0
- package/src/karin/module/utils/Network/Network.ts +344 -0
- package/src/karin/module/utils/Network/ThrottleStream.ts +76 -0
- package/src/karin/module/utils/Network/constants.ts +135 -0
- package/src/karin/module/utils/Network/helpers.ts +183 -0
- package/src/karin/module/utils/Network/index.ts +28 -0
- package/src/karin/module/utils/Network/types.ts +46 -0
- package/src/karin/module/utils/Networks.ts +20 -0
- package/src/karin/module/utils/ParseLock.ts +33 -0
- package/src/karin/module/utils/ParseOverride.ts +128 -0
- package/src/karin/module/utils/QqCardResolve.ts +116 -0
- package/src/karin/module/utils/QqPanel.ts +880 -0
- package/src/karin/module/utils/Render/coverTheme.ts +294 -0
- package/src/karin/module/utils/Render/index.ts +574 -0
- package/src/karin/module/utils/amagiClient.ts +368 -0
- package/src/karin/module/utils/avatar.ts +220 -0
- package/src/karin/module/utils/bot.ts +115 -0
- package/src/karin/module/utils/build-metadata.ts +60 -0
- package/src/karin/module/utils/changelog.ts +175 -0
- package/src/karin/module/utils/index.ts +10 -0
- package/src/karin/module/utils/loginSession.ts +291 -0
- package/src/karin/module/utils/parseTip.ts +59 -0
- package/src/karin/module/utils/runtime-report.ts +142 -0
- package/src/karin/module/utils/semver.ts +60 -0
- package/src/karin/module/utils/statisticsAggregate.ts +507 -0
- package/src/karin/platform/bilibili/bilibili.ts +2004 -0
- package/src/karin/platform/bilibili/comments.ts +397 -0
- package/src/karin/platform/bilibili/danmaku.ts +653 -0
- package/src/karin/platform/bilibili/dynamic-text.ts +926 -0
- package/src/karin/platform/bilibili/genParams.ts +30 -0
- package/src/karin/platform/bilibili/getID.ts +163 -0
- package/src/karin/platform/bilibili/index.ts +8 -0
- package/src/karin/platform/bilibili/live-status.ts +36 -0
- package/src/karin/platform/bilibili/login.ts +130 -0
- package/src/karin/platform/bilibili/push.ts +1615 -0
- package/src/karin/platform/bilibili/riskControl.ts +114 -0
- package/src/karin/platform/bilibili/search.ts +305 -0
- package/src/karin/platform/common/danmaku-types.ts +18 -0
- package/src/karin/platform/douyin/comments.ts +404 -0
- package/src/karin/platform/douyin/danmaku.ts +1187 -0
- package/src/karin/platform/douyin/douyin.ts +1244 -0
- package/src/karin/platform/douyin/getID.ts +101 -0
- package/src/karin/platform/douyin/index.ts +8 -0
- package/src/karin/platform/douyin/login.ts +251 -0
- package/src/karin/platform/douyin/push/favorite.ts +97 -0
- package/src/karin/platform/douyin/push/index.ts +5 -0
- package/src/karin/platform/douyin/push/live.ts +86 -0
- package/src/karin/platform/douyin/push/post.ts +75 -0
- package/src/karin/platform/douyin/push/recommend.ts +96 -0
- package/src/karin/platform/douyin/push/render.ts +768 -0
- package/src/karin/platform/douyin/push/types.ts +41 -0
- package/src/karin/platform/douyin/push.ts +1241 -0
- package/src/karin/platform/douyin/types.ts +151 -0
- package/src/karin/platform/douyin/videoQuality.ts +234 -0
- package/src/karin/platform/douyin/workType.ts +238 -0
- package/src/karin/platform/index.ts +4 -0
- package/src/karin/platform/kuaishou/comments.ts +114 -0
- package/src/karin/platform/kuaishou/getID.ts +48 -0
- package/src/karin/platform/kuaishou/getdata.ts +78 -0
- package/src/karin/platform/kuaishou/index.ts +4 -0
- package/src/karin/platform/kuaishou/kuaishou.ts +130 -0
- package/src/karin/platform/xiaohongshu/comments.ts +227 -0
- package/src/karin/platform/xiaohongshu/getID.ts +127 -0
- package/src/karin/platform/xiaohongshu/index.ts +2 -0
- package/src/karin/platform/xiaohongshu/xiaohongshu.ts +733 -0
- package/src/karin/root.ts +78 -0
- package/src/karin/setup.ts +77 -0
- package/src/karin/types/config/amagi.ts +46 -0
- package/src/karin/types/config/app.ts +129 -0
- package/src/karin/types/config/bilibili.ts +121 -0
- package/src/karin/types/config/cookies.ts +11 -0
- package/src/karin/types/config/douyin.ts +93 -0
- package/src/karin/types/config/index.ts +41 -0
- package/src/karin/types/config/kuaishou.ts +10 -0
- package/src/karin/types/config/pushlist.ts +55 -0
- package/src/karin/types/config/request.ts +27 -0
- package/src/karin/types/config/upload.ts +49 -0
- package/src/karin/types/config/xiaohongshu.ts +24 -0
- package/src/karin/types/datatypes.ts +42 -0
- package/src/karin/types/index.ts +4 -0
- package/src/karin/types/netrorks/NetworksConfigType.ts +61 -0
- package/src/karin/types/netrorks/index.ts +1 -0
- package/src/karin/web.config.ts +48 -0
- package/src/ktr/registry.ts +55 -0
- package/src/ktr/template/_preview/components/PreviewInfoCard.tsx +33 -0
- package/src/ktr/template/_preview/components/PreviewLayout.tsx +65 -0
- package/src/ktr/template/_preview/components/PreviewVideoCard.tsx +22 -0
- package/src/ktr/template/_preview/render.ts +158 -0
- package/src/ktr/template/_preview/types.ts +15 -0
- package/src/ktr/template/_preview/utils/status.ts +29 -0
- package/src/ktr/template/_preview/utils/time.ts +8 -0
- package/src/ktr/template/bilibili/bangumi/components/bangumi.tsx +462 -0
- package/src/ktr/template/bilibili/bangumi/components/types.ts +36 -0
- package/src/ktr/template/bilibili/bangumi/index.tsx +9 -0
- package/src/ktr/template/bilibili/comment/components/Comment.tsx +657 -0
- package/src/ktr/template/bilibili/comment/components/types.ts +26 -0
- package/src/ktr/template/bilibili/comment/index.tsx +11 -0
- package/src/ktr/template/bilibili/components/Icons.tsx +209 -0
- package/src/ktr/template/bilibili/components/shared.tsx +162 -0
- package/src/ktr/template/bilibili/components/types.ts +388 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/DYNAMIC_TYPE_ARTICLE.tsx +251 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/types.ts +67 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/DYNAMIC_TYPE_AV.tsx +238 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/types.ts +39 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/DYNAMIC_TYPE_DRAW.tsx +205 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/types.ts +20 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/index.tsx +11 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/DYNAMIC_TYPE_FORWARD.tsx +348 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/types.ts +16 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/DYNAMIC_TYPE_LIVE_RCMD.tsx +264 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/types.ts +32 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/DYNAMIC_TYPE_WORD.tsx +68 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/types.ts +14 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/components/AdditionalCard.tsx +165 -0
- package/src/ktr/template/bilibili/dynamic/components/CommonComponents.tsx +142 -0
- package/src/ktr/template/bilibili/dynamic/types.ts +382 -0
- package/src/ktr/template/bilibili/qrcodeImg/components/qrcodeImg.tsx +179 -0
- package/src/ktr/template/bilibili/qrcodeImg/components/types.ts +9 -0
- package/src/ktr/template/bilibili/qrcodeImg/index.tsx +12 -0
- package/src/ktr/template/bilibili/userlist/components/UserList.tsx +246 -0
- package/src/ktr/template/bilibili/userlist/components/types.ts +35 -0
- package/src/ktr/template/bilibili/userlist/index.tsx +11 -0
- package/src/ktr/template/bilibili/videoInfo/components/types.ts +28 -0
- package/src/ktr/template/bilibili/videoInfo/components/videoInfo.tsx +217 -0
- package/src/ktr/template/bilibili/videoInfo/index.tsx +12 -0
- package/src/ktr/template/components/AmbientCover.tsx +50 -0
- package/src/ktr/template/components/DefaultLayout.tsx +166 -0
- package/src/ktr/template/components/GlowImage.tsx +572 -0
- package/src/ktr/template/components/QRCodeWithAvatar.tsx +52 -0
- package/src/ktr/template/components/RolldownLogo.tsx +110 -0
- package/src/ktr/template/components/ViteLogo.tsx +134 -0
- package/src/ktr/template/components/iconRegistry.ts +294 -0
- package/src/ktr/template/douyin/article-work/components/ArticleWork.tsx +301 -0
- package/src/ktr/template/douyin/article-work/components/types.ts +53 -0
- package/src/ktr/template/douyin/article-work/index.tsx +12 -0
- package/src/ktr/template/douyin/comment/components/Comment.tsx +612 -0
- package/src/ktr/template/douyin/comment/components/types.ts +85 -0
- package/src/ktr/template/douyin/comment/index.tsx +11 -0
- package/src/ktr/template/douyin/components/Icons.tsx +75 -0
- package/src/ktr/template/douyin/components/types.ts +83 -0
- package/src/ktr/template/douyin/dynamic/components/Dynamic.tsx +283 -0
- package/src/ktr/template/douyin/dynamic/components/types.ts +46 -0
- package/src/ktr/template/douyin/dynamic/index.tsx +11 -0
- package/src/ktr/template/douyin/favorite-list/components/FavoriteList.tsx +201 -0
- package/src/ktr/template/douyin/favorite-list/components/types.ts +38 -0
- package/src/ktr/template/douyin/favorite-list/index.tsx +12 -0
- package/src/ktr/template/douyin/image-work/components/ImageWork.tsx +437 -0
- package/src/ktr/template/douyin/image-work/components/types.ts +78 -0
- package/src/ktr/template/douyin/image-work/index.tsx +11 -0
- package/src/ktr/template/douyin/live/components/Live.tsx +229 -0
- package/src/ktr/template/douyin/live/components/types.ts +47 -0
- package/src/ktr/template/douyin/live/index.tsx +11 -0
- package/src/ktr/template/douyin/musicinfo/components/MusicInfo.tsx +187 -0
- package/src/ktr/template/douyin/musicinfo/components/types.ts +31 -0
- package/src/ktr/template/douyin/musicinfo/index.tsx +11 -0
- package/src/ktr/template/douyin/qrcodeImg/components/qrcodeImg.tsx +170 -0
- package/src/ktr/template/douyin/qrcodeImg/components/types.ts +9 -0
- package/src/ktr/template/douyin/qrcodeImg/index.tsx +9 -0
- package/src/ktr/template/douyin/recommend-list/components/RecommendList.tsx +201 -0
- package/src/ktr/template/douyin/recommend-list/components/types.ts +37 -0
- package/src/ktr/template/douyin/recommend-list/index.tsx +12 -0
- package/src/ktr/template/douyin/user_profile/components/UserVideoList.tsx +225 -0
- package/src/ktr/template/douyin/user_profile/components/types.ts +71 -0
- package/src/ktr/template/douyin/user_profile/index.tsx +9 -0
- package/src/ktr/template/douyin/userlist/components/UserList.tsx +229 -0
- package/src/ktr/template/douyin/userlist/components/types.ts +35 -0
- package/src/ktr/template/douyin/userlist/index.tsx +11 -0
- package/src/ktr/template/douyin/video-work/components/VideoWork.tsx +398 -0
- package/src/ktr/template/douyin/video-work/components/types.ts +80 -0
- package/src/ktr/template/douyin/video-work/index.tsx +11 -0
- package/src/ktr/template/font.css +6071 -0
- package/src/ktr/template/global.d.ts +69 -0
- package/src/ktr/template/kuaishou/comment/components/Comment.tsx +207 -0
- package/src/ktr/template/kuaishou/comment/components/types.ts +47 -0
- package/src/ktr/template/kuaishou/comment/index.tsx +11 -0
- package/src/ktr/template/other/changelog/components/changelog.tsx +411 -0
- package/src/ktr/template/other/changelog/components/types.ts +21 -0
- package/src/ktr/template/other/changelog/index.tsx +9 -0
- package/src/ktr/template/other/handlerError/components/errorTitles.ts +224 -0
- package/src/ktr/template/other/handlerError/components/handlerError.tsx +1076 -0
- package/src/ktr/template/other/handlerError/components/stackHighlight.ts +127 -0
- package/src/ktr/template/other/handlerError/components/types.ts +124 -0
- package/src/ktr/template/other/handlerError/index.tsx +9 -0
- package/src/ktr/template/other/help/components/Help.tsx +249 -0
- package/src/ktr/template/other/help/components/types.ts +47 -0
- package/src/ktr/template/other/help/index.tsx +9 -0
- package/src/ktr/template/other/live-photo-tip/components/LivePhotoTip.tsx +295 -0
- package/src/ktr/template/other/live-photo-tip/components/types.ts +8 -0
- package/src/ktr/template/other/live-photo-tip/index.tsx +9 -0
- package/src/ktr/template/other/qrlogin/components/qrlogin.tsx +295 -0
- package/src/ktr/template/other/qrlogin/components/types.ts +11 -0
- package/src/ktr/template/other/qrlogin/index.tsx +9 -0
- package/src/ktr/template/other/runtime/components/runtime.tsx +347 -0
- package/src/ktr/template/other/runtime/components/types.ts +75 -0
- package/src/ktr/template/other/runtime/index.tsx +9 -0
- package/src/ktr/template/other/version_warning/components/VersionWarning.tsx +392 -0
- package/src/ktr/template/other/version_warning/components/types.ts +8 -0
- package/src/ktr/template/other/version_warning/index.tsx +9 -0
- package/src/ktr/template/statistics/components/BoxplotGuide.tsx +57 -0
- package/src/ktr/template/statistics/components/ChartCard.tsx +40 -0
- package/src/ktr/template/statistics/components/KpiCard.tsx +39 -0
- package/src/ktr/template/statistics/components/PlatformTable.tsx +83 -0
- package/src/ktr/template/statistics/components/RankList.tsx +127 -0
- package/src/ktr/template/statistics/components/SSRChart.tsx +41 -0
- package/src/ktr/template/statistics/components/chartPresets.ts +700 -0
- package/src/ktr/template/statistics/components/chartTheme.ts +234 -0
- package/src/ktr/template/statistics/components/format.ts +33 -0
- package/src/ktr/template/statistics/components/types.ts +92 -0
- package/src/ktr/template/statistics/global/components/GlobalStatistics.tsx +597 -0
- package/src/ktr/template/statistics/global/components/types.ts +138 -0
- package/src/ktr/template/statistics/global/index.tsx +9 -0
- package/src/ktr/template/statistics/group/components/GroupStatistics.tsx +468 -0
- package/src/ktr/template/statistics/group/components/types.ts +113 -0
- package/src/ktr/template/statistics/group/index.tsx +9 -0
- package/src/ktr/template/style.css +65 -0
- package/src/ktr/template/types/ctx.ts +42 -0
- package/src/ktr/template/xiaohongshu/comment/components/Comment.tsx +264 -0
- package/src/ktr/template/xiaohongshu/comment/components/types.ts +119 -0
- package/src/ktr/template/xiaohongshu/comment/index.tsx +9 -0
- package/src/ktr/template/xiaohongshu/noteInfo/components/noteInfo.tsx +271 -0
- package/src/ktr/template/xiaohongshu/noteInfo/components/types.ts +66 -0
- package/src/ktr/template/xiaohongshu/noteInfo/index.tsx +9 -0
- package/src/ktr/utils/QRCodeAvatar.ts +102 -0
- package/src/ktr/utils/QRcode.ts +65 -0
- package/src/ktr/utils/avatarProxy.ts +42 -0
- package/src/ktr/utils/cn.ts +6 -0
- package/src/ktr/utils/theme.ts +10 -0
- package/src/qqFields.json +75 -0
- package/src/qqOptions.ts +64 -0
- package/src/richtext/index.ts +9 -0
- package/src/richtext/parse/index.ts +271 -0
- package/src/richtext/react/cn.ts +6 -0
- package/src/richtext/react/index.tsx +582 -0
- package/src/richtext/types.ts +320 -0
- package/src/schema.ts +372 -0
- package/src/webui.ts +352 -0
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import { buildMarkdownImageMessage } from '@/module/utils/QqPanel'
|
|
3
|
+
import { sendParseTip } from '@/module/utils/parseTip'
|
|
4
|
+
|
|
5
|
+
import type { NoteComments, XiaohongshuEmojiListResponse } from '@ikenxuan/amagi'
|
|
6
|
+
import type { RichTextEmojiDefinition } from '@kkk/richtext'
|
|
7
|
+
import { format } from 'date-fns'
|
|
8
|
+
import { common, type Elements, type Message, segment } from 'node-karin'
|
|
9
|
+
import { logger } from 'node-karin'
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
Base,
|
|
13
|
+
baseHeaders,
|
|
14
|
+
buildGoogleMotionPhoto,
|
|
15
|
+
Common,
|
|
16
|
+
downloadFile,
|
|
17
|
+
type downLoadFileOptions,
|
|
18
|
+
downloadVideo,
|
|
19
|
+
type LiveImageMergeOptions,
|
|
20
|
+
loopVideoWithTransition,
|
|
21
|
+
processLocalImageFile,
|
|
22
|
+
processImageUrl,
|
|
23
|
+
Render
|
|
24
|
+
} from '@/module'
|
|
25
|
+
import type { ParseWorkType } from '@/module/db'
|
|
26
|
+
import { Config } from '@/module/utils/Config'
|
|
27
|
+
|
|
28
|
+
import { buildXiaohongshuRichText, xiaohongshuComments } from './comments'
|
|
29
|
+
import { XiaohongshuIdData } from './getID'
|
|
30
|
+
|
|
31
|
+
// 定义小红书视频流类型
|
|
32
|
+
export type XhsVideoStream = {
|
|
33
|
+
height: number
|
|
34
|
+
width: number
|
|
35
|
+
size: number
|
|
36
|
+
video_bitrate: number
|
|
37
|
+
audio_bitrate: number
|
|
38
|
+
fps: number
|
|
39
|
+
master_url: string
|
|
40
|
+
backup_urls: string[]
|
|
41
|
+
video_codec: string
|
|
42
|
+
audio_codec: string
|
|
43
|
+
format: string
|
|
44
|
+
quality_type: string
|
|
45
|
+
stream_desc: string
|
|
46
|
+
duration: number
|
|
47
|
+
avg_bitrate: number
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class Xiaohongshu extends Base {
|
|
51
|
+
e: Message
|
|
52
|
+
type: XiaohongshuIdData['type']
|
|
53
|
+
/**
|
|
54
|
+
* 本次解析的内容形态,供统计埋点读取。
|
|
55
|
+
* 笔记详情拿到之前无法判定,所以留到 `XiaohongshuHandler` 里赋值。
|
|
56
|
+
*/
|
|
57
|
+
workType?: ParseWorkType
|
|
58
|
+
|
|
59
|
+
constructor(e: Message, iddata: XiaohongshuIdData) {
|
|
60
|
+
super(e)
|
|
61
|
+
this.e = e
|
|
62
|
+
this.type = iddata?.type
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 取够配置条数的笔记评论。
|
|
67
|
+
*
|
|
68
|
+
* v7 的 `noteComments` 端点自带声明式翻页:只传目标条数 `number`,游标由管线
|
|
69
|
+
* 携带、跨页条目由端点的 `normalize` 回填到最后一页原位 —— 所以这里不再手写
|
|
70
|
+
* cursor 循环(v6 时代那 30 行)。
|
|
71
|
+
*
|
|
72
|
+
* 这条端点在 amagi 那边还没有生成响应类型(声明回退 `any`),形状仍按手写快照树的
|
|
73
|
+
* `NoteComments` 断言;等它补上样本、生成类型之后换成生成的那份。
|
|
74
|
+
* @param data - 笔记 id 与 xsec_token
|
|
75
|
+
* @returns 响应体(fetcher 失败即抛),`data.comments` 已是合并后的全部评论
|
|
76
|
+
*/
|
|
77
|
+
private async fetchConfiguredNoteComments(data: XiaohongshuIdData): Promise<NoteComments> {
|
|
78
|
+
return (
|
|
79
|
+
await this.amagi.xiaohongshu.fetcher.fetchNoteComments({
|
|
80
|
+
note_id: data.note_id,
|
|
81
|
+
xsec_token: data.xsec_token,
|
|
82
|
+
number: Math.max(1, Config.xiaohongshu.numcomment)
|
|
83
|
+
})
|
|
84
|
+
).data
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async XiaohongshuHandler(data: XiaohongshuIdData) {
|
|
88
|
+
// 诊断:把入参和每一步的结果打出来,定位「只提示不解析」卡在哪
|
|
89
|
+
logger.mark('[小红书] 开始解析: note_id=' + String(data?.note_id ?? '(空)') + ' xsec_token=' + (data?.xsec_token ? '有' : '(空)') + ' type=' + String(this.type))
|
|
90
|
+
if (Config.amagi.cookies.xiaohongshu === '') {
|
|
91
|
+
throw new Error('我还没有小红书的 Cookies,暂时无法解析呢 ~')
|
|
92
|
+
}
|
|
93
|
+
await sendParseTip(this.e, '小红书')
|
|
94
|
+
let NoteData: any
|
|
95
|
+
try {
|
|
96
|
+
NoteData = await this.amagi.xiaohongshu.fetcher.fetchNoteDetail({
|
|
97
|
+
note_id: data.note_id,
|
|
98
|
+
xsec_token: data.xsec_token
|
|
99
|
+
})
|
|
100
|
+
} catch (error: any) {
|
|
101
|
+
logger.error('[小红书] 拉取笔记详情失败: ' + String(error?.message ?? error))
|
|
102
|
+
throw error
|
|
103
|
+
}
|
|
104
|
+
const noteItems = NoteData?.data?.data?.items
|
|
105
|
+
logger.mark('[小红书] 笔记详情返回: items=' + (Array.isArray(noteItems) ? noteItems.length : '(不是数组 ✗)'))
|
|
106
|
+
/**
|
|
107
|
+
* **卡片数据的取值要容错**:实测 items[0].note_card 经常取不到
|
|
108
|
+
* (接口层级与我们预期的不一致),一取不到就在这行抛 TypeError,
|
|
109
|
+
* 后面的卡片渲染完全轮不到 —— 用户看到的就是「提示解析中,然后没反应」。
|
|
110
|
+
* 这里把可能的两层都兜住,并把真实键名打出来(下次即可精确修改)。
|
|
111
|
+
*/
|
|
112
|
+
const rawItem: any = Array.isArray(noteItems) ? noteItems[0] : undefined
|
|
113
|
+
const noteCard: any = rawItem?.note_card ?? rawItem?.noteCard ?? rawItem
|
|
114
|
+
logger.mark('[小红书] 条目键名: ' + JSON.stringify(Object.keys(rawItem ?? {}).slice(0, 12)) +
|
|
115
|
+
' / note_card 键名: ' + JSON.stringify(Object.keys(rawItem?.note_card ?? {}).slice(0, 16)))
|
|
116
|
+
if (!noteCard) {
|
|
117
|
+
logger.warn('[小红书] 拿不到笔记内容,无法渲染卡片')
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
logger.mark('[小红书] 准备判定内容形态…')
|
|
121
|
+
// 统计用的内容形态:有视频流算视频笔记,否则算图文(与 noteInfo/comment 模板里的判定一致)
|
|
122
|
+
this.workType = noteCard.video ? 'video' : 'gallery'
|
|
123
|
+
logger.mark('[小红书] 内容形态=' + this.workType + ',接下来拉表情列表')
|
|
124
|
+
/**
|
|
125
|
+
* 表情列表**失败不能让整条解析中断** ——
|
|
126
|
+
* 实测这个接口经常报错,而它在卡片渲染之前,一抛异常就变成
|
|
127
|
+
* 「详情明明拿到了,卡片却一张都不发」(用户看到的就是「提示解析中然后没反应」)。
|
|
128
|
+
* 拿不到就用空表情表继续,卡片照样渲染,只是表情不做转换。
|
|
129
|
+
*/
|
|
130
|
+
/**
|
|
131
|
+
* 表情表先用**空的**,卡片立刻渲染 —— 这是关键。
|
|
132
|
+
*
|
|
133
|
+
* 实测 `fetchEmojiList()` 会把整个流程卡死(既不返回也不报错,连 Promise.race
|
|
134
|
+
* 的超时都触发不了,说明事件循环被它拖住了),而它在卡片渲染**之前**,
|
|
135
|
+
* 结果就是「提示解析中,然后没反应,卡片一张都没有」。
|
|
136
|
+
* 现在把表情拉取挪到卡片发完之后,卡片不受影响,评论区再单独尝试。
|
|
137
|
+
*/
|
|
138
|
+
// 注意必须是**数组**:buildXiaohongshuRichText 会直接迭代它(给 {} 会报 emojiData is not iterable)
|
|
139
|
+
let formattedEmojis: any[] = []
|
|
140
|
+
|
|
141
|
+
// 笔记信息
|
|
142
|
+
if (Config.xiaohongshu.sendContent.some((item) => item === 'info')) {
|
|
143
|
+
logger.mark('[小红书] 准备渲染详情卡片: title=' + String(noteCard.title ?? '').slice(0, 20) +
|
|
144
|
+
' 图片数=' + (Array.isArray(noteCard.image_list) ? noteCard.image_list.length : 0))
|
|
145
|
+
let noteInfoImg: any
|
|
146
|
+
try {
|
|
147
|
+
noteInfoImg = await Render(this.e, 'xiaohongshu/noteInfo', {
|
|
148
|
+
title: noteCard.title,
|
|
149
|
+
desc: buildXiaohongshuRichText(noteCard.desc, formattedEmojis, [], {
|
|
150
|
+
stripTopicMarker: true
|
|
151
|
+
}),
|
|
152
|
+
statistics: noteCard.interact_info,
|
|
153
|
+
note_id: noteCard.note_id,
|
|
154
|
+
author: noteCard.user,
|
|
155
|
+
/**
|
|
156
|
+
* 封面要**容错**:视频笔记的 image_list 可能是空数组,
|
|
157
|
+
* 取 [0].url_default 会抛 TypeError(卡片整张都没了)。
|
|
158
|
+
* 退而求其次用视频首帧,再不行给空串(模板能接受空值)。
|
|
159
|
+
*/
|
|
160
|
+
image_url: noteCard.image_list?.[0]?.url_default
|
|
161
|
+
?? noteCard.video?.image?.first_frame
|
|
162
|
+
?? noteCard.video?.cover
|
|
163
|
+
?? '',
|
|
164
|
+
time: noteCard.time,
|
|
165
|
+
ip_location: noteCard.ip_location,
|
|
166
|
+
share_url: `https://www.xiaohongshu.com/discovery/item/${data.note_id}?source=webshare&xhsshare=pc_web&xsec_token=${data.xsec_token}&xsec_source=pc_share`,
|
|
167
|
+
image_list: noteCard.image_list?.map((image) => image.url_default) ?? [],
|
|
168
|
+
is_video: Boolean(noteCard.video)
|
|
169
|
+
})
|
|
170
|
+
} catch (error: any) {
|
|
171
|
+
// 渲染失败要看得见,别又变成「提示解析中然后没反应」
|
|
172
|
+
logger.error('[小红书] 详情卡片渲染失败: ' + String(error?.message ?? error))
|
|
173
|
+
throw error
|
|
174
|
+
}
|
|
175
|
+
logger.mark('[小红书] 详情卡片渲染完成,准备发送')
|
|
176
|
+
await this.e.reply(noteInfoImg)
|
|
177
|
+
logger.mark('[小红书] 详情卡片已发送')
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* **图文笔记的图片要发出来**(用户要求)。
|
|
182
|
+
*
|
|
183
|
+
* 之前只发了详情卡片,正文里的图片一张都没发 —— 用户看到的就是
|
|
184
|
+
* 「解析出来了图文,但图呢?」。这里和抖音图集一样:合并成**一条 markdown**
|
|
185
|
+
* (图片紧贴渲染,一条消息装完整套图)。
|
|
186
|
+
*/
|
|
187
|
+
const noteImages: string[] = (noteCard.image_list ?? [])
|
|
188
|
+
.map((image: any) => String(image?.url_default ?? image?.url ?? ''))
|
|
189
|
+
.filter(Boolean)
|
|
190
|
+
if (!noteCard.video && noteImages.length) {
|
|
191
|
+
try {
|
|
192
|
+
const mdMessage = await buildMarkdownImageMessage(noteImages)
|
|
193
|
+
if (mdMessage) {
|
|
194
|
+
await this.e.reply(mdMessage)
|
|
195
|
+
logger.mark('[小红书] 图文图片已用一条 markdown 发送,共 ' + noteImages.length + ' 张')
|
|
196
|
+
} else {
|
|
197
|
+
// md 生成失败就逐张发,总比一张不发好
|
|
198
|
+
for (const imageUrl of noteImages) await this.e.reply(segment.image(imageUrl))
|
|
199
|
+
logger.mark('[小红书] md 生成失败,图文图片改为逐张发送,共 ' + noteImages.length + ' 张')
|
|
200
|
+
}
|
|
201
|
+
} catch (error: any) {
|
|
202
|
+
logger.warn('[小红书] 发送图文图片失败: ' + String(error?.message ?? error).slice(0, 120))
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 卡片发完后再去拉表情表(给评论区做表情转换用)。
|
|
208
|
+
* 这里挂掉/超时都不影响已经发出去的卡片。
|
|
209
|
+
*/
|
|
210
|
+
try {
|
|
211
|
+
const EmojiList = await Promise.race([
|
|
212
|
+
this.amagi.xiaohongshu.fetcher.fetchEmojiList(),
|
|
213
|
+
new Promise((resolve) => setTimeout(() => resolve(null), 8000))
|
|
214
|
+
]) as any
|
|
215
|
+
if (EmojiList) {
|
|
216
|
+
formattedEmojis = XiaohongshuEmoji(EmojiList.data)
|
|
217
|
+
logger.mark('[小红书] 表情表已获取,共 ' + (Array.isArray(formattedEmojis) ? formattedEmojis.length : 0) + ' 条')
|
|
218
|
+
} else {
|
|
219
|
+
logger.warn('[小红书] 表情表超时(8s),评论区将不做表情转换')
|
|
220
|
+
}
|
|
221
|
+
} catch (error: any) {
|
|
222
|
+
logger.warn('[小红书] 表情表拉取失败(不影响卡片): ' + String(error?.message ?? error).slice(0, 100))
|
|
223
|
+
formattedEmojis = []
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// 评论列表
|
|
227
|
+
if (Config.xiaohongshu.sendContent.some((item) => item === 'comment')) {
|
|
228
|
+
/**
|
|
229
|
+
* 评论同样**非致命**:上游这条链路本来就常报错,
|
|
230
|
+
* 但卡片(上面已经发过)不该因为评论拉不到就整条失败。
|
|
231
|
+
*/
|
|
232
|
+
let CommentData: any
|
|
233
|
+
/** 评论是否拉取失败 —— 失败也要把评论卡渲染出来(只是内容为空 + 一句提示) */
|
|
234
|
+
let commentFailed = false
|
|
235
|
+
try {
|
|
236
|
+
// 评论同样加超时:上游这条链路本来就常挂,别把整条解析拖死
|
|
237
|
+
CommentData = await Promise.race([
|
|
238
|
+
this.fetchConfiguredNoteComments(data),
|
|
239
|
+
new Promise((resolve) => setTimeout(() => resolve(null), 15000))
|
|
240
|
+
]) as any
|
|
241
|
+
if (!CommentData) throw new Error('拉取评论超时(15s)')
|
|
242
|
+
} catch (error: any) {
|
|
243
|
+
/**
|
|
244
|
+
* **这里绝对不能 return** —— 视频分支在这个代码块之后,
|
|
245
|
+
* 一 return 就等于「评论拉不到 → 视频也不发了」。
|
|
246
|
+
* 只跳过评论区,继续往下走。
|
|
247
|
+
*/
|
|
248
|
+
logger.warn('[小红书] 拉取评论失败(跳过评论区,继续后面的视频): ' + String(error?.message ?? error).slice(0, 120))
|
|
249
|
+
CommentData = null
|
|
250
|
+
commentFailed = true
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (!CommentData) {
|
|
254
|
+
/**
|
|
255
|
+
* 评论接口拿不到数据时,**仍然渲染一张评论卡**(内容为空),
|
|
256
|
+
* 并明确提示「无法获取评论数据」—— 用户要求:
|
|
257
|
+
* 与其什么都不发,不如让人看到「这里本该有评论,只是接口失败了」。
|
|
258
|
+
*/
|
|
259
|
+
if (commentFailed) {
|
|
260
|
+
try {
|
|
261
|
+
const emptyCommentCard = await Render(this.e, 'xiaohongshu/comment', {
|
|
262
|
+
Type: noteCard.video ? '视频' : '图文',
|
|
263
|
+
CommentsData: [],
|
|
264
|
+
CommentLength: 0,
|
|
265
|
+
ImageLength: noteCard.image_list?.length || 0,
|
|
266
|
+
// 提示直接写进卡片(模板的 ErrorText),不再单独发文字、也不带 emoji
|
|
267
|
+
ErrorText: '评论数据获取失败,稍后再试试',
|
|
268
|
+
share_url: 'https://www.xiaohongshu.com/discovery/item/' + data.note_id
|
|
269
|
+
})
|
|
270
|
+
await this.e.reply(emptyCommentCard)
|
|
271
|
+
logger.mark('[小红书] 已发出空的评论卡片(占位)')
|
|
272
|
+
} catch (renderError: any) {
|
|
273
|
+
logger.warn('[小红书] 空评论卡渲染失败: ' + String(renderError?.message ?? renderError).slice(0, 100))
|
|
274
|
+
}
|
|
275
|
+
// 提示已经在卡片里了,不再另发文字
|
|
276
|
+
}
|
|
277
|
+
} else if (!CommentData?.data?.comments || CommentData.data.comments.length === 0) {
|
|
278
|
+
await this.e.reply('这个笔记没有评论 ~')
|
|
279
|
+
} else {
|
|
280
|
+
// 使用简化的评论处理函数,直接返回评论数组
|
|
281
|
+
const processedComments = await xiaohongshuComments(CommentData, formattedEmojis)
|
|
282
|
+
|
|
283
|
+
const commentListImg = await Render(this.e, 'xiaohongshu/comment', {
|
|
284
|
+
Type: noteCard.video ? '视频' : '图文',
|
|
285
|
+
CommentsData: processedComments,
|
|
286
|
+
CommentLength: processedComments.length,
|
|
287
|
+
ImageLength: noteCard.image_list?.length || 0,
|
|
288
|
+
share_url: `https://www.xiaohongshu.com/discovery/item/${data.note_id}?source=webshare&xhsshare=pc_web&xsec_token=${data.xsec_token}&xsec_source=pc_share`
|
|
289
|
+
})
|
|
290
|
+
this.e.reply(commentListImg)
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// 图片笔记
|
|
295
|
+
if (!noteCard.video && Config.xiaohongshu.sendContent.includes('image')) {
|
|
296
|
+
const processedImages: Elements[] = []
|
|
297
|
+
const title = noteCard.title
|
|
298
|
+
const temp: Array<{ filepath: string; totalBytes: number }> = []
|
|
299
|
+
let hasGeneratedLivePhoto = false // 标记是否生成了实况图
|
|
300
|
+
|
|
301
|
+
// 获取实况图配置
|
|
302
|
+
const livePhotoMode = Config.app.livePhotoMode ?? 'video_and_livephoto'
|
|
303
|
+
const shouldGenerateVideo = livePhotoMode === 'video_and_livephoto' || livePhotoMode === 'video_only'
|
|
304
|
+
const shouldGenerateLivePhoto = livePhotoMode === 'video_and_livephoto' || livePhotoMode === 'livephoto_only'
|
|
305
|
+
|
|
306
|
+
// 实况图合并配置
|
|
307
|
+
const loopCount = 3 // 小红书实况图循环3次
|
|
308
|
+
const mergeMode: LiveImageMergeOptions['mergeMode'] = 'continuous'
|
|
309
|
+
let bgmContext: LiveImageMergeOptions['context'] | undefined = undefined
|
|
310
|
+
|
|
311
|
+
for (const [index, item] of noteCard.image_list.entries()) {
|
|
312
|
+
// 检查是否为实况图
|
|
313
|
+
if (item.live_photo && item.stream && (shouldGenerateVideo || shouldGenerateLivePhoto)) {
|
|
314
|
+
// 下载静态图片
|
|
315
|
+
const staticImageUrl = item.url_default
|
|
316
|
+
const staticImgTempPath = Common.tempDri.images + `static_${Date.now()}_${index}.jpg`
|
|
317
|
+
const staticImg = await downloadFile(staticImageUrl, {
|
|
318
|
+
title: `static_${Date.now()}_${index}.jpg`,
|
|
319
|
+
filepath: staticImgTempPath,
|
|
320
|
+
headers: {
|
|
321
|
+
...baseHeaders,
|
|
322
|
+
Referer: 'https://www.xiaohongshu.com',
|
|
323
|
+
Cookie: Config.amagi.cookies.xiaohongshu
|
|
324
|
+
} as downLoadFileOptions['headers']
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
let staticImgPath = ''
|
|
328
|
+
if (staticImg.filepath) {
|
|
329
|
+
staticImgPath = staticImg.filepath
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// 获取实况图视频流
|
|
333
|
+
const livePhotoVideo = xiaohongshuGetLivePhotoVideo(item.stream)
|
|
334
|
+
|
|
335
|
+
if (livePhotoVideo) {
|
|
336
|
+
// 下载实况图视频
|
|
337
|
+
const livePhotoPath = Common.tempDri.video + `livephoto_${Date.now()}_${index}.mp4`
|
|
338
|
+
const livePhoto = await downloadFile(livePhotoVideo.master_url, {
|
|
339
|
+
title: `livephoto_${Date.now()}_${index}.mp4`,
|
|
340
|
+
filepath: livePhotoPath,
|
|
341
|
+
headers: {
|
|
342
|
+
...baseHeaders,
|
|
343
|
+
Referer: 'https://www.xiaohongshu.com',
|
|
344
|
+
Cookie: Config.amagi.cookies.xiaohongshu
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
if (livePhoto.filepath) {
|
|
349
|
+
// 生成视频(优先)
|
|
350
|
+
if (shouldGenerateVideo) {
|
|
351
|
+
const outputPath = Common.tempDri.video + `xhs_live_${Date.now()}_${index}.mp4`
|
|
352
|
+
const transitionEnabled = loopCount > 1 && Boolean(staticImgPath)
|
|
353
|
+
const safeStaticPath = staticImgPath || livePhoto.filepath
|
|
354
|
+
|
|
355
|
+
const result = await loopVideoWithTransition({
|
|
356
|
+
inputPath: livePhoto.filepath,
|
|
357
|
+
outputPath,
|
|
358
|
+
loopCount,
|
|
359
|
+
staticImagePath: safeStaticPath,
|
|
360
|
+
transitionEnabled,
|
|
361
|
+
mergeMode,
|
|
362
|
+
context: bgmContext ?? undefined
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
const success = result.success
|
|
366
|
+
if (mergeMode === 'continuous' && result.context) {
|
|
367
|
+
bgmContext = result.context
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (success) {
|
|
371
|
+
const filePath = Common.tempDri.video + `tmp_${Date.now()}.mp4`
|
|
372
|
+
fs.renameSync(outputPath, filePath)
|
|
373
|
+
logger.mark(`小红书实况图视频文件重命名完成: ${outputPath.split('/').pop()} -> ${filePath.split('/').pop()}`)
|
|
374
|
+
temp.push({ filepath: filePath, totalBytes: 0 })
|
|
375
|
+
const videoPath =
|
|
376
|
+
Config.app.videoSendMode === 'base64'
|
|
377
|
+
? `base64://${fs.readFileSync(filePath).toString('base64')}`
|
|
378
|
+
: `file://${filePath}`
|
|
379
|
+
processedImages.push(segment.video(videoPath))
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// 生成实况图(在视频之后)
|
|
384
|
+
if (shouldGenerateLivePhoto) {
|
|
385
|
+
let hasPushedMotionPhotoCover = false
|
|
386
|
+
if (staticImgPath) {
|
|
387
|
+
const motionPhotoCoverPath = Common.tempDri.images + `MVIMG_${format(new Date(), 'yyyyMMdd_HHmmss_SSS')}_${index}.jpg`
|
|
388
|
+
const motionPhotoCreated = await buildGoogleMotionPhoto({
|
|
389
|
+
imagePath: staticImgPath,
|
|
390
|
+
videoPath: livePhoto.filepath,
|
|
391
|
+
outputPath: motionPhotoCoverPath
|
|
392
|
+
})
|
|
393
|
+
|
|
394
|
+
if (motionPhotoCreated) {
|
|
395
|
+
temp.push({ filepath: motionPhotoCoverPath, totalBytes: 0 })
|
|
396
|
+
const motionPhotoCover = processLocalImageFile(motionPhotoCoverPath)
|
|
397
|
+
processedImages.push(segment.image(motionPhotoCover))
|
|
398
|
+
hasPushedMotionPhotoCover = true
|
|
399
|
+
hasGeneratedLivePhoto = true // 标记已生成实况图
|
|
400
|
+
logger.debug(`小红书实况图生成成功: ${motionPhotoCoverPath}`)
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// 如果实况图生成失败,使用普通图片
|
|
405
|
+
if (!hasPushedMotionPhotoCover) {
|
|
406
|
+
const imageUrl = await processImageUrl(item.url_default, title, index)
|
|
407
|
+
processedImages.push(segment.image(imageUrl))
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// 清理临时视频文件
|
|
412
|
+
logger.mark('正在尝试删除缓存文件')
|
|
413
|
+
await Common.removeFile(livePhoto.filepath, true)
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// 清理临时静态图片文件
|
|
418
|
+
if (staticImgPath) {
|
|
419
|
+
temp.push({ filepath: staticImgPath, totalBytes: 0 })
|
|
420
|
+
}
|
|
421
|
+
} else {
|
|
422
|
+
// 普通图片处理
|
|
423
|
+
const imageUrl = await processImageUrl(item.url_default, title, index)
|
|
424
|
+
processedImages.push(segment.image(imageUrl))
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// 如果生成了实况图,添加提示文字
|
|
429
|
+
if (hasGeneratedLivePhoto) {
|
|
430
|
+
const tipImg = await Render(this.e, 'other/live-photo-tip', {
|
|
431
|
+
title: '实况照片已生成',
|
|
432
|
+
description: '保存原图到相册即可识别为实况图'
|
|
433
|
+
})
|
|
434
|
+
processedImages.push(...tipImg)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const res = common.makeForward(
|
|
438
|
+
processedImages,
|
|
439
|
+
Config.app.fakeForward ? this.e.sender.userId : this.e.bot.account.selfId,
|
|
440
|
+
Config.app.fakeForward ? this.e.sender.nick : this.e.bot.account.name
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
if (processedImages.length === 1) {
|
|
444
|
+
await this.e.reply(processedImages[0])
|
|
445
|
+
} else if (processedImages.length > 1) {
|
|
446
|
+
try {
|
|
447
|
+
await this.e.bot.sendForwardMsg(this.e.contact, res, {
|
|
448
|
+
source: '图片合集',
|
|
449
|
+
summary: `查看${res.length}张图片/视频消息`,
|
|
450
|
+
prompt: '小红书图集解析结果',
|
|
451
|
+
news: [{ text: '点击查看解析结果' }]
|
|
452
|
+
})
|
|
453
|
+
} finally {
|
|
454
|
+
for (const item of temp) {
|
|
455
|
+
await Common.removeFile(item.filepath, true)
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// 视频笔记
|
|
462
|
+
if (noteCard.video && Config.xiaohongshu.sendContent.includes('video')) {
|
|
463
|
+
const video = noteCard.video
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* 诊断:把视频流结构打出来(小红书这几版接口字段一直在变)。
|
|
467
|
+
* 结构:video.media.stream = { h264: [...], h265: [...], av1: [...] }
|
|
468
|
+
*/
|
|
469
|
+
const stream = video.media?.stream ?? video.stream
|
|
470
|
+
logger.mark('[小红书] 视频结构: video键=' + JSON.stringify(Object.keys(video ?? {}).slice(0, 10)) +
|
|
471
|
+
' media键=' + JSON.stringify(Object.keys(video?.media ?? {}).slice(0, 8)) +
|
|
472
|
+
' stream键=' + JSON.stringify(Object.keys(stream ?? {}).slice(0, 8)) +
|
|
473
|
+
' h264数=' + (Array.isArray(stream?.h264) ? stream.h264.length : 0) +
|
|
474
|
+
' h265数=' + (Array.isArray(stream?.h265) ? stream.h265.length : 0))
|
|
475
|
+
/**
|
|
476
|
+
* **不再按字段名找流**:小红书现在把这些数组放在 EF4/EF5/EF6/EF7 之类的键下,
|
|
477
|
+
* 老代码只认 h264/h265,自然一个都选不出来(诊断日志里 h264数=0 h265数=0)。
|
|
478
|
+
* 这里把 stream 下**所有数组**拍平,按码率从低到高排序后交给选择逻辑。
|
|
479
|
+
*/
|
|
480
|
+
const allStreams: XhsVideoStream[] = Object.values(stream ?? {})
|
|
481
|
+
.flat()
|
|
482
|
+
.filter((item: any) => item && typeof item === 'object' && (item.master_url || item.url))
|
|
483
|
+
logger.mark('[小红书] 可用视频流: ' + allStreams.length + ' 条' +
|
|
484
|
+
(allStreams.length ? '(码率 ' + allStreams.map((s: any) => s.video_bitrate ?? s.bitrate ?? '?').join('/') + ')' : ''))
|
|
485
|
+
const streamForSelect: any = {
|
|
486
|
+
h264: allStreams.filter((s: any) => !/h265|hevc/i.test(String(s.video_codec ?? ''))),
|
|
487
|
+
h265: allStreams.filter((s: any) => /h265|hevc/i.test(String(s.video_codec ?? '')))
|
|
488
|
+
}
|
|
489
|
+
// 使用新的视频选择逻辑
|
|
490
|
+
const selectedVideo = xiaohongshuProcessVideos(
|
|
491
|
+
allStreams.length ? streamForSelect : stream,
|
|
492
|
+
Config.xiaohongshu.videoQuality,
|
|
493
|
+
Config.xiaohongshu.maxAutoVideoSize
|
|
494
|
+
)
|
|
495
|
+
|
|
496
|
+
if (selectedVideo) {
|
|
497
|
+
await downloadVideo(
|
|
498
|
+
this.e,
|
|
499
|
+
{
|
|
500
|
+
video_url: selectedVideo.master_url,
|
|
501
|
+
title: {
|
|
502
|
+
timestampTitle: `tmp_${Date.now()}.mp4`,
|
|
503
|
+
originTitle: `${selectedVideo.stream_desc}.mp4`
|
|
504
|
+
},
|
|
505
|
+
headers: {
|
|
506
|
+
...baseHeaders,
|
|
507
|
+
Referer: 'https://www.xiaohongshu.com',
|
|
508
|
+
Cookie: Config.amagi.cookies.xiaohongshu
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
message_id: this.e.messageId
|
|
513
|
+
}
|
|
514
|
+
)
|
|
515
|
+
} else {
|
|
516
|
+
/**
|
|
517
|
+
* 兜底:按几种已知字段顺序找视频地址。
|
|
518
|
+
* 原来只取 video.url_default,取不到就 segment.video(undefined),
|
|
519
|
+
* 直接在 Satori 里抛 `Cannot read properties of undefined (reading 'startsWith')`。
|
|
520
|
+
*/
|
|
521
|
+
const fallbackUrl =
|
|
522
|
+
video.url_default ??
|
|
523
|
+
allStreams[allStreams.length - 1]?.master_url ??
|
|
524
|
+
allStreams[0]?.master_url ??
|
|
525
|
+
video.media?.video?.url ??
|
|
526
|
+
''
|
|
527
|
+
if (fallbackUrl) {
|
|
528
|
+
logger.mark('[小红书] 视频流选择失败,改用兜底地址发送')
|
|
529
|
+
await this.e.reply(segment.video(fallbackUrl))
|
|
530
|
+
} else {
|
|
531
|
+
// 实在拿不到地址就明确报错(用户要求:拿不到就直接报错,别静默)
|
|
532
|
+
logger.warn('[小红书] 找不到任何可用的视频地址')
|
|
533
|
+
await this.e.reply('这条小红书视频没能取到可下载的地址,稍后再试试 ~')
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return true
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* 取某个编码下的流列表。
|
|
543
|
+
*
|
|
544
|
+
* `image_list[].stream` 与 `video.media.stream` 在生成树里都只有索引签名(样本没录到编码键),
|
|
545
|
+
* 值统一在这里收成 {@link XhsVideoStream},别让 `any` 顺着调用链传下去。
|
|
546
|
+
*/
|
|
547
|
+
const codecVideos = (streamData: unknown, codec: string): XhsVideoStream[] => {
|
|
548
|
+
if (!streamData || typeof streamData !== 'object') {
|
|
549
|
+
return []
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
const value: unknown = (streamData as Record<string, unknown>)[codec]
|
|
553
|
+
return Array.isArray(value) ? (value as XhsVideoStream[]) : []
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* 获取小红书实况图视频流
|
|
558
|
+
* @param streamData 视频流数据
|
|
559
|
+
* @returns 选择的视频流
|
|
560
|
+
*/
|
|
561
|
+
export const xiaohongshuGetLivePhotoVideo = (streamData: unknown): XhsVideoStream | null => {
|
|
562
|
+
if (!streamData) {
|
|
563
|
+
logger.warn('没有找到实况图视频流数据')
|
|
564
|
+
return null
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// 按兼容性优先级收集所有视频流:h264 > h265 > av1 > h266
|
|
568
|
+
const codecPriority = ['h264', 'h265', 'av1', 'h266']
|
|
569
|
+
|
|
570
|
+
for (const codec of codecPriority) {
|
|
571
|
+
const videos = codecVideos(streamData, codec)
|
|
572
|
+
if (videos.length > 0) {
|
|
573
|
+
// 选择第一个可用的视频流(实况图通常只有一个流)
|
|
574
|
+
const video = videos[0]
|
|
575
|
+
logger.debug(`选择实况图视频流: 编码=${codec}, 大小=${(video.size || 0) / (1024 * 1024)}MB`)
|
|
576
|
+
return video
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
logger.warn('未找到可用的实况图视频流')
|
|
581
|
+
return null
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* 处理小红书视频流选择逻辑
|
|
586
|
+
* @param streamData 视频流数据
|
|
587
|
+
* @param videoQuality 画质偏好
|
|
588
|
+
* @param maxAutoVideoSize 自动模式下的最大文件大小(MB)
|
|
589
|
+
* @returns 选择的视频流
|
|
590
|
+
*/
|
|
591
|
+
export const xiaohongshuProcessVideos = (streamData: unknown, videoQuality: string, maxAutoVideoSize?: number): XhsVideoStream | null => {
|
|
592
|
+
if (!streamData) {
|
|
593
|
+
logger.warn('没有找到视频流数据')
|
|
594
|
+
return null
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// 按兼容性优先级收集所有视频流:h265 > h264 > av1 > h266
|
|
598
|
+
const codecPriority = ['h265', 'h264', 'av1', 'h266']
|
|
599
|
+
const allVideos: XhsVideoStream[] = []
|
|
600
|
+
|
|
601
|
+
for (const codec of codecPriority) {
|
|
602
|
+
allVideos.push(...codecVideos(streamData, codec))
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
if (allVideos.length === 0) {
|
|
606
|
+
logger.warn('没有找到可用的视频流')
|
|
607
|
+
return null
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
logger.debug(`找到 ${allVideos.length} 个视频流`)
|
|
611
|
+
|
|
612
|
+
// 定义画质等级映射,根据分辨率判断画质
|
|
613
|
+
const getQualityLevel = (width: number, height: number): string => {
|
|
614
|
+
const pixels = width * height
|
|
615
|
+
// 4K 画质 (3840x2160 或更高)
|
|
616
|
+
if (pixels >= 3840 * 2160) return '4k'
|
|
617
|
+
// 2K/1440p 画质 (2560x1440)
|
|
618
|
+
if (pixels >= 2560 * 1440) return '2k'
|
|
619
|
+
// 1080p 画质 (1920x1080)
|
|
620
|
+
if (pixels >= 1920 * 1080) return '1080p'
|
|
621
|
+
// 720p 画质 (1280x720)
|
|
622
|
+
if (pixels >= 1280 * 720) return '720p'
|
|
623
|
+
// 540p 画质及以下
|
|
624
|
+
return '540p'
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// 按画质分组,并在每组内按文件大小排序(大的在前)
|
|
628
|
+
const videosByQuality = new Map<string, XhsVideoStream[]>()
|
|
629
|
+
|
|
630
|
+
allVideos.forEach((video) => {
|
|
631
|
+
const quality = getQualityLevel(video.width, video.height)
|
|
632
|
+
if (!videosByQuality.has(quality)) {
|
|
633
|
+
videosByQuality.set(quality, [])
|
|
634
|
+
}
|
|
635
|
+
videosByQuality.get(quality)!.push(video)
|
|
636
|
+
})
|
|
637
|
+
|
|
638
|
+
// 对每个画质组内的视频按文件大小排序(大的在前)
|
|
639
|
+
videosByQuality.forEach((videos) => {
|
|
640
|
+
videos.sort((a, b) => b.size - a.size)
|
|
641
|
+
})
|
|
642
|
+
|
|
643
|
+
// 如果是自动模式
|
|
644
|
+
if (videoQuality === 'adapt') {
|
|
645
|
+
const sizeLimitBytes = (maxAutoVideoSize || Config.app.filelimit) * 1024 * 1024
|
|
646
|
+
|
|
647
|
+
// 按画质优先级排序:4k > 2k > 1080p > 720p > 540p
|
|
648
|
+
const qualityPriority = ['4k', '2k', '1080p', '720p', '540p']
|
|
649
|
+
|
|
650
|
+
for (const quality of qualityPriority) {
|
|
651
|
+
const qualityVideos = videosByQuality.get(quality)
|
|
652
|
+
if (qualityVideos && qualityVideos.length > 0) {
|
|
653
|
+
// 选择该画质下文件大小最大但不超过限制的视频
|
|
654
|
+
const suitableVideo = qualityVideos.find((video) => video.size <= sizeLimitBytes)
|
|
655
|
+
if (suitableVideo) {
|
|
656
|
+
logger.debug(
|
|
657
|
+
`自动选择画质: ${quality}, 文件大小: ${(suitableVideo.size / (1024 * 1024)).toFixed(2)}MB, 编码: ${suitableVideo.video_codec}`
|
|
658
|
+
)
|
|
659
|
+
return suitableVideo
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// 如果没有找到符合大小限制的视频,选择最小的视频
|
|
665
|
+
let smallestVideo = allVideos[0]
|
|
666
|
+
allVideos.forEach((video) => {
|
|
667
|
+
if (video.size < smallestVideo.size) {
|
|
668
|
+
smallestVideo = video
|
|
669
|
+
}
|
|
670
|
+
})
|
|
671
|
+
logger.debug(
|
|
672
|
+
`未找到符合大小限制的视频,选择最小视频: ${(smallestVideo.size / (1024 * 1024)).toFixed(2)}MB, 编码: ${smallestVideo.video_codec}`
|
|
673
|
+
)
|
|
674
|
+
return smallestVideo
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// 固定画质模式
|
|
678
|
+
const targetQuality = videoQuality
|
|
679
|
+
const targetVideos = videosByQuality.get(targetQuality)
|
|
680
|
+
|
|
681
|
+
if (targetVideos && targetVideos.length > 0) {
|
|
682
|
+
// 选择该画质下文件大小最大的视频(通常意味着更高的码率和质量)
|
|
683
|
+
logger.debug(
|
|
684
|
+
`选择固定画质: ${targetQuality}, 文件大小: ${(targetVideos[0].size / (1024 * 1024)).toFixed(2)}MB, 编码: ${targetVideos[0].video_codec}`
|
|
685
|
+
)
|
|
686
|
+
return targetVideos[0]
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// 如果没有找到目标画质,选择最接近的画质
|
|
690
|
+
const qualityPriority = ['4k', '2k', '1080p', '720p', '540p']
|
|
691
|
+
const targetIndex = qualityPriority.indexOf(targetQuality)
|
|
692
|
+
|
|
693
|
+
// 先尝试向下找(更低画质)
|
|
694
|
+
for (let i = targetIndex + 1; i < qualityPriority.length; i++) {
|
|
695
|
+
const fallbackVideos = videosByQuality.get(qualityPriority[i])
|
|
696
|
+
if (fallbackVideos && fallbackVideos.length > 0) {
|
|
697
|
+
logger.debug(`目标画质 ${targetQuality} 不可用,降级到: ${qualityPriority[i]}, 编码: ${fallbackVideos[0].video_codec}`)
|
|
698
|
+
return fallbackVideos[0]
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// 再尝试向上找(更高画质)
|
|
703
|
+
for (let i = targetIndex - 1; i >= 0; i--) {
|
|
704
|
+
const fallbackVideos = videosByQuality.get(qualityPriority[i])
|
|
705
|
+
if (fallbackVideos && fallbackVideos.length > 0) {
|
|
706
|
+
logger.debug(`目标画质 ${targetQuality} 不可用,升级到: ${qualityPriority[i]}, 编码: ${fallbackVideos[0].video_codec}`)
|
|
707
|
+
return fallbackVideos[0]
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// 如果都没找到,返回第一个可用视频
|
|
712
|
+
logger.warn('未找到任何匹配的画质,返回默认视频')
|
|
713
|
+
return allVideos[0]
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* 格式化小红书表情列表
|
|
718
|
+
* @param data 表情接口的响应体(`fetchEmojiList` 的 `data`)
|
|
719
|
+
* @returns 格式化后的表情数组
|
|
720
|
+
*/
|
|
721
|
+
export const XiaohongshuEmoji = (data: XiaohongshuEmojiListResponse): RichTextEmojiDefinition[] => {
|
|
722
|
+
const list: RichTextEmojiDefinition[] = []
|
|
723
|
+
|
|
724
|
+
for (const tab of data.data.emoji.tabs ?? []) {
|
|
725
|
+
for (const collection of tab.collection ?? []) {
|
|
726
|
+
for (const emoji of collection.emoji ?? []) {
|
|
727
|
+
list.push({ name: emoji.image_name, url: emoji.image })
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
return list
|
|
733
|
+
}
|