Esempio n. 1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("App Started");
            Console.WriteLine("Talking to Reddit...");

            Reddit        reddit   = new Reddit();
            RedditReponse response = reddit.GetPostsAsync().Result;

            string topImage = response.data.children[0].data.url;

            Console.WriteLine("Reddit data retrieved: " + topImage);
            Console.WriteLine("Downloading file...");

            IFileSaver saver = new FileDownloader();
            string     path  = saver.Save(topImage);

            Console.WriteLine("File downloaded to: " + path);
            Console.WriteLine("Setting desktop wallpaper...");

            IWallpaperSetter setter = CreateWallpaperSetter();

            if (setter == null)
            {
                Console.Error.WriteLine("Platform not detected.");
                return;
            }

            setter.SetWallpaper(path);

            Console.WriteLine("Done!");
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            Console.WriteLine("App Started");

            Reddit           reddit = new Reddit();
            IFileSaver       saver  = new FileDownloader();
            IWallpaperSetter setter = CreateWallpaperSetter();

            if (setter == null)
            {
                Console.Error.WriteLine("Platform not detected.");
                return;
            }

            Console.WriteLine("Getting top image from /r/earthporn...");

            //Get the top image to start with.
            RedditReponse response = reddit.GetPostsAsync(limit: 1).Result;

            bool liked = false;

            while (!liked)
            {
                Child post = response.data.children[0];

                Console.WriteLine("Downloading image: " + post.data.url);

                string path = saver.Save(post.data.url);

                Console.WriteLine("Image downloaded to: " + path);
                Console.WriteLine("Setting desktop wallpaper...");

                setter.SetWallpaper(path);

                Console.WriteLine("Do you like it? [Y/N]");

                var input = Console.ReadLine().Trim();
                liked = input.ToLower().Equals("y", StringComparison.OrdinalIgnoreCase);

                //If they didn't like it, get the next post and try again.
                if (!liked)
                {
                    Console.WriteLine("Getting the next image from /r/earthporn...");

                    response = reddit.GetPostsAsync(limit: 1).Result;

                    Console.WriteLine("Reddit data retrieved.");
                }
            }

            Console.WriteLine("Finished!");
        }