private async Task <string> AskCode() { using (var auth = new AuthServer(@"http://localhost:8888/")) { string authUrl = _spotify.GetAuthUrl().Replace("&", "^&"); Process.Start(new ProcessStartInfo("cmd", $"/c start {authUrl}") { CreateNoWindow = true }); return(await auth.GetAuthCode()); } }
static async Task Main() { AppDomain.CurrentDomain.ProcessExit += new EventHandler(onClose); steamService = OperatingSystem.IsWindows() ? new SteamServiceWindows() : new SteamServiceLinux(); string redirectUrl = @"http://localhost:8888/"; keySender = new InputSenderWindows(); keyFormatter = new KeyFormatterWindows(); pathResolver = new PathResolver(); requestsManager = new SpotifyRequestsManager("7633771350404368ac3e05c9cf73d187", "29bd9ec2676c4bf593f3cc2858099838", redirectUrl); process = new GameProcess(); process.Start(); steamContext = steamService.GetSteamContext(); var accounts = steamContext.GetAccounts(); Console.WriteLine("Awaiting user authorization..."); var server = new AuthServer(redirectUrl); string authUrl = requestsManager.GetAuthUrl().Replace("&", "^&"); Process.Start(new ProcessStartInfo("cmd", $"/c start {authUrl}") { CreateNoWindow = true }); string code = await server.GetAuthCode(); await requestsManager.StartTokenRequests(code); int accSteamId3 = accounts.FirstOrDefault((x) => x.Name == steamContext.LastAccount).SteamId3; string writePath = pathResolver.GetWritePath(process.CurrentProcess, steamContext.UserdataPath, accSteamId3.ToString()); configWriter = new ConfigWriter(writePath); Console.WriteLine("Press the bind key"); var consoleInput = Console.ReadKey(true); currentKeyVirtual = (ushort)consoleInput.Key; currentKey = keyFormatter.GetSourceKey(currentKeyVirtual); trackInfoUpdater = new SpotifyTrackUpdater(requestsManager); trackInfoUpdater.OnPlaybackStateUpdate += onPlaybackStateUpdate; trackInfoUpdater.StartPlaybackUpdate(); }