From 6b30ba2b768faa86445bcb98f968cb48a69caebc Mon Sep 17 00:00:00 2001 From: Kenshin Date: Sun, 11 Apr 2021 02:52:41 +0200 Subject: [PATCH] Added some heuristic to check if the download succeeded by checking the number of mp4 files before and after download. --- resources/Video_dl.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/Video_dl.ps1 b/resources/Video_dl.ps1 index 43cdcc3..631aa28 100644 --- a/resources/Video_dl.ps1 +++ b/resources/Video_dl.ps1 @@ -119,11 +119,13 @@ function PSVideo-DL($ASIC, $Ini){ $End = "99:59:59" } + $Current_N_MP4 = (Get-ChildItem -File $DownPath | Where-Object {$_.Extension -eq ".mp4"}| Measure-Object).Count $Download = ..\bin\youtube-dl.exe --console-title --no-warnings --prefer-ffmpeg --ffmpeg-location "..\bin\ffmpeg.exe" --no-playlist -f "bestvideo[vcodec*=avc1][width<=?1920]+[acodec*=mp4a]/bestvideo[vcodec*=avc1][width<=?1920]+bestaudio/bestvideo[width<=?1920]+bestaudio/bestvideo+bestaudio/best" --merge-output-format mp4 "$Url" -o "$DownPath\%(title)s - %(uploader)s.%(ext)s" - if ($Download -eq $None -or $Download[0] -eq "[") {Echo $Download return "An error occured while downloading."} + $New_N_MP4 = (Get-ChildItem -File $DownPath | Where-Object {$_.Extension -eq ".mp4"}| Measure-Object).Count + if ($Download -eq $None -or $Download[0] -eq "[" -or $Current_N_MP4 -eq $New_N_MP4) {Echo $Download; return "An error occured while downloading."} $File = gci "$DownPath" | sort CreationTime | select -last 1 - if ($File -eq $None) {return "Fuck."} + if ($File -eq $None) {return "There was an error with the download."} $Filename = $File.Name $Filebase = $File.Basename $File_ext = $File.Extension