update check and update routine

This commit is contained in:
Frank Skare
2019-11-12 21:50:38 +01:00
parent 3b7bc95869
commit 20ea755a93
7 changed files with 41 additions and 53 deletions

View File

@@ -1,5 +1,11 @@
- new: install via Scoop and Chocolatey added to readme/website (Restia666Ashdoll)
###
- new: install via Scoop and Chocolatey added to readme/website (maintained by Restia666Ashdoll)
- new: update check, it must be enabled first in the conf editor under General
- new: update feature, requires PowerShell 5 and curl,
an up to date Windows 10 system has both included.
Main menu (input.conf) must be reset or updated manually ([defaults](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt))
- fix: often the OSC was shown when fullscreen was entered
or on app startup, this is now suppressed

View File

@@ -1,7 +1,7 @@
MIT License
Copyright 2002-2017 Frank Skare (stax76)
Copyright (c) 2002-2017 Frank Skare (stax76)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and ssociated documentation

View File

@@ -85,6 +85,7 @@
+ [Help > Show mpv default keys](#help--show-mpv-default-keys)
+ [Help > Show mpv.net default keys](#help--show-mpvnet-default-keys)
+ [Help > Show mpv.net manual](#help--show-mpvnet-manual)
+ [Help > Check for Updates](#help--check-for-updates)
+ [Help > About mpv.net](#help--about-mpvnet)
+ [Exit](#exit)
+ [Exit Watch Later](#exit-watch-later)
@@ -765,11 +766,7 @@ Cycles the hwdec property to enable/disable hardware decoding using the followin
[hwdec property](https://mpv.io/manual/master/#options-hwdec)
### Tools > Execute mpv command
Allows to execute mpv commands.
### Tools > Manage File Associations
### Tools > OS Setup
Allows to manage file associations.
@@ -777,21 +774,19 @@ Allows to manage file associations.
Shows the [mpv manual](https://mpv.io/manual/stable/).
### Help > Show mpv default keys
### Help > Show mpv.net web site
Shows the [mpv default keys](https://github.com/mpv-player/mpv/blob/master/etc/input.conf)
### Help > Show mpv.net default keys
Shows the [mpv.net default keys](https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt)
Help > Show mpv.net web site
Shows the [mpv.net web site](https://mpv-net.github.io/mpv.net-web-site/)
Shows the [mpv.net web site](https://mpv-net.github.io/mpv.net-web-site/).
### Help > Show mpv.net manual
Shows the [mpv.net manual](https://github.com/stax76/mpv.net/blob/master/Manual.md)
Shows the [mpv.net manual](https://github.com/stax76/mpv.net/blob/master/Manual.md).
### Help > Check for Updates
Checks for updates and allows to execute the update routine.
The update routine requires PowerShell 5 and curl, an up to date Windows 10 system has both included.
### Help > About mpv.net

View File

@@ -1,7 +1,6 @@

using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Reflection;
using System.Text.RegularExpressions;
@@ -30,41 +29,34 @@ namespace mpvnet
var response = await client.GetAsync("https://api.github.com/repos/stax76/mpv.net/releases/latest");
response.EnsureSuccessStatusCode();
string content = await response.Content.ReadAsStringAsync();
Match match = Regex.Match(content, $@"""mpv\.net-portable-x64-([\d\.]+)\.7z""");
Match match = Regex.Match(content, @"""mpv\.net-portable-x64-([\d\.]+)\.7z""");
Version onlineVersion = Version.Parse(match.Groups[1].Value);
Version currentVersion = Assembly.GetEntryAssembly().GetName().Version;
//if (onlineVersion == currentVersion)
//{
// if (showUpToDateMessage)
// Msg.Show($"{Application.ProductName} is up to date.");
// return;
//}
if (onlineVersion == currentVersion)
{
if (showUpToDateMessage)
Msg.Show($"{Application.ProductName} is up to date.");
return;
}
if (Msg.ShowQuestion($"New version {onlineVersion} is available, update now?") == MsgResult.OK)
{
string arch = IntPtr.Size == 8 ? "64" : "86";
string url = $"https://github.com/stax76/mpv.net/releases/download/{onlineVersion}/mpv.net-portable-x{arch}-{onlineVersion}.7z";
bool asAdmin = false;
try {
File.WriteAllText(Folder.Startup + @"write access test", "");
} catch {
asAdmin = true;
using (Process proc = new Process())
{
proc.StartInfo.FileName = "PowerShell";
proc.StartInfo.Arguments = $"-NoLogo -NoExit -File \"{Folder.Startup + "Update.ps1"}\" \"{url}\" \"{Application.StartupPath}\"";
if (Folder.Startup.Contains("Program Files"))
proc.StartInfo.Verb = "runas";
proc.Start();
}
//using (Process proc = new Process())
//{
// proc.StartInfo.FileName = "PowerShell";
// proc.StartInfo.Arguments = $"-File \"{Folder.Startup + "Update.ps1"}\" \"{url}\" \"{Application.StartupPath}\"";
// if (asAdmin)
// proc.StartInfo.Verb = "runas";
// proc.Start();
//}
//mp.command("quit");
mp.command("quit");
}
}
}

View File

@@ -507,7 +507,7 @@ name = "update-check"
file = "mpvnet"
default = "no"
filter = "General"
help = "Daily check for new version. (mpv.net specific setting)"
help = "Daily check for new version. (requires PowerShell 5 and curl. mpv.net specific setting)"
options = [{ name = "yes" },
{ name = "no" }]

View File

@@ -218,15 +218,12 @@
</EmbeddedResource>
<None Include="..\Changelog.md">
<Link>Changelog.md</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\Manual.md">
<Link>Manual.md</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\README.md">
<Link>README.md</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="app.manifest" />
<None Include="packages.config" />

View File

@@ -152,7 +152,7 @@ namespace mpvnet
get {
if (_ConfigFolder == null)
{
string portableFolder = Folder.Startup + "portable_config\\";
string portableFolder = Folder.Startup + @"portable_config\";
_ConfigFolder = portableFolder;
if (!Directory.Exists(_ConfigFolder))
@@ -160,15 +160,13 @@ namespace mpvnet
if (!Directory.Exists(_ConfigFolder))
{
string appdataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv.net\\";
string appdataFolderMpv = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\";
string appdataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\mpv.net\";
using (TaskDialog<string> td = new TaskDialog<string>())
{
td.MainInstruction = "Choose a settings folder.";
td.AddCommandLink(@"AppData\Roaming\mpv.net", appdataFolder, appdataFolder);
td.AddCommandLink(@"AppData\Roaming\mpv", appdataFolderMpv, appdataFolderMpv);
td.AddCommandLink("<startup>\\portable_config", portableFolder, portableFolder);
td.AddCommandLink(@"<startup>\portable_config", portableFolder, portableFolder);
td.AddCommandLink("Choose custom folder", "custom");
_ConfigFolder = td.Show();
}
@@ -186,7 +184,7 @@ namespace mpvnet
d.Description = "Choose a folder.";
if (d.ShowDialog() == WinForms.DialogResult.OK)
_ConfigFolder = d.SelectedPath + "\\";
_ConfigFolder = d.SelectedPath + @"\";
else
_ConfigFolder = appdataFolder;
}