diff --git a/Changelog.md b/Changelog.md index c8d4906..01eff1b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,13 @@ +5.4.6.0 +======= + +- youtube-dl update +- auto update routine fix + + 5.4.5.1 Beta ============ diff --git a/mpv.net/Misc/Misc.cs b/mpv.net/Misc/Misc.cs index 3f7a8f0..f69551a 100644 --- a/mpv.net/Misc/Misc.cs +++ b/mpv.net/Misc/Misc.cs @@ -229,4 +229,4 @@ namespace mpvnet { public static string Startup { get; } = Application.StartupPath + @"\"; } -} \ No newline at end of file +} diff --git a/mpv.net/Properties/AssemblyInfo.cs b/mpv.net/Properties/AssemblyInfo.cs index 951b8ee..a332e54 100644 --- a/mpv.net/Properties/AssemblyInfo.cs +++ b/mpv.net/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("5.4.5.1")] -[assembly: AssemblyFileVersion("5.4.5.1")] +[assembly: AssemblyVersion("5.4.6.0")] +[assembly: AssemblyFileVersion("5.4.6.0")] diff --git a/mpv.net/Update.ps1 b/mpv.net/Update.ps1 index 1a55a9e..c195df7 100644 --- a/mpv.net/Update.ps1 +++ b/mpv.net/Update.ps1 @@ -1,23 +1,67 @@ $ErrorActionPreference = 'Stop' -$targetDir = (Split-Path $args[1]) + "\new version" + +if ($args.Length -ne 2) { + Write-Host 'Invalid arguments' -ForegroundColor Red + exit +} + +if (-not (Get-Command curl.exe)) { + Write-Host 'Error using curl.exe' -ForegroundColor Red + exit +} + +if ($PSVersionTable.PSVersion.Major -lt 5) { + Write-Host 'PowerShell 5.1 not found' -ForegroundColor Red + exit +} + +Add-Type -AssemblyName Microsoft.VisualBasic + +# Delete directory using recycle bin +function Remove-Directory($directory) { + if (Test-Path $directory) { + [Microsoft.VisualBasic.FileIO.FileSystem]:: + DeleteDirectory($directory, 'OnlyErrorDialogs', 'SendToRecycleBin') + } +} + +$currentDir = $args[1]; + +$targetDir = (Split-Path $currentDir) + "\new version" +Remove-Directory $targetDir $targetFile = $targetDir + '.7z' +Remove-Item $targetFile -Force -ErrorAction Ignore Write-Host 'Download new version' -ForegroundColor Green curl.exe $args[0] --location --output $targetFile if ($LastExitCode) { throw $LastExitCode } Write-Host 'Unpack new version' -ForegroundColor Green -& ($args[1] + '\7z\7za.exe') x -y $targetFile -o"$targetDir" +& ($currentDir + '\7z\7za.exe') x -y $targetFile -o"$targetDir" if ($LastExitCode) { throw $LastExitCode } Write-Host 'Delete downloaded file' -ForegroundColor Green Remove-Item $targetFile -Force -Recurse +$portableConfigDir = $currentDir + '\portable_config' +$portableConfigTempDir = (Split-Path $currentDir) + '\portable config dir temp' +Remove-Item $portableConfigTempDir -Force -ErrorAction Ignore + +if (Test-Path $portableConfigDir) { + Write-Host 'Backup portable config' -ForegroundColor Green + Copy-Item $portableConfigDir $portableConfigTempDir -Recurse -Force +} + Write-Host 'Delete current version' -ForegroundColor Green -Remove-Item $args[1] -Force -Recurse +Remove-Directory $currentDir Write-Host 'Rename directory' -ForegroundColor Green -Rename-Item $targetDir (Split-Path $args[1] -Leaf) +Rename-Item $targetDir (Split-Path $currentDir -Leaf) + +if (Test-Path $portableConfigTempDir) { + Write-Host 'Restore portable config' -ForegroundColor Green + Move-Item $portableConfigTempDir $portableConfigDir -Force +} Write-Host 'Update is complete' -ForegroundColor Green