failed list+fix for repos with colons

This commit is contained in:
kawaiizenbo 2021-10-22 15:30:51 -07:00
parent 30bb587c93
commit 3ae0c0204f

View file

@ -96,7 +96,7 @@ namespace RepoFullDownloader_Core
{ {
link += "/"; link += "/";
} }
string cleanLink = link.Replace("http://", "").Replace("/", "_"); string cleanLink = link.TrimEnd('/').Replace("http://", "").Replace("https://", "").Replace("/", "_").Replace(":", "_");
Directory.CreateDirectory($"./output/{cleanLink}"); Directory.CreateDirectory($"./output/{cleanLink}");
WebClient webClient = new WebClient(); WebClient webClient = new WebClient();
// headers because some repos are 'interesting' // headers because some repos are 'interesting'
@ -168,34 +168,31 @@ namespace RepoFullDownloader_Core
} }
// remove last one because ???? // remove last one because ????
packages.RemoveAt(packages.Count - 1); packages.RemoveAt(packages.Count - 1);
List<string> failed = new List<string>();
foreach(CydiaPackage p in packages) foreach(CydiaPackage p in packages)
{ {
// Download all packages on repo // Download all packages on repo
Random r = new Random();
try try
{ {
Random r = new Random(); string[] choppedUp = p.link.Split('/');
try string fileToDownload = keepOg ? $"./output/{cleanLink}/" + choppedUp[choppedUp.Length - 1] : $"./output/{cleanLink}/" + p.name + "-" + p.version + ".deb";
if (File.Exists(fileToDownload))
{ {
string[] choppedUp = p.link.Split('/'); fileToDownload += "_" + r.Next(0000, 9999);
string fileToDownload = keepOg ? $"./output/{cleanLink}/" + choppedUp[choppedUp.Length - 1] : $"./output/{cleanLink}/" + p.name + "-" + p.version + ".deb";
if (File.Exists(fileToDownload))
{
fileToDownload += "_" + r.Next(0000, 9999);
}
webClient.DownloadFile(new Uri(link + p.link), fileToDownload);
Console.WriteLine("Successfully downloaded " + link + p.link + " as " + fileToDownload);
}
catch (Exception e)
{
Console.WriteLine("Could not download " + link + p.link);
Console.WriteLine(e.Message);
} }
webClient.DownloadFile(new Uri(link + p.link), fileToDownload);
Console.WriteLine("Successfully downloaded " + link + p.link + " as " + fileToDownload);
} }
catch (ArgumentOutOfRangeException) catch (Exception e)
{ {
Console.WriteLine("Finished downloading " + link); Console.WriteLine("Could not download " + link + p.link);
Console.WriteLine(e.Message);
failed.Add(link + p.link);
} }
} }
Console.WriteLine("Finished downloading " + link);
if(failed.Count != 0) File.WriteAllLines($"./output/{cleanLink}/failed.txt", failed);
} }
static void DownloadInstallerRepo(string link) static void DownloadInstallerRepo(string link)