@@ -298,7 +298,8 @@ private async Task VerifyDownloadedParts(ICollection<M3U8.Stream> playlist, Rang
298
298
foreach ( var part in playlist . Take ( videoListCrop ) )
299
299
{
300
300
var filePath = Path . Combine ( downloadFolder , DownloadTools . RemoveQueryString ( part . Path ) ) ;
301
- if ( ! VerifyVideoPart ( filePath ) )
301
+ var fi = new FileInfo ( filePath ) ;
302
+ if ( ! fi . Exists || fi . Length == 0 )
302
303
{
303
304
failedParts . Add ( part ) ;
304
305
}
@@ -312,43 +313,18 @@ private async Task VerifyDownloadedParts(ICollection<M3U8.Stream> playlist, Rang
312
313
313
314
if ( failedParts . Count != 0 )
314
315
{
315
- if ( playlist . Count == 1 )
316
- {
317
- // The video is only 1 part, it probably won't be a complete file.
318
- return ;
319
- }
320
-
321
316
if ( partCount > 20 && failedParts . Count >= partCount * 0.95 )
322
317
{
323
- // 19/20 parts failed to verify. Either the VOD is heavily corrupted or something went horribly wrong.
318
+ // 19/20 parts are missing or empty, something went horribly wrong.
324
319
// TODO: Somehow let the user bypass this. Maybe with callbacks?
325
- throw new Exception ( $ "Too many parts are corrupted or missing ({ failedParts . Count } /{ partCount } ), aborting.") ;
320
+ throw new Exception ( $ "Too many parts are missing ({ failedParts . Count } /{ partCount } ), aborting.") ;
326
321
}
327
322
328
323
_progress . LogInfo ( $ "The following parts will be redownloaded: { string . Join ( ", " , failedParts ) } ") ;
329
324
await DownloadVideoPartsAsync ( failedParts , videoListCrop , baseUrl , downloadFolder , vodAirDate , cancellationToken ) ;
330
325
}
331
326
}
332
327
333
- private static bool VerifyVideoPart ( string filePath )
334
- {
335
- const int TS_PACKET_LENGTH = 188 ; // MPEG TS packets are made of a header and a body: [ 4B ][ 184B ] - https://tsduck.io/download/docs/mpegts-introduction.pdf
336
-
337
- if ( ! File . Exists ( filePath ) )
338
- {
339
- return false ;
340
- }
341
-
342
- using var fs = File . Open ( filePath , FileMode . Open , FileAccess . Read , FileShare . Read ) ;
343
- var fileLength = fs . Length ;
344
- if ( fileLength == 0 || fileLength % TS_PACKET_LENGTH != 0 )
345
- {
346
- return false ;
347
- }
348
-
349
- return true ;
350
- }
351
-
352
328
private int RunFfmpegVideoCopy ( string tempFolder , FileInfo outputFile , string concatListPath , string metadataPath , decimal startOffset , decimal endOffset , TimeSpan videoLength )
353
329
{
354
330
using var process = new Process
0 commit comments