Skip to content

Commit

Permalink
1.优化文件下载优先标题命名 2.完善资源类型case
Browse files Browse the repository at this point in the history
  • Loading branch information
putyy committed Jun 5, 2024
1 parent 7a01544 commit ca718de
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 47 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# res-downloader
#### 爱享素材下载器

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

## 软件下载
Expand Down
24 changes: 9 additions & 15 deletions electron/main/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,23 @@ export default function initIPC() {
return decodeWxFile(result?.[0], data.decode_key, result?.[0].replace(".mp4", "_解密.mp4"))
})


ipcMain.handle('invoke_file_exists', async (event, {save_path, url}) => {
let url_sign = hexMD5(url)
let res = fs.existsSync(`${save_path}/${url_sign}.mp4`)
return {is_file: res, fileName: `${save_path}/${url_sign}.mp4`}
ipcMain.handle('invoke_file_exists', async (event, {save_path, url, description}) => {
let fileName = description ? description.replace(/[^a-zA-Z\u4e00-\u9fa5]/g, '') : hexMD5(url);
let res = fs.existsSync(`${save_path}/${fileName}.mp4`)
return {is_file: res, fileName: `${save_path}/${fileName}.mp4`}
})

ipcMain.handle('invoke_down_file', async (event, {index, data, save_path, high}) => {
ipcMain.handle('invoke_down_file', async (event, {data, save_path, description}) => {
let down_url = data.down_url
if (high && data.high_url) {
down_url = data.high_url
}

if (!down_url) {
return false
}

let url_sign = hexMD5(down_url)
let save_path_file = `${save_path}/${url_sign}` + suffix(data.type)
let fileName = description ? description.replace(/[^a-zA-Z\u4e00-\u9fa5]/g, '') : hexMD5(down_url);
let save_path_file = `${save_path}/${fileName}` + suffix(data.type)
if (process.platform === 'win32'){
save_path_file = `${save_path}\\${url_sign}` + suffix(data.type)
save_path_file = `${save_path}\\${fileName}` + suffix(data.type)
}

if (fs.existsSync(save_path_file)) {
Expand Down Expand Up @@ -116,8 +112,6 @@ export default function initIPC() {
return
}

console.log('url', url)

previewWin.loadURL(url).then(r => {
return
}).catch(res => {
Expand All @@ -143,4 +137,4 @@ export default function initIPC() {
export function setWin(w, p) {
win = w
previewWin = p
}
}
27 changes: 27 additions & 0 deletions electron/main/proxyServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ export async function startServer({
let urlInfo = urlTool.parse(res_url, true)
switch (ctype) {
case "video/mp4":
case "video/webm":
case "video/ogg":
case "video/x-msvideo":
case "video/mpeg":
case "video/quicktime":
case "video/x-ms-wmv":
case "video/x-flv":
case "video/3gpp":
case "video/x-matroska":
if (videoList.hasOwnProperty(url_sign) === false) {
videoList[url_sign] = req.fullUrl()
let high_url = ''
Expand Down Expand Up @@ -189,6 +198,11 @@ export async function startServer({
case "image/svg+xml":
case "image/gif":
case "image/avif":
case "image/bmp":
case "image/tiff":
case "image/x-icon":
case "image/heic":
case "image/vnd.adobe.photoshop":
win?.webContents?.send?.('on_get_queue', {
url_sign: url_sign,
url: res_url,
Expand All @@ -207,6 +221,18 @@ export async function startServer({
})
break;
case "audio/mpeg":
case "audio/wav":
case "audio/aiff":
case "audio/x-aiff":
case "audio/aac":
case "audio/ogg":
case "audio/flac":
case "audio/midi":
case "audio/x-midi":
case "audio/x-ms-wma":
case "audio/opus":
case "audio/webm":
case "audio/mp4":
win?.webContents?.send?.('on_get_queue', {
url_sign: url_sign,
url: res_url,
Expand All @@ -225,6 +251,7 @@ export async function startServer({
})
break;
case "application/vnd.apple.mpegurl":
case "application/x-mpegURL":
win.webContents?.send?.('on_get_queue', {
url_sign: url_sign,
url: res_url,
Expand Down
6 changes: 0 additions & 6 deletions electron/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ const safeDOM = {
},
}

/**
* https://tobiasahlin.com/spinkit
* https://connoratherton.com/loaders
* https://projects.lukehaas.me/css-loaders
* https://matejkustec.github.io/SpinThatShit
*/
function useLoading() {
const className = `loaders-css__square-spin`
const styleContent = `
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "res-downloader",
"version": "1.0.5",
"version": "1.0.6",
"main": "dist-electron/main/index.js",
"description": "Electron + Vue + Vite 实现的资源下载软件,支持微信视频号下载、抖音视频下载、快手视频下载、酷狗音乐下载等",
"author": "[email protected]",
Expand Down
13 changes: 4 additions & 9 deletions src/components/layout/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ const jump = (scene: number)=>{
break;
case 4:
ipcRenderer.invoke('invoke_open_default_browser', {
url: "https://github.com/putyy/res-downloader/issues"
})
break;
case 5:
ipcRenderer.invoke('invoke_open_default_browser', {
url: "https://haokawx.lot-ml.com/Product/Index/22550"
url: "https://s.gowas.cn/d/4089-quan-ping-tai-zi-yuan-xia-zai-ruan-jian"
})
break;
case 6:
Expand All @@ -42,11 +37,11 @@ div.line
a.item 当前版本: {{v}}
a.item 站长邮箱: [email protected]
a.item(@click="jump(1)") 获取更新
a.item(@click="jump(2)") 云盘资源
a.item(@click="jump(4)") 问题反馈
div.line
a.item 推荐:
a.item(@click="jump(2)") 云盘资源
a.item(@click="jump(3)") 图片无损压缩
a.item(@click="jump(4)") 问题反馈
a.item(@click="jump(5)") 流量卡推荐
a.item(@click="jump(6)") 软件源码
</template>

Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/Sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import {inject, onMounted, ref, watch} from 'vue'
import localStorageCache from "../../common/localStorage";
import localStorageCache from "../../common/localStorage"
const appName = "爱享素材"
const sidebarCollapse = ref(inject('sidebarCollapse'))
Expand Down
12 changes: 6 additions & 6 deletions src/views/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {ref, onMounted, onUnmounted, watch} from "vue"
import {ipcRenderer} from 'electron'
import {ElMessage, ElLoading, ElTable} from "element-plus"
import localStorageCache from "../common/localStorage"
import {Delete, Promotion} from "@element-plus/icons-vue";
import {Delete, Promotion} from "@element-plus/icons-vue"
interface resData {
url_sign: string,
Expand Down Expand Up @@ -153,7 +153,7 @@ const handleBatchDown = async () => {
}
const handleDown = async (index: number, row: any, high: boolean) => {
const handleDown = async (index: number, row: any) => {
let save_dir = localStorageCache.get("save_dir")
Expand All @@ -173,7 +173,8 @@ const handleDown = async (index: number, row: any, high: boolean) => {
let result = await ipcRenderer.invoke('invoke_file_exists', {
save_path: save_dir,
url: (high && row.high_url) ? row.high_url : row.url,
url: row.high_url ? row.high_url : row.url,
description: row.description
})
if (result.is_file) {
Expand All @@ -189,10 +190,9 @@ const handleDown = async (index: number, row: any, high: boolean) => {
}
ipcRenderer.invoke('invoke_down_file', {
index: index,
data: Object.assign({}, tableData.value[index]),
save_path: save_dir,
high: high
description: row.description
}).then((res) => {
if (res !== false) {
tableData.value[index].progress_bar = "100%"
Expand Down Expand Up @@ -336,7 +336,7 @@ el-container.container
template(#default="scope")
div.actions
template(v-if="scope.row.type_str !== 'm3u8'" )
el-button(v-if="!scope.row.save_path" link type="primary" @click="handleDown(scope.$index, scope.row, false)") {{scope.row.decode_key ? "解密下载(视频号)" : "下载"}}
el-button(v-if="!scope.row.save_path" link type="primary" @click="handleDown(scope.$index, scope.row)") {{scope.row.decode_key ? "解密下载(视频号)" : "下载"}}
el-button(v-if="scope.row.decode_key" link type="primary" @click="decodeWxFile(scope.$index)") 视频解密(视频号)
el-button(link type="primary" @click="handlePreview(scope.$index, scope.row)") 窗口预览
el-button(link type="primary" @click="handleCopy(scope.row.down_url)") 复制链接
Expand Down
10 changes: 5 additions & 5 deletions src/views/Setting.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import {onMounted, ref} from "vue";
import {ipcRenderer} from "electron";
import localStorageCache from "../common/localStorage";
import {ElMessage} from "element-plus";
import {onMounted, ref} from "vue"
import {ipcRenderer} from "electron"
import localStorageCache from "../common/localStorage"
import {ElMessage} from "element-plus"
const saveDir = ref("")
const upstream_proxy = ref("")
Expand Down Expand Up @@ -43,4 +43,4 @@ el-form
el-input(v-model="upstream_proxy" placeholder="例如: http://127.0.0.1:7890 修改此项需重启本软件" )
el-form-item
el-button(type="primary" @click="onSetting") 保存
</template>
</template>

0 comments on commit ca718de

Please sign in to comment.