@@ -160,6 +160,27 @@ export function createServer ({repo, connections = []}) {
160
160
res . end ( 'Download started' )
161
161
}
162
162
163
+
164
+ async function ignoreVideoHandler ( req , res , repo , connections = [ ] ) {
165
+ const body = await getBody ( req )
166
+ let { id } = JSON . parse ( body )
167
+ res . writeHead ( 200 , { 'Content-Type' : 'application/json' } )
168
+ return res . end ( JSON . stringify ( repo . toggleIgnoreVideo ( id ) ) )
169
+ }
170
+
171
+ async function deleteVideoHandler ( req , res , repo , connections = [ ] ) {
172
+ const body = await getBody ( req )
173
+ let { id } = JSON . parse ( body )
174
+ try {
175
+ repo . deleteVideo ( id )
176
+ res . writeHead ( 200 )
177
+ res . end ( )
178
+ } catch ( err ) {
179
+ res . writeHead ( 500 )
180
+ res . end ( )
181
+ }
182
+ }
183
+
163
184
function watchVideoHandler ( req , res ) {
164
185
const videoPath = './data' + req . url + '.mp4'
165
186
if ( ! fs . existsSync ( videoPath ) ) {
@@ -281,23 +302,4 @@ export function createServer ({repo, connections = []}) {
281
302
}
282
303
}
283
304
284
- async function ignoreVideoHandler ( req , res , repo , connections = [ ] ) {
285
- const body = await getBody ( req )
286
- let { id } = JSON . parse ( body )
287
- res . writeHead ( 200 , { 'Content-Type' : 'application/json' } )
288
- return res . end ( JSON . stringify ( repo . toggleIgnoreVideo ( id ) ) )
289
- }
290
-
291
- async function deleteVideoHandler ( req , res , repo , connections = [ ] ) {
292
- const body = await getBody ( req )
293
- let { id } = JSON . parse ( body )
294
- try {
295
- repo . deleteVideo ( id )
296
- res . writeHead ( 200 )
297
- res . end ( )
298
- } catch ( err ) {
299
- res . writeHead ( 500 )
300
- res . end ( )
301
- }
302
- }
303
305
}
0 commit comments