From a7e0ff2c1a0a0d37fa42b58eba3a77105e0804ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BC=96=E7=A0=81=E7=8C=BF?= Date: Fri, 29 Aug 2025 22:03:36 +0800 Subject: [PATCH] 233 --- .gitignore | 2 +- downKsVideo/package.json | 2 +- downKsVideo/src/http/http.js | 2 +- downKsVideo/src/index.js | 2 +- downKsVideo/src/utils/utils.js | 20 +++++++++++++------ downKsVideo/src/visionProfileLikePhotoList.js | 6 ++++-- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 403adbc..8cc4042 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ .DS_Store node_modules -/dist +downKsVideo/dist/* # local env files diff --git a/downKsVideo/package.json b/downKsVideo/package.json index 1c31435..8b73c14 100644 --- a/downKsVideo/package.json +++ b/downKsVideo/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "node --max-old-space-size=20240 src/index.js", "http": "node-dev app.js", - "tj": "node-dev src/tuijian.js" + "zb": "node-dev src/visionProfileLikePhotoList.js" }, "keywords": [], "author": "", diff --git a/downKsVideo/src/http/http.js b/downKsVideo/src/http/http.js index b36fcd6..b3a95bc 100644 --- a/downKsVideo/src/http/http.js +++ b/downKsVideo/src/http/http.js @@ -5,7 +5,7 @@ class GraphqlRequest { constructor() { this.client = new GraphQLClient(config.url, { headers: { - Cookie: 'did=web_8e01e1d7a6199e8ad21de2e5f486f2db; clientid=3; kpf=PC_WEB; kpn=KUAISHOU_VISION' + Cookie: 'kpf=PC_WEB; clientid=3; did=web_1debac63b767ac564381b3e54dc1de14; userId=58344290; kuaishou.server.webday7_st=ChprdWFpc2hvdS5zZXJ2ZXIud2ViZGF5Ny5zdBKwAS28zA7-aNXM3dej-9d2bBkejAcmqj3N81VfEi6InoR5aOqvxTncN3v-Uqk9AgKLWgWB1DU13-erJnrkhVdBtvxZGa-jyk983XBft3x5Gs6W7Gbmgvbnd-_7g3kz3WR7EYksKtPMKVXn3_pHLNu91hTPpT9Ifz5kAuhdeej3BJxZi3V1O5XQ1jFdk4BfthT_y33jZvfUI1qlRHfR8K2C969mhMQmisDy2WjqhUZkLA_UGhJ9HT6MbGrfdP_lNnYr-H8iHsEiIEvZa908l7ohZ_Y3lA8JBQMyEsG5ETx9F7bbEPudwvWkKAUwAQ; kuaishou.server.webday7_ph=fa6c85794f6091f1c8261e28a15425b66a23; kpn=KUAISHOU_VISION' }, }) } diff --git a/downKsVideo/src/index.js b/downKsVideo/src/index.js index b48b6a8..dd8426b 100644 --- a/downKsVideo/src/index.js +++ b/downKsVideo/src/index.js @@ -19,7 +19,7 @@ pr.on('uncaughtException', err => { }); /** - * 自动下载快手主播主页所有视频和图片 + * 自动下载快手喜欢的所有视频 */ const main = async () => { console.log("开始 =============================================================="); diff --git a/downKsVideo/src/utils/utils.js b/downKsVideo/src/utils/utils.js index dedc6e1..58d4d71 100644 --- a/downKsVideo/src/utils/utils.js +++ b/downKsVideo/src/utils/utils.js @@ -23,9 +23,10 @@ class Utils { init(type = "visionProfileLikePhotoList", userId) { this.type = type this.userId = userId + this.mkDir(this.userId) } - async start(params) { + async start() { let params = { page: "profile", pcursor: this.principalId } this.userId ? params.userId = this.userId : null @@ -63,10 +64,8 @@ class Utils { }) } - - async savefileToPath(fileData, fileName) { - let fileFullName = path.join(__dirname, `../../dist/${fileName}.mp4`) + let fileFullName = path.join(__dirname, `../../dist/${this.userId}/${fileName}.mp4`) return new Promise((resolve, reject) => { fs.writeFile(fileFullName, fileData, 'binary', err => { if (err) { @@ -78,11 +77,11 @@ class Utils { if (this.TotalCount >= this.TotalFeeds.length) { console.log("-----------视频下载进度-------------"); console.log(""); - console.log(`3:已下载:${this.TotalFeeds.length} 条视频,5秒 后将开始下载 下一页..`); + console.log(`3:已下载:${this.TotalFeeds.length} 条视频,3秒 后将开始下载 下一页..`); console.log("") console.log("") - setTimeout(() => this.start(), 5000) + setTimeout(() => this.start(), 3000) } resolve('已下载') } @@ -90,6 +89,15 @@ class Utils { }) } + + /** + * 创建文件夹 + * @param {*} page + */ + mkDir(page) { + fs.mkdir(`dist/${page}`, err => err ? console.log(err) : console.log('文件夹创建成功')) + } + } module.exports = Utils \ No newline at end of file diff --git a/downKsVideo/src/visionProfileLikePhotoList.js b/downKsVideo/src/visionProfileLikePhotoList.js index 5ed9b41..09f923a 100644 --- a/downKsVideo/src/visionProfileLikePhotoList.js +++ b/downKsVideo/src/visionProfileLikePhotoList.js @@ -1,6 +1,8 @@ const utils = require("./utils/utils"); + +// 下载主播主页的视频 let u = new utils() // u.init("visionProfileLikePhotoList") -u.init("visionProfilePhotoList", "3xiem77vya42p4y") -u.start({ page: "profile", pcursor: this.principalId }) \ No newline at end of file +u.init("visionProfilePhotoList", "3x8549i7ha829sg") +u.start() \ No newline at end of file