public bool DownloadArchive(Archive archive, bool download) { try { switch (archive) { case NexusMod a: string url; try { url = NexusAPI.GetNexusDownloadLink(a as NexusMod, NexusAPIKey, !download); if (!download) { return(true); } } catch (Exception ex) { Info($"{a.Name} - Error Getting Nexus Download URL - {ex.Message}"); return(false); } Info($"Downloading Nexus Archive - {archive.Name} - {a.GameName} - {a.ModID} - {a.FileID}"); DownloadURLDirect(archive, url); return(true); case MEGAArchive a: return(DownloadMegaArchive(a, download)); case GoogleDriveMod a: return(DownloadGoogleDriveArchive(a, download)); case MODDBArchive a: return(DownloadModDBArchive(archive, (archive as MODDBArchive).URL, download)); case MediaFireArchive a: return(false); //return DownloadMediaFireArchive(archive, a.URL, download); case DirectURLArchive a: return(DownloadURLDirect(archive, a.URL, headers: a.Headers, download: download)); } } catch (Exception ex) { Utils.Log($"Download error for file {archive.Name}"); Utils.Log(ex.ToString()); return(false); } return(false); }
private void DownloadMissingArchives(List <Archive> missing) { missing.PMap(archive => { switch (archive) { case NexusMod a: Info($"Downloading Nexus Archive - {archive.Name} - {a.GameName} - {a.ModID} - {a.FileID}"); string url; try { url = NexusAPI.GetNexusDownloadLink(a as NexusMod, NexusAPIKey); } catch (Exception ex) { Info($"{a.Name} - Error Getting Nexus Download URL - {ex.Message}"); return; } DownloadURLDirect(archive, url); break; case GoogleDriveMod a: DownloadGoogleDriveArchive(a); break; case MODDBArchive a: DownloadModDBArchive(archive, (archive as MODDBArchive).URL); break; case MediaFireArchive a: DownloadMediaFireArchive(archive, a.URL); break; case DirectURLArchive a: DownloadURLDirect(archive, a.URL, headers: a.Headers); break; default: break; } }); }