Skip to content

Commit

Permalink
Changed order outputs and downloads are done to prevent apod metadata…
Browse files Browse the repository at this point in the history
… from outputting after an error
  • Loading branch information
wmcnamara committed Dec 31, 2020
1 parent a19f1b3 commit 101bd09
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,23 @@ async static Task Main(string[] args)

Console.WriteLine("Astronomy Picture Of The Day | Program Created by Weston McNamara\n");

//Ouput the title, date, and an image explanation
Console.WriteLine(apod.title);
Console.WriteLine(apod.date + "\n\n");
Console.WriteLine(apod.explanation + "\n\n");

//After displaying that, download the background, and set the desktop background with the new image.
using (var client = new WebClient())
{
Console.WriteLine("Downloading Background...");
client.DownloadFile(apod.hdurl, "bg.jpg");
SetDesktopBackground(Path.GetFullPath("bg.jpg"));
Console.WriteLine("Background Updated!");
Console.WriteLine("Background Updated!\n");
}

//Ouput the title, date, and an image explanation
Console.WriteLine(apod.title);
Console.WriteLine(apod.date + "\n\n");
Console.WriteLine(apod.explanation + "\n");
}
catch (Exception e)
{

//Console.WriteLine("\nException Caught!");
//Console.WriteLine("Message :{0} ", e.Message);
Console.WriteLine("\nThe APOD today is not a format that can be set to a desktop background, such as a video. Please visit the official APOD website to view todays APOD. \n\nhttps://apod.nasa.gov/apod/astropix.html" );
Expand Down

0 comments on commit 101bd09

Please sign in to comment.