예제 #1
0
        /// <summary>
        /// Extract the versions and the base URLs from the html string.
        /// </summary>
        Dictionary <UnityVersion, VersionMetadata> ExtractFromHtml(string html, Dictionary <UnityVersion, VersionMetadata> results = null)
        {
            var matches = UNIT_DOWNLOADS_RE.Matches(html);

            results = results ?? new Dictionary <UnityVersion, VersionMetadata>();
            foreach (Match match in matches)
            {
                var version = new UnityVersion(match.Groups[4].Value);
                version.hash = match.Groups[2].Value;

                var iniUrl        = match.Groups[1].Value;
                var componentName = match.Groups[3].Value;

                CachePlatform cachePlatform;
                if (componentName.Contains("Mac"))
                {
                    cachePlatform = CachePlatform.macOS;
                }
                else if (componentName.Contains("Windows"))
                {
                    cachePlatform = CachePlatform.Windows;
                }
                else if (componentName.Contains("Linux"))
                {
                    cachePlatform = CachePlatform.Linux;
                }
                else
                {
                    Logger.LogDebug("Platform name not found in component name: " + componentName);
                    continue;
                }

                VersionMetadata metadata = default;
                if (!results.TryGetValue(version, out metadata))
                {
                    metadata.version = version;
                }

                var platform = metadata.GetPlatform(cachePlatform);
                platform.iniUrl = iniUrl;

                metadata.SetPlatform(cachePlatform, platform);
                results[version] = metadata;
            }
            return(results);
        }
예제 #2
0
        void ParseVersions(CachePlatform cachePlatform, HubUnityVersion[] versions, List <VersionMetadata> results)
        {
            foreach (var version in versions)
            {
                var metadata = new VersionMetadata();
                metadata.version = new UnityVersion(version.version);

                var platform = new VersionPlatformMetadata();
                platform.packages    = new PackageMetadata[version.modules.Length + 1];
                platform.packages[0] = new PackageMetadata()
                {
                    name          = "Unity ",
                    title         = "Unity " + version.version,
                    description   = "Unity Editor",
                    url           = version.downloadUrl,
                    install       = true,
                    mandatory     = false,
                    size          = long.Parse(version.downloadSize),
                    installedsize = long.Parse(version.installedSize),
                    version       = version.version,
                    md5           = version.checksum
                };

                var i = 1;
                foreach (var module in version.modules)
                {
                    platform.packages[i++] = new PackageMetadata()
                    {
                        name          = module.id,
                        title         = module.name,
                        description   = module.description,
                        url           = module.downloadUrl,
                        install       = module.selected,
                        mandatory     = false,
                        size          = long.Parse(module.downloadSize),
                        installedsize = long.Parse(module.installedSize),
                        version       = version.version,
                        md5           = module.checksum
                    };
                }

                Logger.LogDebug($"Found version {metadata.version} with {platform.packages.Length} packages");
                metadata.SetPlatform(cachePlatform, platform);
                results.Add(metadata);
            }
        }