2020-09-02 21:19:20 +12:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2022-01-12 05:32:17 +13:00
|
|
|
|
Copyright (c) 2007-2022 ShareX Team
|
2020-09-02 21:19:20 +12:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace ShareX.HelpersLib
|
|
|
|
|
{
|
|
|
|
|
public class FFmpegUpdateChecker : GitHubUpdateChecker
|
|
|
|
|
{
|
|
|
|
|
public FFmpegArchitecture Architecture { get; private set; }
|
|
|
|
|
|
2020-09-02 21:49:59 +12:00
|
|
|
|
public FFmpegUpdateChecker(string owner, string repo) : base(owner, repo)
|
2020-09-02 21:19:20 +12:00
|
|
|
|
{
|
2020-09-02 21:49:59 +12:00
|
|
|
|
if (NativeMethods.Is64Bit())
|
2020-09-02 21:19:20 +12:00
|
|
|
|
{
|
2020-09-02 21:49:59 +12:00
|
|
|
|
Architecture = FFmpegArchitecture.win64;
|
2020-09-02 21:19:20 +12:00
|
|
|
|
}
|
2020-09-02 21:49:59 +12:00
|
|
|
|
else
|
2020-09-02 21:19:20 +12:00
|
|
|
|
{
|
2020-09-02 21:49:59 +12:00
|
|
|
|
Architecture = FFmpegArchitecture.win32;
|
2020-09-02 21:19:20 +12:00
|
|
|
|
}
|
2020-09-02 21:49:59 +12:00
|
|
|
|
}
|
2020-09-02 21:19:20 +12:00
|
|
|
|
|
2020-09-02 21:49:59 +12:00
|
|
|
|
public FFmpegUpdateChecker(string owner, string repo, FFmpegArchitecture architecture) : base(owner, repo)
|
|
|
|
|
{
|
|
|
|
|
Architecture = architecture;
|
2020-09-02 21:19:20 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool UpdateReleaseInfo(GitHubRelease release, bool isPortable, bool isBrowserDownloadURL)
|
|
|
|
|
{
|
|
|
|
|
if (release != null && !string.IsNullOrEmpty(release.tag_name) && release.tag_name.Length > 1 && release.tag_name[0] == 'v')
|
|
|
|
|
{
|
|
|
|
|
LatestVersion = new Version(release.tag_name.Substring(1));
|
|
|
|
|
|
|
|
|
|
if (release.assets != null && release.assets.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string endsWith;
|
|
|
|
|
|
|
|
|
|
switch (Architecture)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case FFmpegArchitecture.win64:
|
|
|
|
|
endsWith = "win64.zip";
|
|
|
|
|
break;
|
|
|
|
|
case FFmpegArchitecture.win32:
|
|
|
|
|
endsWith = "win32.zip";
|
|
|
|
|
break;
|
|
|
|
|
case FFmpegArchitecture.macos64:
|
|
|
|
|
endsWith = "macos64.zip";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (GitHubAsset asset in release.assets)
|
|
|
|
|
{
|
|
|
|
|
if (asset != null && !string.IsNullOrEmpty(asset.name) && asset.name.EndsWith(endsWith, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
2021-12-12 10:21:19 +13:00
|
|
|
|
FileName = asset.name;
|
2020-09-02 21:19:20 +12:00
|
|
|
|
|
|
|
|
|
if (isBrowserDownloadURL)
|
|
|
|
|
{
|
|
|
|
|
DownloadURL = asset.browser_download_url;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DownloadURL = asset.url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IsPreRelease = release.prerelease;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|