Пример #1
0
        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))
                        {
                            Filename = asset.name;

                            if (isBrowserDownloadURL)
                            {
                                DownloadURL = asset.browser_download_url;
                            }
                            else
                            {
                                DownloadURL = asset.url;
                            }

                            IsPreRelease = release.prerelease;

                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #2
0
        private string GetDownloadURL(GitHubRelease release)
        {
            if (release.assets != null && release.assets.Count > 0)
            {
                GitHubAsset asset = release.assets[0];

                if (asset != null && !string.IsNullOrEmpty(asset.name))
                {
                    return(string.Format("https://github.com/{0}/{1}/releases/download/{2}/{3}", Owner, Repo, release.tag_name, asset.name));
                }
            }

            return(null);
        }
Пример #3
0
        public string GetLatestDownloadURL(bool includePreRelease, bool isPortable, bool isBrowserDownloadURL)
        {
            try
            {
                GitHubRelease latestRelease = GetLatestRelease(includePreRelease);

                if (UpdateReleaseInfo(latestRelease, isPortable, isBrowserDownloadURL))
                {
                    return(DownloadURL);
                }
            }
            catch (Exception e)
            {
                DebugHelper.WriteException(e);
            }

            return(null);
        }
Пример #4
0
        protected virtual 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;

                    if (isPortable)
                    {
                        endsWith = "portable.zip";
                    }
                    else
                    {
                        endsWith = ".exe";
                    }

                    foreach (GitHubAsset asset in release.assets)
                    {
                        if (asset != null && !string.IsNullOrEmpty(asset.name) && asset.name.EndsWith(endsWith, StringComparison.OrdinalIgnoreCase))
                        {
                            Filename = asset.name;

                            if (isBrowserDownloadURL)
                            {
                                DownloadURL = asset.browser_download_url;
                            }
                            else
                            {
                                DownloadURL = asset.url;
                            }

                            IsPreRelease = release.prerelease;

                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Пример #5
0
        public override void CheckUpdate()
        {
            try
            {
                GitHubRelease latestRelease = GetLatestRelease(IncludePreRelease);

                if (UpdateReleaseInfo(latestRelease, IsPortable, IsPortable ? true : false))
                {
                    RefreshStatus();
                    return;
                }
            }
            catch (Exception e)
            {
                DebugHelper.WriteException(e, "GitHub update check failed");
            }

            Status = UpdateStatus.UpdateCheckFailed;
        }
Пример #6
0
        private GitHubRelease GetLatestRelease(bool includePreRelease)
        {
            GitHubRelease latestRelease = null;

            List <GitHubRelease> releases = GetReleases();

            if (releases != null && releases.Count > 0)
            {
                if (includePreRelease)
                {
                    latestRelease = releases[0];
                }
                else
                {
                    latestRelease = releases.FirstOrDefault(x => !x.prerelease);
                }
            }

            return(latestRelease);
        }
Пример #7
0
        private string GetDownloadURL(GitHubRelease release)
        {
            if (release.assets != null && release.assets.Count > 0)
            {
                GitHubAsset asset = release.assets[0];

                if (asset != null && !string.IsNullOrEmpty(asset.name))
                {
                    return string.Format("https://github.com/{0}/{1}/releases/download/{2}/{3}", Owner, Repo, release.tag_name, asset.name);
                }
            }

            return null;
        }
Пример #8
0
        private 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;

                    if (isPortable)
                    {
                        endsWith = "portable.zip";
                    }
                    else
                    {
                        endsWith = ".exe";
                    }

                    foreach (GitHubAsset asset in release.assets)
                    {
                        if (asset != null && !string.IsNullOrEmpty(asset.name) && asset.name.EndsWith(endsWith, StringComparison.InvariantCultureIgnoreCase))
                        {
                            Filename = asset.name;

                            if (isBrowserDownloadURL)
                            {
                                DownloadURL = asset.browser_download_url;
                            }
                            else
                            {
                                DownloadURL = asset.url;
                            }

                            return true;
                        }
                    }
                }
            }

            return false;
        }