Skip to content

Commit

Permalink
新增代理设置、更换证书、mac下增加http的代理设置、完善image content-type等
Browse files Browse the repository at this point in the history
  • Loading branch information
putyy committed Feb 19, 2024
1 parent 366c79f commit 3082faa
Show file tree
Hide file tree
Showing 20 changed files with 998 additions and 345 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lerna-debug.log*
node_modules
dist
temp
test
dist-ssr
dist-electron
release
Expand All @@ -28,4 +29,5 @@ release

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

🎯 基于 [electron-vite-vue](https://github.com/electron-vite/electron-vite-vue.git)
📦 操作简单、可获取不同类型的资源
💪 支持获取视频、音频、图片、m3u8
🖥 支持获取视频号、抖音、快手、小红书、酷狗音乐、qq音乐等网络资源
💪 支持获取视频、音频、图片、m3u8
🖥 支持获取视频号、抖音、快手、小红书、酷狗音乐、qq音乐、微信小程序等网络资源
🍊 支持设置代理以获取特殊网络下的资源

## 软件下载
🆕 [github下载](https://github.com/putyy/res-downloader/releases)
Expand All @@ -28,9 +29,6 @@ yarn run build --mac
yarn run build --win
```

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

## 使用方法
> 1. 打开本软件
> 2. 软件首页选择要获取的资源类型(默认选中的视频)
Expand All @@ -42,10 +40,18 @@ yarn run build --win
> > 手动检测系统代理是否设置正确 本软件代理地址: 127.0.0.1:8899
> 2. 关闭软件后无法正常上网
> > 手动关闭系统代理设置
> 3. 视频号抓取流程
> > 将需要下载的视频发给好友或者文件助手 再打开即可拦截,通常会出现解密下载按钮
> >
> > 大视频可以复制链接通过其他工具加速下载,然后再通过对应的视频操作项进行"视频解密"
## 软件截图
![](public/show.webp)

## 实现原理
> 通过代理网络抓包拦截响应,筛选出有用的资源,同fiddler、charles等抓包软件、浏览器F12打开控制也能达到目的,只不过这些软件需要手动进行筛选,对于小白用户上手还是有点难度,所以就有了本项目这样的软件。
## 参考项目

- [WeChatVideoDownloader](https://github.com/lecepin/WeChatVideoDownloader) 原项目是react写的,本项目参考原项目用vue3重写了一下,核心逻辑没什么变化,主要是增加了一些新的功能,再次感谢!

1 change: 1 addition & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare module 'vue' {
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElInput: typeof import('element-plus/es')['ElInput']
ElMain: typeof import('element-plus/es')['ElMain']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
Expand Down
3 changes: 1 addition & 2 deletions electron/main/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ const EXECUTABLE_PATH = path.join(
)

const HOME_PATH = path.join(os.homedir(), '.res-downloader@putyy')

export default {
IS_DEV: isDev,
EXECUTABLE_PATH,
HOME_PATH,
CERT_PRIVATE_PATH: path.join(EXECUTABLE_PATH, './keys/private.pem'),
CERT_PUBLIC_PATH: path.join(EXECUTABLE_PATH, './keys/public.pem'),
INSTALL_CERT_FLAG: path.join(HOME_PATH, './installed.lock'),
INSTALL_CERT_FLAG: path.join(HOME_PATH, './res-downloader-installed.lock'),
WIN_CERT_INSTALL_HELPER: path.join(EXECUTABLE_PATH, './w_c.exe'),
APP_CN_NAME: '爱享素材下载器',
APP_EN_NAME: 'ResDownloader',
Expand Down
5 changes: 0 additions & 5 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ function createPreviewWindow(parent: BrowserWindow) {
// previewWin.hide()
previewWin.setTitle("预览")

previewWin.webContents.session.on('will-download', (event, item, webContents) => {
// console.log("取消下载")
item.cancel()
})

previewWin.on("page-title-updated", (event) => {
// 阻止该事件
event.preventDefault()
Expand Down
69 changes: 18 additions & 51 deletions electron/main/ipc.ts
Original file line number Diff line number Diff line change
@@ -1,90 +1,47 @@
import {ipcMain, dialog, BrowserWindow, app, shell} from 'electron'
import {startServer} from './proxyServer'
import {installCert, checkCertInstalled} from './cert'
import {downloadFile, decodeWxFile} from './utils'
import {downloadFile, decodeWxFile, suffix} from './utils'
// @ts-ignore
import {hexMD5} from '../../src/common/md5'
import fs from "fs"
import CryptoJS from 'crypto-js'
import {closeProxy, setProxy} from "./setProxy"
import log from "electron-log"
import {floor} from "lodash";
import {floor} from "lodash"

let getMac = require("getmac").default
let win: BrowserWindow
let previewWin: BrowserWindow
let isStartProxy = false
let isOpenProxy = false

let aesKey = "as5d45as4d6qe6wqfar6gt4749q6y7w6h34v64tv7t37ty5qwtv6t6qv"

const suffix = (type: string) => {
switch (type) {
case "video/mp4":
return ".mp4";
case "image/png":
return ".png";
case "image/webp":
return ".webp";
case "image/svg+xml":
return ".svg";
case "image/gif":
return ".gif";
case "audio/mpeg":
return ".mp3";
case "application/vnd.apple.mpegurl":
return ".m3u8";
}
}

export default function initIPC() {

ipcMain.handle('invoke_app_is_init', async (event, arg) => {
// 初始化应用 安装证书相关
return checkCertInstalled()
})

ipcMain.handle('invoke_init_app', (event, arg) => {
ipcMain.handle('invoke_init_app', (event, arg) => {
// 开始 初始化应用 安装证书相关
// console.log('invoke_init_app')
return installCert(false)
installCert(false).then(r => {})
})

ipcMain.handle('invoke_start_proxy', async (event, arg) => {
ipcMain.handle('invoke_start_proxy', (event, arg) => {
// 启动代理服务
if (isStartProxy) {
if (isOpenProxy === false) {
isOpenProxy = true
setProxy('127.0.0.1', 8899)
.then(() => {
})
.catch((err) => {
})
}
return
}
isStartProxy = true
isOpenProxy = true
return startServer({
win: win,
upstreamProxy: arg.upstream_proxy ? arg.upstream_proxy : "",
setProxyErrorCallback: err => {
isStartProxy = false
isOpenProxy = false

},
})
})

ipcMain.handle('invoke_close_proxy', (event, arg) => {
// 关闭代理
try {
isOpenProxy = false
return closeProxy()
} catch (error) {
log.log("--------------closeProxy error--------------", error)
}

})

ipcMain.handle('invoke_select_down_dir', async (event, arg) => {
// 选择下载位置
const result = dialog.showOpenDialogSync({title: '保存', properties: ['openDirectory']})
Expand Down Expand Up @@ -123,6 +80,10 @@ export default function initIPC() {

let url_sign = hexMD5(down_url)
let save_path_file = `${save_path}/${url_sign}` + suffix(data.type)
if (process.platform === 'win32'){
save_path_file = `${save_path}\\${url_sign}` + suffix(data.type)
}

if (fs.existsSync(save_path_file)) {
return {fullFileName: save_path_file, totalLen: ""}
}
Expand All @@ -135,7 +96,6 @@ export default function initIPC() {
win?.webContents.send('on_down_file_schedule', {schedule: floor(res * 100)})
}
).catch(err => {
// console.log('invoke_down_file:err', err)
return false
})
})
Expand All @@ -156,6 +116,8 @@ export default function initIPC() {
return
}

console.log('url', url)

previewWin.loadURL(url).then(r => {
return
}).catch(res => {
Expand All @@ -171,6 +133,11 @@ export default function initIPC() {
ipcMain.handle('invoke_open_file_dir', (event, {save_path}) => {
shell.showItemInFolder(save_path)
})

ipcMain.handle('invoke_window_restart', (event) => {
app.relaunch()
app.exit()
})
}

export function setWin(w, p) {
Expand Down
Loading

0 comments on commit 3082faa

Please sign in to comment.