Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- namespace GameCubeDownloader
- {
- class Program
- {
- static void Main(string[] args)
- {
- string href = "<td><a href=\"";
- string slashA = "</a>";
- string delimiter = "\">";
- string URL = "https://archive.org/download/GamecubeCollectionByGhostware/";
- string Root = System.IO.Directory.GetCurrentDirectory();
- string downloadFolder = "/Downloaded/";
- string temporaryFolder = "/temp/";
- string[] source;
- using (WebClient client = new WebClient())
- source = client.DownloadString(URL).Split(new string[] { href }, StringSplitOptions.RemoveEmptyEntries);
- if (!System.IO.Directory.Exists(Root + downloadFolder)) System.IO.Directory.CreateDirectory(Root + downloadFolder);
- if (!System.IO.Directory.Exists(Root + temporaryFolder)) System.IO.Directory.CreateDirectory(Root + temporaryFolder);
- foreach (string snippet in source)
- {
- string file = "N/A";
- try
- {
- string[] important = snippet.Split(new string[] { slashA }, StringSplitOptions.RemoveEmptyEntries)[0].Split(new string[] { delimiter }, StringSplitOptions.RemoveEmptyEntries);
- if (important.Length == 2)
- {
- file = important[1];
- if (important[0].EndsWith(".iso"))
- {
- if (System.IO.File.Exists(Root + downloadFolder + important[1]))
- {
- Console.WriteLine("Already downloaded: " + important[1] + ", Skipping");
- continue;
- }
- while (true)
- {
- if (System.IO.File.Exists(Root + temporaryFolder + important[0]))
- {
- System.IO.File.Delete(temporaryFolder + important[1]);
- Console.WriteLine("Retrying Download: " + important[1]);
- }
- else
- {
- Console.WriteLine("Downloading: " + important[1]);
- }
- using (WebClient client = new WebClient())
- client.DownloadFile(URL + important[0], Root + temporaryFolder + important[1]);
- if (new System.IO.FileInfo(Root + temporaryFolder + important[1]).Length > 1)
- {
- System.IO.File.Move(Root + temporaryFolder + important[1], Root + downloadFolder + important[1]);
- Console.WriteLine("Finshished downloading: " + important[1]);
- break;
- }
- else
- {
- Console.WriteLine("Download Unsucessful: " + important[1]);
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- System.IO.File.AppendAllText(Root + "/Log.txt", "[" + DateTime.Now.ToShortTimeString() + "] " + file + " : " + ex.Message);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment