Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #51 from lecepin/fix-update-rule
Browse files Browse the repository at this point in the history
feat: Rule update & Electron update
  • Loading branch information
lecepin authored Sep 4, 2023
2 parents a31c15a + 14a8ef5 commit 17e0ffd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
7 changes: 7 additions & 0 deletions electron/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ export default function initIPC() {
return startServer({
interceptCallback: phase => async (req, res) => {
if (phase === 'response' && res?._data?.headers?.['content-type'] == 'video/mp4') {
const fixUrl = {}
if(req.fullUrl().includes("video.qq.com")){
fixUrl.fixUrl = req.fullUrl().replace(/\/20302\//g, '/20304/');
fixUrl.hdUrl = fixUrl.fixUrl.replace(/(\?|&)(?!(encfilekey=|token=))[^&]+/g, '');
}

win?.webContents?.send?.('VIDEO_CAPTURE', {
url: req.fullUrl(),
size: res?._data?.headers?.['content-length'] ?? 0,
...fixUrl
});
}
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechat-video-downloader",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"main": "./build-electron/index.js",
"homepage": "./",
Expand Down Expand Up @@ -34,7 +34,7 @@
"concurrently": "^7.1.0",
"cross-env": "^7.0.3",
"customize-cra": "^1.0.0",
"electron": "^18.2.3",
"electron": "^26.1.0",
"electron-builder": "^23.0.3",
"electron-icon-builder": "^2.0.1",
"husky": "^8.0.1",
Expand Down
10 changes: 5 additions & 5 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function App() {
title: '操作',
dataIndex: 'action',
key: 'action',
width: '200px',
render: (_, { url, fullFileName }) => (
width: '210px',
render: (_, { url, hdUrl, fixUrl, fullFileName, }) => (
<div>
{fullFileName ? (
<Button
Expand All @@ -80,18 +80,18 @@ function App() {
icon={<DownloadOutlined />}
type="primary"
onClick={() => {
send({ type: 'e_下载', url });
send({ type: 'e_下载', url: (hdUrl || url) });
}}
size="small"
>
下载
{hdUrl ? "高清" : ""}下载
</Button>
)}
&nbsp; &nbsp;
<Button
icon={<PlaySquareOutlined />}
onClick={() => {
send({ type: 'e_预览', url });
send({ type: 'e_预览', url: (fixUrl || url) });
}}
size="small"
>
Expand Down
10 changes: 5 additions & 5 deletions src/fsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ export default createMachine(
.finally(() => send('e_重新检测'));
},
invoke_启动服务: (context, event) => send => {
const fnDealVideoCapture = (eName, { url, size }) => {
send({ type: 'e_视频捕获', url, size });
const fnDealVideoCapture = (eName, { url, size, ...other }) => {
send({ type: 'e_视频捕获', url, size, ...other });
};

ipcRenderer
Expand Down Expand Up @@ -217,8 +217,8 @@ export default createMachine(
},
},
actions: {
action_视频捕获: actions.assign(({ captureList }, { size, url }) => {
captureList.push({ size, url, prettySize: prettyBytes(+size) });
action_视频捕获: actions.assign(({ captureList }, { size, url, ...other }) => {
captureList.push({ size, url, prettySize: prettyBytes(+size), ...other });

return {
captureList: uniqBy(captureList, 'url'),
Expand Down Expand Up @@ -247,7 +247,7 @@ export default createMachine(
action_下载完成: actions.assign(({ captureList }, { fullFileName, currentUrl }) => {
return {
captureList: captureList.map(item => {
if (item.url === currentUrl) {
if ((item.hdUrl || item.url) === currentUrl) {
item.fullFileName = fullFileName;
}
return item;
Expand Down

0 comments on commit 17e0ffd

Please sign in to comment.