Skip to content

Commit

Permalink
更新视频号下载
Browse files Browse the repository at this point in the history
  • Loading branch information
putyy committed Dec 29, 2023
1 parent 05eb23d commit 525c8bb
Show file tree
Hide file tree
Showing 11 changed files with 5,034 additions and 125 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ lerna-debug.log*

node_modules
dist
temp
dist-ssr
dist-electron
release
Expand All @@ -27,5 +28,4 @@ release

# lockfile
package-lock.json
pnpm-lock.yaml
yarn.lock
pnpm-lock.yaml
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


## 二次开发
> ps: 打包慢的问题可以参考 https://www.putyy.com/articles/87
```sh
git clone https://github.com/putyy/res-downloader

Expand All @@ -28,12 +29,23 @@ yarn run build --win
```

## 软件截图
![](public/show.png)
![](public/show.jpg)

## 使用方法
> 1. 打开本软件
> 2. 软件首页选择要获取的资源类型(默认选中的视频)
> 3. 打开要捕获的源, 如:视频号、网页、小程序等等
> 4. 返回软件首页即可看到要下载的资源
## 常见问题
> 1. 无法拦截获取
> > 手动检测系统代理是否设置正确 本软件代理地址: 127.0.0.1:8899
> 2. 关闭软件后无法正常上网
> > 手动关闭系统代理设置
## 实现原理
> 通过代理网络抓包拦截响应,筛选出有用的资源,同fiddler、charles等抓包软件、浏览器F12打开控制也能达到目的,只不过这些软件需要手动进行筛选,对于小白用户上手还是有点难度,所以就有了本项目这样的软件。

## 参考项目

- [WeChatVideoDownloader](https://github.com/lecepin/WeChatVideoDownloader) 原项目是react写的,本项目参考原项目用vue3重写了一下,核心逻辑没什么变化,主要是增加了一些新的功能,再次感谢!
96 changes: 3 additions & 93 deletions electron/main/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {downloadFile} from './utils'
// @ts-ignore
import {hexMD5} from '../../src/common/md5'
import fs from "fs"
import * as urlTool from "url"
import CryptoJS from 'crypto-js'
import {closeProxy, setProxy} from "./setProxy"
import log from "electron-log"
Expand All @@ -15,9 +14,8 @@ let win: BrowserWindow
let previewWin: BrowserWindow
let isStartProxy = false
let isOpenProxy = false
let videoList = {}

let aesKey = "as5d45as4d6qe6wqfar6gt4749q6y7w6h34v64tv7t37ty5qwtv6t6qv"
let qqReg = RegExp("finder.video.qq.com")

const toSize = (size: number) => {
if (size > 1048576) {
Expand Down Expand Up @@ -77,96 +75,7 @@ export default function initIPC() {
isStartProxy = true
isOpenProxy = true
return startServer({
// @ts-ignore
interceptCallback: phase => async (req, res) => {
// 拦截响应
if (phase === 'response') {
let ctype = res?._data?.headers?.['content-type']
let url_sign: string = hexMD5(req.fullUrl())
let res_url = req.fullUrl()
let urlInfo = urlTool.parse(res_url, true)
switch (ctype) {
case "video/mp4":
if (videoList.hasOwnProperty(url_sign) === false) {
videoList[url_sign] = req.fullUrl()
let high_url = ''
let down_url = res_url
if (qqReg.test(down_url)) {
down_url = down_url.replace("finder.video.qq.com/251/20302", "finder.video.qq.com/251/20304")
urlInfo = urlTool.parse(down_url, true)
high_url = urlInfo.protocol + "//" + urlInfo.hostname + urlInfo.pathname
+ '?encfilekey=' + urlInfo.query?.encfilekey
+ '&token=' + urlInfo.query?.token
}

win?.webContents?.send?.('on_get_queue', {
url_sign: url_sign,
url: down_url,
down_url: down_url,
high_url: high_url,
platform: urlInfo.hostname,
size: toSize(res?._data?.headers?.['content-length'] ?? 0),
type: ctype,
type_str: 'video',
progress_bar: '',
save_path: '',
downing: false
})
}
break;
case "image/png":
case "image/webp":
case "image/svg+xml":
case "image/gif":
win?.webContents?.send?.('on_get_queue', {
url_sign: url_sign,
url: res_url,
down_url: res_url,
high_url: '',
platform: urlInfo.hostname,
size: toSize(res?._data?.headers?.['content-length'] ?? 0),
type: ctype,
type_str: 'image',
progress_bar: '',
save_path: '',
downing: false
})
break;
case "audio/mpeg":
win?.webContents?.send?.('on_get_queue', {
url_sign: url_sign,
url: res_url,
down_url: res_url,
high_url: '',
platform: urlInfo.hostname,
size: toSize(res?._data?.headers?.['content-length'] ?? 0),
type: ctype,
type_str: 'audio',
progress_bar: '',
save_path: '',
downing: false
})
break;
case "application/vnd.apple.mpegurl":
win?.webContents?.send?.('on_get_queue', {
url_sign: url_sign,
url: res_url,
down_url: res_url,
high_url: '',
platform: urlInfo.hostname,
size: toSize(res?._data?.headers?.['content-length'] ?? 0),
type: ctype,
type_str: 'm3u8',
progress_bar: '',
save_path: '',
downing: false
})
break;

}

}
},
win: win,
setProxyErrorCallback: err => {
isStartProxy = false
isOpenProxy = false
Expand Down Expand Up @@ -219,6 +128,7 @@ export default function initIPC() {
// 开始下载
return downloadFile(
down_url,
data.decode_key,
save_path_file,
(res) => {
return save_path_file
Expand Down
Loading

0 comments on commit 525c8bb

Please sign in to comment.