public static IEnumerable <string> GetUserProfiles()
        {
            string steamPath = string.Format("{0}\\{1}", RegistryUtil.GetSteamInstallPath(), "userdata");

            foreach (string directory in Directory.GetDirectories(steamPath))
            {
                yield return(new DirectoryInfo(directory).Name);
            }
        }
        public static IEnumerable <string> GetGamesWithScreenshots(string steamId32Bit)
        {
            string screenshotsPath = string.Format("{0}\\{1}\\{2}\\{3}", RegistryUtil.GetSteamInstallPath(), "userdata", steamId32Bit, "760\\remote");

            if (!Directory.Exists(string.Format(screenshotsPath)))
            {
                yield break;
            }

            foreach (string directory in Directory.GetDirectories(screenshotsPath))
            {
                yield return(new DirectoryInfo(directory).Name);
            }
        }
 public static string GetGameScreenshotsFullPath(string steamId32Bit, string gameId)
 {
     return(string.Format("{0}\\{1}\\{2}\\{3}\\{4}\\{5}", RegistryUtil.GetSteamInstallPath(), "userdata", steamId32Bit, "760\\remote", gameId, "screenshots"));
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            Console.Title = "SteamShots.NET";

            PrintWelcome();
            if (!FileUtil.ApiKeyFileExists())
            {
                string apiKeyFileName = FileUtil.CreateApiKeyFile();

                PrintHiglightError("You must supply a valid Steam Web API key!");
                Console.WriteLine(string.Format("Please insert your API key in the {0} file", apiKeyFileName));
                WaitForInput();
                Environment.Exit(0);
            }

            FileUtil.CreateSteamShotsDirectory();

            string steamInstallPath = RegistryUtil.GetSteamInstallPath();

            if (steamInstallPath == null)
            {
                PrintHiglightError("Steam does not appear to be installed!");
                WaitForInput();
                Environment.Exit(0);
            }

            PrintHiglightInfo("Discovered Steam: ", steamInstallPath);

            IEnumerable <string> steamUserIds = SteamUtil.GetUserProfiles();

            if (steamUserIds == null || !steamUserIds.Any())
            {
                PrintHiglightError("No Steam screenshots discovered!");
                WaitForInput();
                Environment.Exit(0);
            }

            PrintHiglightInfo("Discovered users with IDs: ", "{ " + string.Join(", ", steamUserIds.ToArray <string>()) + " }");

            foreach (string steamUserId in steamUserIds)
            {
                string steamUsername = SteamApiUtil.GetSteamUsername(FileUtil.ReadApiKey(), steamUserId);

                if (steamUsername != null)
                {
                    PrintHiglightSuccess(string.Format("Resolved Steam user ID {0}: ", steamUserId), steamUsername);

                    IEnumerable <string> gameIds = SteamUtil.GetGamesWithScreenshots(steamUserId);

                    if (gameIds == null || !gameIds.Any())
                    {
                        PrintInlineHighlight("Discovered ", gameIds.Count().ToString(), " games");
                        PrintHiglightWarning("The following user has no game screenshots: ", steamUsername);
                    }
                    else
                    {
                        PrintHiglightInfo("Discovered games with SteamApp IDs: ", "{ " + string.Join(", ", gameIds.ToArray <string>()) + " }");

                        foreach (string gameId in gameIds)
                        {
                            string gameName = SteamApiUtil.GetSteamGameName(gameId);

                            if (gameName != null)
                            {
                                PrintHiglightSuccess(string.Format("Resolved game SteamApp ID {0}: ", gameId), gameName);
                                int screenshotCopyCount = FileUtil.CopyContentsToSteamShots(SteamUtil.GetGameScreenshotsFullPath(steamUserId, gameId), steamUsername, gameName);
                                PrintInlineHighlight("Copied ", screenshotCopyCount.ToString(), " screensots!");
                            }
                            else
                            {
                                PrintHiglightWarning("The following SteamApp ID couldn't resolve: ", gameId);
                            }
                        }

                        Console.WriteLine();
                    }
                }
                else
                {
                    PrintHiglightWarning("The following Steam ID couldn't resolve: ", steamUserId);
                }
            }

            PrintFinished();
            WaitForInput();
        }