Skip to content

Commit 6dca114

Browse files
Fixing issue with export
1 parent 4c75131 commit 6dca114

File tree

5 files changed

+197
-80
lines changed

5 files changed

+197
-80
lines changed

release/app/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ const exportToZip = async (
275275
collections[game][collectionId].forEach((videoId: string) => {
276276
let videoFilePath: string = `${clipsDirectory}/${videoId}.mp4`;
277277
let subFilePath: string = `${subsDirectory}/${videoId}.srt`;
278+
279+
if (!fs.existsSync(videoFilePath) || !fs.existsSync(subFilePath)) {
280+
console.log("SKIPPING " + videoId);
281+
return;
282+
}
283+
278284
const videoBase64: string = fs.readFileSync(videoFilePath, {
279285
encoding: 'base64',
280286
});

src/renderer/App.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,18 @@ li {
180180
transform: rotate(360deg);
181181
}
182182
}
183+
184+
.clip-pack-edit {
185+
display: grid;
186+
grid-template-columns: 1fr 1fr;
187+
gap: 10px;
188+
}
189+
190+
.clip-pack-edit > div {
191+
height: 80vh;
192+
overflow-y: scroll;
193+
}
194+
195+
.clip-table td:first-child {
196+
width: 200px;
197+
}

src/renderer/routes/CollectionManager.jsx

Lines changed: 60 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -217,44 +217,66 @@ export default () => {
217217
>
218218
Back to Collection List
219219
</button>
220-
<h2>Clip Pack {collectionId}</h2>
221-
{collections[collectionId].map((videoId) => {
222-
return (
223-
<div>
224-
<button
225-
type="button"
226-
onClick={() => {
227-
removeFromCollection(videoId);
228-
}}
229-
>
230-
-
231-
</button>
232-
{videoId.replace(/_/g, ' ')}
233-
</div>
234-
);
235-
})}
236-
<h2>Videos Not in Clip Pack</h2>
237-
{videos
238-
.filter(
239-
(video) =>
240-
!collections[collectionId].includes(video._id) &&
241-
video._id.startsWith('_')
242-
)
243-
.map(({ _id: videoId }) => {
244-
return (
245-
<div>
246-
<button
247-
type="button"
248-
onClick={() => {
249-
addToCollection(collectionId, videoId);
250-
}}
251-
>
252-
+
253-
</button>
254-
{videoId.replace(/_/g, ' ')}
255-
</div>
256-
);
257-
})}
220+
<div className="clip-pack-edit">
221+
<div>
222+
<h2>Clip Pack {collectionId}</h2>
223+
<table style={{ textAlign: 'center', margin: 'auto' }}>
224+
{collections[collectionId].map((videoId) => {
225+
return (
226+
<tr>
227+
<td>
228+
<button
229+
type="button"
230+
onClick={() => {
231+
removeFromCollection(
232+
videoId
233+
);
234+
}}
235+
>
236+
-
237+
</button>
238+
</td>
239+
<td>{videoId.replace(/_/g, ' ')}</td>
240+
</tr>
241+
);
242+
})}
243+
</table>
244+
</div>
245+
<div>
246+
<h2>Videos Not in Clip Pack</h2>
247+
<table style={{ textAlign: 'center', margin: 'auto' }}>
248+
{videos
249+
.filter(
250+
(video) =>
251+
!collections[collectionId].includes(
252+
video._id
253+
) && video._id.startsWith('_')
254+
)
255+
.map(({ _id: videoId }) => {
256+
return (
257+
<tr>
258+
<td>
259+
<button
260+
type="button"
261+
onClick={() => {
262+
addToCollection(
263+
collectionId,
264+
videoId
265+
);
266+
}}
267+
>
268+
+
269+
</button>
270+
</td>
271+
<td>
272+
{videoId.replace(/_/g, ' ')}
273+
</td>
274+
</tr>
275+
);
276+
})}
277+
</table>
278+
</div>
279+
</div>
258280
</div>
259281
);
260282
}

src/renderer/routes/VideoList.jsx

Lines changed: 114 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ let VideoList = () => {
88
const { game } = useParams();
99
const [videos, setVideos] = useState([]);
1010
const [batchCount, setBatchCount] = useState(0);
11+
const [collections, setCollections] = useState({ _originals: [] });
1112
const [config, setConfig] = useState({});
1213

1314
useEffect(() => {
@@ -18,6 +19,8 @@ let VideoList = () => {
1819
const videos = await window.api.send('getVideos', game);
1920
const hasBatch = await BatchAPI.hasBatch();
2021
const config = await ConfigAPI.getConfig();
22+
const collectionMap = await window.api.send('getCollections', game);
23+
setCollections(collectionMap);
2124
setVideos(videos);
2225
setBatchCount(hasBatch);
2326
setConfig(config);
@@ -29,6 +32,21 @@ let VideoList = () => {
2932
loadVideos();
3033
};
3134

35+
let sortedVideos = Object.keys(collections).reduce((prev, curr) => {
36+
let collection = collections[curr];
37+
collection.forEach((video) => {
38+
if (prev && !prev.includes(video)) {
39+
prev.push(video);
40+
}
41+
});
42+
return prev;
43+
}, []);
44+
45+
let unsortedVideos = videos.filter((video) => {
46+
console.log(video._id);
47+
return !sortedVideos.includes(video._id) && video._id.startsWith('_');
48+
});
49+
3250
return (
3351
<div>
3452
<h2>Custom Clips ({game})</h2>
@@ -49,48 +67,104 @@ let VideoList = () => {
4967
</>
5068
) : null}
5169
<h3>Clips</h3>
52-
{videos.filter((video) => video._id.startsWith('_')).length > 0 ? (
53-
<table style={{ margin: 'auto' }}>
54-
<tbody>
55-
{videos
56-
.filter((video) => video._id.startsWith('_'))
57-
.map((video, index) => {
58-
return (
59-
<tr key={`video-${index}`}>
60-
<td style={{ textAlign: 'left' }}>
61-
{video.name}
62-
</td>
63-
<td>
64-
<Link
65-
to={`/videos/${game}/${video._id}`}
66-
>
67-
<button type="button">
68-
Open Details
69-
</button>
70-
</Link>
71-
</td>
72-
{video._id.startsWith('_') ? (
73-
<td>
74-
<button
75-
type="button"
76-
onClick={() => {
77-
deleteFile(
78-
video._id,
79-
game,
80-
!video.disabled
81-
);
70+
{Object.keys(collections).map((key) => {
71+
let collection = collections[key];
72+
return (
73+
<div>
74+
<h4>{key}</h4>
75+
<table
76+
className="clip-table"
77+
style={{ margin: 'auto' }}
78+
>
79+
<tbody>
80+
{videos
81+
.filter((video) =>
82+
collection.includes(video._id)
83+
)
84+
.map((video, index) => {
85+
return (
86+
<tr key={`video-${index}`}>
87+
<td
88+
style={{
89+
textAlign: 'left',
8290
}}
8391
>
84-
Delete
85-
</button>
86-
</td>
87-
) : null}
88-
</tr>
89-
);
90-
})}
91-
</tbody>
92-
</table>
93-
) : null}
92+
{video.name}
93+
</td>
94+
<td>
95+
<Link
96+
to={`/videos/${game}/${video._id}`}
97+
>
98+
<button type="button">
99+
Open Details
100+
</button>
101+
</Link>
102+
</td>
103+
{video._id.startsWith('_') ? (
104+
<td>
105+
<button
106+
type="button"
107+
onClick={() => {
108+
deleteFile(
109+
video._id,
110+
game,
111+
!video.disabled
112+
);
113+
}}
114+
>
115+
Delete
116+
</button>
117+
</td>
118+
) : null}
119+
</tr>
120+
);
121+
})}
122+
</tbody>
123+
</table>
124+
</div>
125+
);
126+
})}
127+
<h4>Unsorted</h4>
128+
<table className="clip-table" style={{ margin: 'auto' }}>
129+
<tbody>
130+
{unsortedVideos.map((video, index) => {
131+
return (
132+
<tr key={`video-${index}`}>
133+
<td
134+
style={{
135+
textAlign: 'left',
136+
}}
137+
>
138+
{video.name}
139+
</td>
140+
<td>
141+
<Link to={`/videos/${game}/${video._id}`}>
142+
<button type="button">
143+
Open Details
144+
</button>
145+
</Link>
146+
</td>
147+
{video._id.startsWith('_') ? (
148+
<td>
149+
<button
150+
type="button"
151+
onClick={() => {
152+
deleteFile(
153+
video._id,
154+
game,
155+
!video.disabled
156+
);
157+
}}
158+
>
159+
Delete
160+
</button>
161+
</td>
162+
) : null}
163+
</tr>
164+
);
165+
})}
166+
</tbody>
167+
</table>
94168
</div>
95169
);
96170
};

0 commit comments

Comments
 (0)