public void Download(bool wait = false) { ConfigStore.LoadFromFile(Path.Combine(Directory.GetCurrentDirectory(), "DepotDownloader.config")); var task1 = ContentDownloader.DownloadAppAsync(); var task = Task.Run(async() => await task1); if (wait) { task.GetAwaiter().GetResult(); } ContentDownloader.ShutdownSteam3(); }
static void Main(string[] args) { if (args.Length == 0) { PrintUsage(); return; } DebugLog.Enabled = false; ConfigStore.LoadFromFile(Path.Combine(Environment.CurrentDirectory, "DepotDownloader.config")); bool bDumpManifest = HasParameter(args, "-manifest-only"); uint appId = GetParameter <uint>(args, "-app", ContentDownloader.INVALID_APP_ID); uint depotId = GetParameter <uint>(args, "-depot", ContentDownloader.INVALID_DEPOT_ID); ContentDownloader.Config.ManifestId = GetParameter <ulong>(args, "-manifest", ContentDownloader.INVALID_MANIFEST_ID); if (appId == ContentDownloader.INVALID_APP_ID) { Console.WriteLine("Error: -app not specified!"); return; } if (depotId == ContentDownloader.INVALID_DEPOT_ID && ContentDownloader.Config.ManifestId != ContentDownloader.INVALID_MANIFEST_ID) { Console.WriteLine("Error: -manifest requires -depot to be specified"); return; } ContentDownloader.Config.DownloadManifestOnly = bDumpManifest; int cellId = GetParameter <int>(args, "-cellid", -1); if (cellId == -1) { cellId = 0; } ContentDownloader.Config.CellID = cellId; ContentDownloader.Config.BetaPassword = GetParameter <string>(args, "-betapassword"); string fileList = GetParameter <string>(args, "-filelist"); string[] files = null; if (fileList != null) { try { string fileListData = File.ReadAllText(fileList); files = fileListData.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); ContentDownloader.Config.UsingFileList = true; ContentDownloader.Config.FilesToDownload = new List <string>(); ContentDownloader.Config.FilesToDownloadRegex = new List <Regex>(); foreach (var fileEntry in files) { try { Regex rgx = new Regex(fileEntry, RegexOptions.Compiled | RegexOptions.IgnoreCase); ContentDownloader.Config.FilesToDownloadRegex.Add(rgx); } catch { ContentDownloader.Config.FilesToDownload.Add(fileEntry); continue; } } Console.WriteLine("Using filelist: '{0}'.", fileList); } catch (Exception ex) { Console.WriteLine("Warning: Unable to load filelist: {0}", ex.ToString()); } } string username = GetParameter <string>(args, "-username") ?? GetParameter <string>(args, "-user"); string password = GetParameter <string>(args, "-password") ?? GetParameter <string>(args, "-pass"); ContentDownloader.Config.InstallDirectory = GetParameter <string>(args, "-dir"); ContentDownloader.Config.DownloadAllPlatforms = HasParameter(args, "-all-platforms"); ContentDownloader.Config.VerifyAll = HasParameter(args, "-verify-all") || HasParameter(args, "-verify_all") || HasParameter(args, "-validate"); ContentDownloader.Config.MaxServers = GetParameter <int>(args, "-max-servers", 8); ContentDownloader.Config.MaxDownloads = GetParameter <int>(args, "-max-downloads", 4); string branch = GetParameter <string>(args, "-branch") ?? GetParameter <string>(args, "-beta") ?? "Public"; if (username != null && password == null) { Console.Write("Enter account password for \"{0}\": ", username); password = Util.ReadPassword(); Console.WriteLine(); } else if (username == null) { Console.WriteLine("No username given. Using anonymous account with dedicated server subscription."); } ContentDownloader.InitializeSteam3(username, password); ContentDownloader.DownloadApp(appId, depotId, branch); ContentDownloader.ShutdownSteam3(); }
static async Task MainAsync(string[] args) { if (args.Length == 0) { PrintUsage(); return; } DebugLog.Enabled = false; ConfigStore.LoadFromFile(Path.Combine(Directory.GetCurrentDirectory(), "DepotDownloader.config")); bool bDumpManifest = HasParameter(args, "-manifest-only"); uint appId = GetParameter <uint>(args, "-app", ContentDownloader.INVALID_APP_ID); uint depotId = GetParameter <uint>(args, "-depot", ContentDownloader.INVALID_DEPOT_ID); ContentDownloader.Config.ManifestId = GetParameter <ulong>(args, "-manifest", ContentDownloader.INVALID_MANIFEST_ID); if (appId == ContentDownloader.INVALID_APP_ID) { Console.WriteLine("Error: -app not specified!"); return; } if (depotId == ContentDownloader.INVALID_DEPOT_ID && ContentDownloader.Config.ManifestId != ContentDownloader.INVALID_MANIFEST_ID) { Console.WriteLine("Error: -manifest requires -depot to be specified"); return; } ContentDownloader.Config.DownloadManifestOnly = bDumpManifest; int cellId = GetParameter <int>(args, "-cellid", -1); if (cellId == -1) { cellId = 0; } ContentDownloader.Config.CellID = cellId; ContentDownloader.Config.BetaPassword = GetParameter <string>(args, "-betapassword"); string fileList = GetParameter <string>(args, "-filelist"); string[] files = null; if (fileList != null) { try { string fileListData = File.ReadAllText(fileList); files = fileListData.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); ContentDownloader.Config.UsingFileList = true; ContentDownloader.Config.FilesToDownload = new List <string>(); ContentDownloader.Config.FilesToDownloadRegex = new List <Regex>(); foreach (var fileEntry in files) { try { Regex rgx = new Regex(fileEntry, RegexOptions.Compiled | RegexOptions.IgnoreCase); ContentDownloader.Config.FilesToDownloadRegex.Add(rgx); } catch { ContentDownloader.Config.FilesToDownload.Add(fileEntry); continue; } } Console.WriteLine("Using filelist: '{0}'.", fileList); } catch (Exception ex) { Console.WriteLine("Warning: Unable to load filelist: {0}", ex.ToString()); } } string username = GetParameter <string>(args, "-username") ?? GetParameter <string>(args, "-user"); string password = GetParameter <string>(args, "-password") ?? GetParameter <string>(args, "-pass"); ContentDownloader.Config.RememberPassword = HasParameter(args, "-remember-password"); ContentDownloader.Config.InstallDirectory = GetParameter <string>(args, "-dir"); ContentDownloader.Config.DownloadAllPlatforms = HasParameter(args, "-all-platforms"); ContentDownloader.Config.VerifyAll = HasParameter(args, "-verify-all") || HasParameter(args, "-verify_all") || HasParameter(args, "-validate"); ContentDownloader.Config.MaxServers = GetParameter <int>(args, "-max-servers", 20); ContentDownloader.Config.MaxDownloads = GetParameter <int>(args, "-max-downloads", 4); string branch = GetParameter <string>(args, "-branch") ?? GetParameter <string>(args, "-beta") ?? "Public"; bool forceDepot = HasParameter(args, "-force-depot"); string os = GetParameter <string>(args, "-os", null); if (ContentDownloader.Config.DownloadAllPlatforms && !String.IsNullOrEmpty(os)) { Console.WriteLine("Error: Cannot specify -os when -all-platforms is specified."); return; } ContentDownloader.Config.MaxServers = Math.Max(ContentDownloader.Config.MaxServers, ContentDownloader.Config.MaxDownloads); if (username != null && password == null && (!ContentDownloader.Config.RememberPassword || !ConfigStore.TheConfig.LoginKeys.ContainsKey(username))) { Console.Write("Enter account password for \"{0}\": ", username); password = Util.ReadPassword(); Console.WriteLine(); } else if (username == null) { Console.WriteLine("No username given. Using anonymous account with dedicated server subscription."); } // capture the supplied password in case we need to re-use it after checking the login key ContentDownloader.Config.SuppliedPassword = password; if (ContentDownloader.InitializeSteam3(username, password)) { await ContentDownloader.DownloadAppAsync(appId, depotId, branch, os, forceDepot).ConfigureAwait(false); ContentDownloader.ShutdownSteam3(); } }
static async Task MainAsync(string[] args) { if (args.Length == 0) { PrintUsage(); return; } DebugLog.Enabled = false; ConfigStore.LoadFromFile(Path.Combine(Directory.GetCurrentDirectory(), "DepotDownloader.config")); #region Common Options string username = GetParameter <string>(args, "-username") ?? GetParameter <string>(args, "-user"); string password = GetParameter <string>(args, "-password") ?? GetParameter <string>(args, "-pass"); ContentDownloader.Config.RememberPassword = HasParameter(args, "-remember-password"); ContentDownloader.Config.DownloadManifestOnly = HasParameter(args, "-manifest-only"); int cellId = GetParameter <int>(args, "-cellid", -1); if (cellId == -1) { cellId = 0; } ContentDownloader.Config.CellID = cellId; string fileList = GetParameter <string>(args, "-filelist"); string[] files = null; if (fileList != null) { try { string fileListData = File.ReadAllText(fileList); files = fileListData.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); ContentDownloader.Config.UsingFileList = true; ContentDownloader.Config.FilesToDownload = new List <string>(); ContentDownloader.Config.FilesToDownloadRegex = new List <Regex>(); foreach (var fileEntry in files) { try { Regex rgx = new Regex(fileEntry, RegexOptions.Compiled | RegexOptions.IgnoreCase); ContentDownloader.Config.FilesToDownloadRegex.Add(rgx); } catch { ContentDownloader.Config.FilesToDownload.Add(fileEntry); continue; } } Console.WriteLine("Using filelist: '{0}'.", fileList); } catch (Exception ex) { Console.WriteLine("Warning: Unable to load filelist: {0}", ex.ToString()); } } ContentDownloader.Config.InstallDirectory = GetParameter <string>(args, "-dir"); ContentDownloader.Config.VerifyAll = HasParameter(args, "-verify-all") || HasParameter(args, "-verify_all") || HasParameter(args, "-validate"); ContentDownloader.Config.MaxServers = GetParameter <int>(args, "-max-servers", 20); ContentDownloader.Config.MaxDownloads = GetParameter <int>(args, "-max-downloads", 4); ContentDownloader.Config.MaxServers = Math.Max(ContentDownloader.Config.MaxServers, ContentDownloader.Config.MaxDownloads); #endregion ulong pubFile = GetParameter <ulong>(args, "-pubfile", ContentDownloader.INVALID_MANIFEST_ID); if (pubFile != ContentDownloader.INVALID_MANIFEST_ID) { #region Pubfile Downloading if (InitializeSteam(username, password)) { await ContentDownloader.DownloadPubfileAsync(pubFile).ConfigureAwait(false); ContentDownloader.ShutdownSteam3(); } #endregion } else { #region App downloading string branch = GetParameter <string>(args, "-branch") ?? GetParameter <string>(args, "-beta") ?? ContentDownloader.DEFAULT_BRANCH; ContentDownloader.Config.BetaPassword = GetParameter <string>(args, "-betapassword"); ContentDownloader.Config.DownloadAllPlatforms = HasParameter(args, "-all-platforms"); string os = GetParameter <string>(args, "-os", null); if (ContentDownloader.Config.DownloadAllPlatforms && !String.IsNullOrEmpty(os)) { Console.WriteLine("Error: Cannot specify -os when -all-platforms is specified."); return; } uint appId = GetParameter <uint>(args, "-app", ContentDownloader.INVALID_APP_ID); if (appId == ContentDownloader.INVALID_APP_ID) { Console.WriteLine("Error: -app not specified!"); return; } uint depotId; bool isUGC = false; ulong manifestId = GetParameter <ulong>(args, "-ugc", ContentDownloader.INVALID_MANIFEST_ID); if (manifestId != ContentDownloader.INVALID_MANIFEST_ID) { depotId = appId; isUGC = true; } else { depotId = GetParameter <uint>(args, "-depot", ContentDownloader.INVALID_DEPOT_ID); manifestId = GetParameter <ulong>(args, "-manifest", ContentDownloader.INVALID_MANIFEST_ID); if (depotId == ContentDownloader.INVALID_DEPOT_ID && manifestId != ContentDownloader.INVALID_MANIFEST_ID) { Console.WriteLine("Error: -manifest requires -depot to be specified"); return; } } if (InitializeSteam(username, password)) { await ContentDownloader.DownloadAppAsync(appId, depotId, manifestId, branch, os, isUGC).ConfigureAwait(false); ContentDownloader.ShutdownSteam3(); } #endregion } }
static void Main(string[] args) { if (args.Length == 0) { PrintUsage(); return; } Program instance = new Program(); DebugLog.Enabled = false; ConfigStore.LoadFromFile(Path.Combine(Environment.CurrentDirectory, "DepotDownloader.config")); instance.ParseOrPromptUserAndPassword(args); ParseGeneralContentDownloaderParams(args); ParseFileList(args); if (HasParameter(args, "-steamvrwin")) { instance.GetSteamVRWin(); return; } if (HasParameter(args, "-steamvr")) { instance.GetSteamVR(); return; } ContentDownloader.Config.DownloadManifestOnly = HasParameter(args, "-manifest-only"); ContentDownloader.Config.BetaPassword = GetParameter <string>(args, "-betapassword"); var dir = GetParameter <string>(args, "-dir"); var dl = new Downloadable(); dl.AppId = GetParameter <uint>(args, "-app", dl.AppId); dl.DepotId = GetParameter <uint>(args, "-depot", dl.DepotId); dl.Branch = GetBranch(args); dl.ManifestId = GetParameter <ulong>(args, "-manifest", dl.ManifestId); if (dl.AppId == ContentDownloader.INVALID_APP_ID) { Console.WriteLine("Error: -app not specified!"); return; } if (dl.DepotId == ContentDownloader.INVALID_DEPOT_ID && dl.ManifestId != ContentDownloader.INVALID_MANIFEST_ID) { Console.WriteLine("Error: -manifest requires -depot to be specified"); return; } dl.ForceDepot = HasParameter(args, "-force-depot"); if (instance.Start()) { instance.Download(dir, dl); instance.Shutdown(); } }