Пример #1
0
        public static async Task <List <ModlistMetadata> > LoadFromGithub()
        {
            var client = new Common.Http.Client();

            Utils.Log("Loading ModLists from GitHub");
            var metadataResult = client.GetStringAsync(Consts.ModlistMetadataURL);
            var summaryResult  = client.GetStringAsync(Consts.ModlistSummaryURL);

            var metadata = (await metadataResult).FromJsonString <List <ModlistMetadata> >();

            try
            {
                var summaries = (await summaryResult).FromJsonString <List <ModListSummary> >().ToDictionary(d => d.MachineURL);

                foreach (var data in metadata)
                {
                    if (summaries.TryGetValue(data.Links.MachineURL, out var summary))
                    {
                        data.ValidationSummary = summary;
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }

            return(metadata.OrderBy(m => (m.ValidationSummary?.HasFailures ?? false ? 1 : 0, m.Title)).ToList());
        }
Пример #2
0
        private static async Task <IEnumerable <UpdateRecord> > GetFeed(Uri uri)
        {
            var client = new Common.Http.Client();
            var data   = await client.GetStringAsync(uri);

            var reader  = XmlReader.Create(new StringReader(data));
            var results = SyndicationFeed.Load(reader);

            return(results.Items
                   .Select(itm =>
            {
                if (TryParseGameUrl(itm.Links.First(), out var game, out var modId))
                {
                    return new UpdateRecord
                    {
                        TimeStamp = itm.PublishDate.UtcDateTime,
                        Game = game,
                        ModId = modId
                    };
                }

                return null;
            })
                   .NotNull());
        }
Пример #3
0
        /// <summary>
        /// Given an archive hash, search the Wabbajack server for a matching .ini file
        /// </summary>
        /// <param name="hash"></param>
        /// <returns></returns>
        public static async Task <string?> GetModIni(Hash hash)
        {
            var client = new Common.Http.Client();

            try
            {
                return(await client.GetStringAsync(
                           $"{Consts.WabbajackBuildServerUri}indexed_files/{hash.ToHex()}/meta.ini"));
            }
            catch (HttpException)
            {
                return(null);
            }
        }