Skip to content

Commit e8f18ea

Browse files
Fixed some bugs
1 parent 9d140ef commit e8f18ea

File tree

8 files changed

+23
-49
lines changed

8 files changed

+23
-49
lines changed

.dub-editor-batch-cache.v2.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
{
2-
"video": "localfile:///Users/michaelmain/Downloads/365778504_824985109259568_3291619676639901566_n.mp4",
3-
"title": "test",
4-
"clipNumber": 4,
5-
"clips": []
6-
}
1+
"/Users/michaelmain/Documents/dub-editor/.dub-editor-batch-cache.v2.json"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
"webpack-merge": "^5.8.0"
157157
},
158158
"build": {
159-
"productName": "Dub Editor",
159+
"productName": "Dub Editor SA",
160160
"appId": "com.trinary.dub-editor",
161161
"asar": true,
162162
"asarUnpack": [

src/main/main.ts

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ const CONFIG_FILE: string = `${HOME}/.dub-editor-config.v2.json`;
5656
const COLLECTIONS_FILE: string = '.dub-editor-collections.v2.json';
5757
const BATCH_CACHE_FILE: string = '.dub-editor-batch-cache.v2.json';
5858

59-
const BATCH_VIDEO_TEMP_FILE: string = '.dub-editor-data.v2/dub-editor-batch-tmp.mp4';
60-
const CLIP_VIDEO_TEMP_FILE: string = '.dub-editor-data.v2/dub-editor-clip-tmp.mp4';
61-
6259
const VIDEO_SUB_DIRECTORY = 'VideoClips';
6360
const SUBTITLE_SUB_DIRECTORY = 'Subtitles';
6461
const THUMBNAIL_SUB_DIRECTORY = 'ThumbNails';
@@ -167,7 +164,6 @@ const getDirectoriesForGame = (game: string) : DirectoryList => {
167164
previewImage: path.join(config.mediaDirectory, game, PREVIEW_IMAGE_SUB_DIRECTORY),
168165
collectionMeta: path.join(config.mediaDirectory, COLLECTIONS_FILE),
169166
batchCacheMeta: path.join(config.mediaDirectory, BATCH_CACHE_FILE),
170-
batchVideoMeta: path.join(config.mediaDirectory, BATCH_VIDEO_TEMP_FILE),
171167
}
172168
}
173169

@@ -179,7 +175,6 @@ const getConfigDirectories = () : DirectoryList => {
179175
previewImage: '',
180176
collectionMeta: path.join(config.mediaDirectory, COLLECTIONS_FILE),
181177
batchCacheMeta: path.join(config.mediaDirectory, BATCH_CACHE_FILE),
182-
batchVideoMeta: path.join(config.mediaDirectory, BATCH_VIDEO_TEMP_FILE),
183178
}
184179
}
185180

@@ -468,7 +463,7 @@ const createMetaDataFiles = () => {
468463

469464
// If batch storage doesn't exist, then create it
470465
if (!fs.existsSync(batchCacheMeta)) {
471-
console.log("CREATING BATCH CACHE");
466+
console.log("CREATING BATCH CACHE " + batchCacheMeta);
472467
fs.mkdirSync(HOME, { recursive: true });
473468
fs.writeFileSync(
474469
batchCacheMeta,
@@ -605,12 +600,6 @@ const createWindow = async () => {
605600
let url = request.url.substring('game://'.length);
606601
let pattern = /^(rifftrax|whatthedub)\/(.+)\.(mp4|srt|jpg)$/;
607602

608-
if (url === "batch.tmp.mp4") {
609-
return callback(BATCH_VIDEO_TEMP_FILE);
610-
} else if (url === "clip.tmp.mp4") {
611-
return callback(CLIP_VIDEO_TEMP_FILE);
612-
}
613-
614603
let match : any = url.match(pattern);
615604

616605
if (!match) {
@@ -708,10 +697,12 @@ ipcMain.handle('storeBatch', async (event, { clips, video, title }) => {
708697
clips,
709698
};
710699

700+
let {batchCacheMeta} = getConfigDirectories();
701+
711702
// Write cache file
712703
fs.writeFileSync(
713704
BATCH_CACHE_FILE,
714-
Buffer.from(JSON.stringify(batchCache, null, 5))
705+
Buffer.from(JSON.stringify(batchCacheMeta, null, 5))
715706
);
716707
});
717708

@@ -733,6 +724,8 @@ ipcMain.handle('processBatchClip', async (event, {videoSource, subtitles, title,
733724
`STORING ${title}-${clipNumber} for game ${game} with subtitles ${subtitles}`
734725
);
735726

727+
let {batchCacheMeta} = getConfigDirectories();
728+
736729
let clip : any = batchCache.clips[0];
737730

738731
if (clip) {
@@ -749,7 +742,7 @@ ipcMain.handle('processBatchClip', async (event, {videoSource, subtitles, title,
749742
batchCache.clips.shift();
750743
batchCache.clipNumber++;
751744
fs.writeFileSync(
752-
BATCH_CACHE_FILE,
745+
batchCacheMeta,
753746
Buffer.from(JSON.stringify(batchCache, null, 5))
754747
);
755748

@@ -880,31 +873,6 @@ ipcMain.handle(
880873
}
881874
);
882875

883-
ipcMain.handle(
884-
'storeTempVideo',
885-
(event, {videoArrayBuffer, type}) => {
886-
console.log(
887-
`STORING TEMP CLIP VIDEO`
888-
);
889-
890-
if (type === "clip") {
891-
fs.writeFileSync(
892-
CLIP_VIDEO_TEMP_FILE,
893-
Buffer.from(videoArrayBuffer)
894-
);
895-
return `app://clip.tmp.mp4`;
896-
} else if (type === "batch") {
897-
fs.writeFileSync(
898-
BATCH_VIDEO_TEMP_FILE,
899-
Buffer.from(videoArrayBuffer)
900-
);
901-
return `app://batch.tmp.mp4`;
902-
}
903-
904-
return null;
905-
}
906-
);
907-
908876
ipcMain.handle('deleteVideo', (event, { id, game }) => {
909877
deleteClip(id, game);
910878
});

src/main/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export type DirectoryList = {
66
previewImage: string,
77
collectionMeta: string,
88
batchCacheMeta: string,
9-
batchVideoMeta: string
109
}
1110

1211
export type ClipPaths = {

src/renderer/App.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ let App = (props) => {
8484
<Interstitial isOpen={interstitialState.isOpen}>
8585
{interstitialState.message}
8686
</Interstitial>
87-
{!location.pathname.includes(`/create`) ? (
87+
{!location.pathname.includes(`/create`) &&
88+
!location.pathname.includes(`/batch`) ? (
8889
<div>
8990
<header
9091
style={{

src/renderer/routes/editor/AdvancedEditor.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ let AdvancedEditor = () => {
9191

9292
let onFileOpen = async () => {
9393
let filePath = await VideoAPI.getVideoFile();
94+
if (!filePath) {
95+
return;
96+
}
9497
setVideoSource(`localfile://${filePath}`);
9598
};
9699

src/renderer/routes/editor/ClipCutter.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ let ClipCutter = () => {
5757

5858
let onFileOpen = async () => {
5959
let filePath = await VideoAPI.getVideoFile();
60+
if (!filePath) {
61+
return;
62+
}
6063
setVideoSource(`localfile://${filePath}`);
6164
};
6265

src/renderer/routes/editor/SimpleEditor.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import VideoAPI from 'renderer/api/VideoAPI';
99
import { useAtom } from 'jotai';
1010
import { interstitialAtom } from 'renderer/atoms/interstitial.atom';
1111
import { handleInterstitial } from 'renderer/components/interstitial/Interstitial';
12+
import { gameAtom } from 'renderer/atoms/game.atom';
1213

1314
let SimpleEditor = () => {
14-
const params = useParams();
15+
const [type] = useAtom(gameAtom);
16+
const params = { ...useParams(), type };
1517
const navigate = useNavigate();
1618

1719
const [, setInterstitialState] = useAtom(interstitialAtom);
@@ -86,6 +88,9 @@ let SimpleEditor = () => {
8688

8789
let onFileOpen = async () => {
8890
let filePath = await VideoAPI.getVideoFile();
91+
if (!filePath) {
92+
return;
93+
}
8994
setVideoSource(`localfile://${filePath}`);
9095
};
9196

0 commit comments

Comments
 (0)