Пример #1
0
 void Download(string dir, Downloadable dl)
 {
     if (!Started)
     {
         if (!Start())
         {
             return;
         }
     }
     ContentDownloader.Config.InstallDirectory = dir;
     ContentDownloader.Config.ManifestId       = dl.ManifestId;
     ContentDownloader.DownloadApp(dl.AppId, dl.DepotId, dl.Branch, dl.ForceDepot);
 }
Пример #2
0
        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();
        }
Пример #3
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintUsage();
                return;
            }

            DebugLog.Enabled = false;

            ServerCache.Build();
            CDRManager.Update();

            if (HasParameter(args, "-list"))
            {
                CDRManager.ListGameServers();
                return;
            }

            bool bGameserver   = true;
            bool bApp          = false;
            bool bListDepots   = HasParameter(args, "-listdepots");
            bool bDumpManifest = HasParameter(args, "-manifest");

            int    appId    = -1;
            int    depotId  = -1;
            string gameName = GetStringParameter(args, "-game");

            if (gameName == null)
            {
                appId       = GetIntParameter(args, "-app");
                bGameserver = false;

                depotId = GetIntParameter(args, "-depot");

                if (depotId == -1 && appId == -1)
                {
                    Console.WriteLine("Error: -game, -app, or -depot not specified!");
                    return;
                }
                else if (appId >= 0)
                {
                    bApp = true;
                }
            }

            ContentDownloader.Config.DownloadManifestOnly = bDumpManifest;

            int cellId = GetIntParameter(args, "-cellid");

            if (cellId == -1)
            {
                cellId = 0;
                Console.WriteLine(
                    "Warning: Using default CellID of 0! This may lead to slow downloads. " +
                    "You can specify the CellID using the -cellid parameter");
            }

            ContentDownloader.Config.CellID = cellId;

            int depotVersion = GetIntParameter(args, "-version");

            ContentDownloader.Config.PreferBetaVersions = HasParameter(args, "-beta");

            // this is a Steam2 option
            if (!bGameserver && !bApp && depotVersion == -1)
            {
                int latestVer = CDRManager.GetLatestDepotVersion(depotId, ContentDownloader.Config.PreferBetaVersions);

                if (latestVer == -1)
                {
                    Console.WriteLine("Error: Unable to find DepotID {0} in the CDR!", depotId);
                    return;
                }

                string strVersion = GetStringParameter(args, "-version");
                if (strVersion != null && strVersion.Equals("latest", StringComparison.OrdinalIgnoreCase))
                {
                    Console.WriteLine("Using latest version: {0}", latestVer);
                    depotVersion = latestVer;
                }
                else if (strVersion == null)
                {
                    // this could probably be combined with the above
                    Console.WriteLine("No version specified.");
                    Console.WriteLine("Using latest version: {0}", latestVer);
                    depotVersion = latestVer;
                }
                else
                {
                    Console.WriteLine("Available depot versions:");
                    Console.WriteLine("  Oldest: 0");
                    Console.WriteLine("  Newest: {0}", latestVer);
                    return;
                }
            }

            string fileList = GetStringParameter(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 = GetStringParameter(args, "-username");
            string password = GetStringParameter(args, "-password");

            ContentDownloader.Config.InstallDirectory = GetStringParameter(args, "-dir");
            bool bNoExclude = HasParameter(args, "-no-exclude");

            ContentDownloader.Config.DownloadAllPlatforms = HasParameter(args, "-all-platforms");

            if (username != null && password == null)
            {
                Console.Write("Enter account password: "******"Error: No depots for specified game '{0}'", gameName);
                    return;
                }

                if (bListDepots)
                {
                    Console.WriteLine("\n  '{0}' Depots:", gameName);

                    foreach (var depot in depotIDs)
                    {
                        var depotName = CDRManager.GetDepotName(depot);
                        Console.WriteLine("{0} - {1}", depot, depotName);
                    }

                    return;
                }

                foreach (int currentDepotId in depotIDs)
                {
                    depotVersion = CDRManager.GetLatestDepotVersion(currentDepotId, ContentDownloader.Config.PreferBetaVersions);
                    if (depotVersion == -1)
                    {
                        Console.WriteLine("Error: Unable to find DepotID {0} in the CDR!", currentDepotId);
                        ContentDownloader.ShutdownSteam3();
                        return;
                    }

                    ContentDownloader.DownloadDepot(currentDepotId, depotVersion);
                }
            }

            ContentDownloader.ShutdownSteam3();
        }