Beispiel #1
0
        public AbstractDownloadState GetDownloaderState(dynamic archive_ini)
        {
            var general = archive_ini?.General;

            if (general.modID != null && general.fileID != null && general.gameName != null)
            {
                var info = new NexusApiClient().GetModInfo(general.gameName, general.modID);
                return(new State
                {
                    GameName = general.gameName,
                    FileID = general.fileID,
                    ModID = general.modID,
                    Version = general.version ?? "0.0.0.0",
                    Author = info.author,
                    UploadedBy = info.uploaded_by,
                    UploaderProfile = info.uploaded_users_profile_url,
                    ModName = info.name,
                    SlideShowPic = info.picture_url,
                    NexusURL = NexusApiUtils.GetModURL(info.game_name, info.mod_id),
                    Summary = info.summary,
                    Adult = info.contains_adult_content
                });
            }

            return(null);
        }
Beispiel #2
0
        public async Task <AbstractDownloadState> GetDownloaderState(dynamic archiveINI)
        {
            var general = archiveINI?.General;

            if (general.modID != null && general.fileID != null && general.gameName != null)
            {
                var name     = (string)general.gameName;
                var gameMeta = GameRegistry.GetByMO2ArchiveName(name);
                var game     = gameMeta != null?GameRegistry.GetByMO2ArchiveName(name).Game : GameRegistry.GetByNexusName(name).Game;

                var client = await NexusApiClient.Get();

                var info = await client.GetModInfo(game, general.modID);

                return(new State
                {
                    GameName = general.gameName,
                    FileID = general.fileID,
                    ModID = general.modID,
                    Version = general.version ?? "0.0.0.0",
                    Author = info.author,
                    UploadedBy = info.uploaded_by,
                    UploaderProfile = info.uploaded_users_profile_url,
                    ModName = info.name,
                    SlideShowPic = info.picture_url,
                    NexusURL = NexusApiUtils.GetModURL(game, info.mod_id),
                    Summary = info.summary,
                    Adult = info.contains_adult_content
                });
            }

            return(null);
        }
Beispiel #3
0
        public async Task <AbstractDownloadState?> GetDownloaderState(dynamic archiveINI, bool quickMode)
        {
            var general = archiveINI.General;

            if (general.modID != null && general.fileID != null && general.gameName != null)
            {
                var game = GameRegistry.GetByFuzzyName((string)general.gameName).Game;

                if (quickMode)
                {
                    return(new State
                    {
                        Game = GameRegistry.GetByFuzzyName((string)general.gameName).Game,
                        ModID = long.Parse(general.modID),
                        FileID = long.Parse(general.fileID),
                    });
                }

                var client = DownloadDispatcher.GetInstance <NexusDownloader>().Client ?? await NexusApiClient.Get();

                ModInfo info;
                try
                {
                    info = await client.GetModInfo(game, long.Parse((string)general.modID));
                }
                catch (Exception)
                {
                    return(new State
                    {
                        Game = GameRegistry.GetByFuzzyName((string)general.gameName).Game,
                        ModID = long.Parse(general.modID),
                        FileID = long.Parse(general.fileID),
                    });
                }

                try
                {
                    return(new State
                    {
                        Name = NexusApiUtils.FixupSummary(info.name),
                        Author = NexusApiUtils.FixupSummary(info.author),
                        Version = general.version ?? "0.0.0.0",
                        ImageURL = info.picture_url,
                        IsNSFW = info.contains_adult_content,
                        Description = NexusApiUtils.FixupSummary(info.summary),
                        Game = GameRegistry.GetByFuzzyName((string)general.gameName).Game,
                        ModID = long.Parse(general.modID),
                        FileID = long.Parse(general.fileID)
                    });
                }
                catch (FormatException)
                {
                    Utils.Log(
                        $"Cannot parse ModID/FileID from {(string)general.gameName} {(string)general.modID} {(string)general.fileID}");
                    throw;
                }
            }

            return(null);
        }
Beispiel #4
0
        public ModVM(NexusDownloader.State m)
        {
            this.ModName         = NexusApiUtils.FixupSummary(m.ModName);
            this.ModID           = m.ModID;
            this.ModDescription  = NexusApiUtils.FixupSummary(m.Summary);
            this.ModAuthor       = NexusApiUtils.FixupSummary(m.Author);
            this.IsNSFW          = m.Adult;
            this.ModURL          = m.NexusURL;
            this.ImageURL        = m.SlideShowPic;
            this.ImageObservable = Observable.Return(this.ImageURL)
                                   .ObserveOn(RxApp.TaskpoolScheduler)
                                   .SelectTask(async url =>
            {
                try
                {
                    var ret = new MemoryStream();
                    using (Stream stream = await new HttpClient().GetStreamAsync(url))
                    {
                        stream.CopyTo(ret);
                    }

                    ret.Seek(0, SeekOrigin.Begin);
                    return(ret);
                }
                catch (Exception ex)
                {
                    Utils.LogToFile($"Exception while caching slide {this.ModName} ({this.ModID})\n{ex.ExceptionToString()}");
                    return(default(MemoryStream));
                }
            })
                                   .ObserveOn(RxApp.MainThreadScheduler)
                                   .Select(memStream =>
            {
                if (memStream == null)
                {
                    return(default(BitmapImage));
                }
                try
                {
                    var image = new BitmapImage();
                    image.BeginInit();
                    image.CacheOption  = BitmapCacheOption.OnLoad;
                    image.StreamSource = memStream;
                    image.EndInit();
                    image.Freeze();
                    return(image);
                }
                catch (Exception ex)
                {
                    Utils.LogToFile($"Exception while caching slide {this.ModName} ({this.ModID})\n{ex.ExceptionToString()}");
                    return(default(BitmapImage));
                }
                finally
                {
                    memStream?.Dispose();
                }
            })
                                   .Replay(1)
                                   .RefCount();
        }
Beispiel #5
0
            public override string GetReportEntry(Archive a)
            {
                var profile = UploaderProfile.Replace("/games/",
                                                      "/" + NexusApiUtils.ConvertGameName(GameName).ToLower() + "/");

                return(string.Join("\n",
                                   $"* [{a.Name}](http://nexusmods.com/{NexusApiUtils.ConvertGameName(GameName)}/mods/{ModID})",
                                   $"    * Author : [{UploadedBy}]({profile})",
                                   $"    * Version : {Version}"));
            }
Beispiel #6
0
        public ModVM(NexusDownloader.State m)
        {
            ModName         = NexusApiUtils.FixupSummary(m.ModName);
            ModID           = m.ModID;
            ModDescription  = NexusApiUtils.FixupSummary(m.Summary);
            ModAuthor       = NexusApiUtils.FixupSummary(m.Author);
            IsNSFW          = m.Adult;
            ModURL          = m.NexusURL;
            ImageURL        = m.SlideShowPic;
            ImageObservable = Observable.Return(ImageURL)
                              .ObserveOn(RxApp.TaskpoolScheduler)
                              .SelectTask(async url =>
            {
                try
                {
                    var ret = new MemoryStream();
                    using (Stream stream = await new HttpClient().GetStreamAsync(url))
                    {
                        stream.CopyTo(ret);
                    }

                    ret.Seek(0, SeekOrigin.Begin);
                    return(ret);
                }
                catch (Exception ex)
                {
                    Utils.Error(ex, $"Exception while caching slide {ModName} ({ModID})");
                    return(default(MemoryStream));
                }
            })
                              .ObserveOn(RxApp.MainThreadScheduler)
                              .Select(memStream =>
            {
                if (memStream == null)
                {
                    return(default(BitmapImage));
                }
                try
                {
                    return(UIUtils.BitmapImageFromStream(memStream));
                }
                catch (Exception ex)
                {
                    Utils.Error(ex, $"Exception while caching slide {ModName} ({ModID})");
                    return(default(BitmapImage));
                }
                finally
                {
                    memStream?.Dispose();
                }
            })
                              .Replay(1)
                              .RefCount();
        }
Beispiel #7
0
 public ModVM(NexusDownloader.State m)
 {
     ModName         = NexusApiUtils.FixupSummary(m.ModName);
     ModID           = m.ModID;
     ModDescription  = NexusApiUtils.FixupSummary(m.Summary);
     ModAuthor       = NexusApiUtils.FixupSummary(m.Author);
     IsNSFW          = m.Adult;
     ModURL          = m.NexusURL;
     ImageURL        = m.SlideShowPic;
     ImageObservable = Observable.Return(ImageURL)
                       .ObserveOn(RxApp.TaskpoolScheduler)
                       .DownloadBitmapImage((ex) => Utils.Log($"Skipping slide for mod {ModName} ({ModID})"))
                       .Replay(1)
                       .RefCount(TimeSpan.FromMilliseconds(5000));
 }
Beispiel #8
0
        public async Task <AbstractDownloadState?> GetDownloaderState(dynamic archiveINI, bool quickMode)
        {
            var general = archiveINI.General;

            if (general.modID != null && general.fileID != null && general.gameName != null)
            {
                var game = GameRegistry.GetByFuzzyName((string)general.gameName).Game;
                if (quickMode)
                {
                    return(new State
                    {
                        Game = GameRegistry.GetByFuzzyName((string)general.gameName).Game,
                        ModID = long.Parse(general.modID),
                        FileID = long.Parse(general.fileID),
                    });
                }

                var client = await NexusApiClient.Get();

                ModInfo info;
                try
                {
                    info = await client.GetModInfo(game, long.Parse((string)general.modID));
                }
                catch (Exception)
                {
                    Utils.Error($"Error getting mod info for Nexus mod with {general.modID}");
                    throw;
                }

                return(new State
                {
                    Name = NexusApiUtils.FixupSummary(info.name),
                    Author = NexusApiUtils.FixupSummary(info.author),
                    Version = general.version ?? "0.0.0.0",
                    ImageURL = info.picture_url,
                    IsNSFW = info.contains_adult_content,
                    Description = NexusApiUtils.FixupSummary(info.summary),
                    Game = GameRegistry.GetByFuzzyName((string)general.gameName).Game,
                    ModID = long.Parse(general.modID),
                    FileID = long.Parse(general.fileID)
                });
            }

            return(null);
        }
Beispiel #9
0
        public void Build(ModList lst)
        {
            Text($"### {lst.Name} - Installation Summary");
            Text(
                $"#### Download Summary ({lst.Archives.Count} archives - {lst.Archives.Sum(a => a.Size).ToFileSizeString()})");
            foreach (var archive in SortArchives(lst.Archives))
            {
                var hash = archive.Hash.FromBase64().ToHEX();
                switch (archive)
                {
                case NexusMod m:
                    var profile = m.UploaderProfile.Replace("/games/",
                                                            "/" + NexusApiUtils.ConvertGameName(m.GameName).ToLower() + "/");
                    NoWrapText(
                        $"* [{m.Name}](http://nexusmods.com/{NexusApiUtils.ConvertGameName(m.GameName)}/mods/{m.ModID})");
                    NoWrapText($"    * Author : [{m.UploadedBy}]({profile})");
                    NoWrapText($"    * Version : {m.Version}");
                    break;

                case MODDBArchive m:
                    NoWrapText($"* MODDB - [{m.Name}]({m.URL})");
                    break;

                case MEGAArchive m:
                    NoWrapText($"* MEGA - [{m.Name}]({m.URL})");
                    break;

                case GoogleDriveMod m:
                    NoWrapText(
                        $"* GoogleDrive - [{m.Name}](https://drive.google.com/uc?id={m.Id}&export=download)");
                    break;

                case DirectURLArchive m:
                    NoWrapText($"* URL - [{m.Name} - {m.URL}]({m.URL})");
                    break;
                }

                NoWrapText($"    * Size : {archive.Size.ToFileSizeString()}");
                NoWrapText($"    * SHA256 : [{hash}](https://www.virustotal.com/gui/file/{hash})");
            }

            Text("\n\n");
            var patched = lst.Directives.OfType <PatchedFromArchive>().OrderBy(p => p.To).ToList();

            Text($"#### Summary of ({patched.Count}) patches");
            foreach (var directive in patched)
            {
                NoWrapText(
                    $"* Applying {directive.Patch.Length} byte patch `{directive.FullPath}` to create `{directive.To}`");
            }


            var files = lst.Directives.OrderBy(d => d.To).ToList();

            Text($"\n\n### Install Plan of ({files.Count}) files");
            Text("(ignoring files that are directly copied from archives or listed in the patches section above)");
            foreach (var directive in files.OrderBy(f => f.GetType().Name).ThenByDescending(f => f.To))
            {
                switch (directive)
                {
                case FromArchive f:
                    //NoWrapText($"* `{f.To}` from `{f.FullPath}`");
                    break;

                case CleanedESM i:
                    NoWrapText($"* `{i.To}` by applying a patch to a game ESM ({i.SourceESMHash})");
                    break;

                case RemappedInlineFile i:
                    NoWrapText($"* `{i.To}` by remapping the contents of an inline file");
                    break;

                case InlineFile i:
                    NoWrapText($"* `{i.To}` from `{i.SourceData.Length.ToFileSizeString()}` file included in modlist");
                    break;

                case CreateBSA i:
                    NoWrapText(
                        $"* `{i.To}` by creating a BSA of files found in `{Consts.BSACreationDir}\\{i.TempID}`");
                    break;
                }
            }

            var inlined = lst.Directives.OfType <InlineFile>()
                          .Select(f => (f.To, "inlined", f.SourceData.Length))
                          .Concat(lst.Directives
                                  .OfType <PatchedFromArchive>()
                                  .Select(f => (f.To, "patched", f.Patch.Length)))
                          .ToHashSet()
                          .OrderByDescending(f => f.Length);

            NoWrapText("\n\n### Summary of inlined files in this installer");
            foreach (var inline in inlined)
            {
                NoWrapText($"* {inline.Length.ToFileSizeString()} for {inline.Item2} file {inline.To}");
            }
        }
Beispiel #10
0
 public override string GetManifestURL(Archive a)
 {
     return($"http://nexusmods.com/{NexusApiUtils.ConvertGameName(GameName)}/mods/{ModID}");
 }