public PlasmaDownloader(IPlasmaDownloaderConfig config, SpringScanner scanner, SpringPaths springPaths) { SpringPaths = springPaths; Config = config; this.scanner = scanner; torrentDownloader = new TorrentDownloader(this); packageDownloader = new PackageDownloader(this); }
public TorrentMgr() { Downloader = new TorrentDownloader(); if (!Directory.Exists("cache\\fs_tr")) { Directory.CreateDirectory("cache\\fs_tr"); } }
public async Task Download() { var downloader = new TorrentDownloader(); //string result = scrapper.Download("Kaguya-sama wa Kokurasetai").Result; downloader.Run(new List <Uri> { new Uri("magnet:?xt=urn:btih:TVVLPUS5IIHR64HCHMELVZCNMFJIAJC2&tr=http://nyaa.tracker.wf:7777/announce&tr=udp://tracker.coppersurfer.tk:6969/announce&tr=udp://tracker.internetwarriors.net:1337/announce&tr=udp://tracker.leechersparadise.org:6969/announce&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://open.stealth.si:80/announce&tr=udp://p4p.arenabg.com:1337/announce&tr=udp://mgtracker.org:6969/announce&tr=udp://tracker.tiny-vps.com:6969/announce&tr=udp://peerfect.org:6969/announce&tr=http://share.camoe.cn:8080/announce&tr=http://t.nyaatracker.com:80/announce&tr=https://open.kickasstracker.com:443/announce") }); }
private static string GetMobiFile(string magnetUrl) { var torrentDownloader = new TorrentDownloader(); var mobiConverter = new MobiConverter(); var downloadDirectory = Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "_temp_" + Guid.NewGuid().ToString())); var magnetLink = new MagnetLink(magnetUrl, downloadDirectory.FullName); var filePath = torrentDownloader.DownloadMagnetLink(magnetLink); var mobiPath = mobiConverter.ConvertToMobi(filePath); return(mobiPath); }
private void CreateDownloader(string token, byte[] checkPoint = null) { AbstractDownloader downloader = null; try { var task = tasks.First(t => t.Key.Equals(token)); if (task.Target is HttpRangableTarget httpRangableTarget) { downloader = new HttpParallelDownloader( task, coreFolderManager, coreCacheManager.GetCacheProviderForTask(token), coreBufferProvider, checkPoint, settingEntries.ThreadNumber); } else if (task.Target is HttpTarget httpTarget) { downloader = new HttpDownloader( task, coreFolderManager, coreCacheManager.GetCacheProviderForTask(token), coreBufferProvider); } else if (task.Target is TorrentTarget torrentTarget) { downloader = new TorrentDownloader( task, torrentProvider.Engine, coreFolderManager, coreCacheManager.GetCacheProviderForTask(token), checkPoint: checkPoint, maximumConnections: settingEntries.MaximumConnections, maximumDownloadSpeed: settingEntries.MaximumDownloadSpeed, maximumUploadSpeed: settingEntries.MaximumUploadSpeed, announceUrls: announceUrls); } } catch (Exception e) { D($"Downloader with task {token} creation failed, {e.Message}"); } if (downloader != null) { D($"Downloader with task {token} created"); downloader.MaximumRetries = settingEntries.MaximumRetries; downloader.StatusChanged += AnyDownloader_StatusChanged; downloaders.Add(downloader); } }
static async Task Main(string[] args) { if (args.Length != 1) { Console.WriteLine("magnetUri not provided"); return; } var scrapper = new HorribleSubsScrapper(); var episodes = await scrapper.Download(args[0]).ConfigureAwait(true); var downloader = new TorrentDownloader(); downloader.Run(episodes.Select(e => e.Url)); }
public bool StartDownload(Uri uri, string label, string hash, string option) { TorrentDownloader dler = prot.TorrentManager.GetURLDownloader(uri.ToString()); global::AzureusEngine.AzCommunication.Torrent tor = dler.Download(); Download dl = prot.DownloadManager.AddDownload(tor); if (dl == null) { return(false); } if (label != "") { dl.Category = label; } TorrentAdded(toUtorrent(dl)); return(true); }
public Download GetDependenciesOnly(string resourceName) { packageDownloader.LoadMasterAndVersions()?.Wait(); var dep = packageDownloader.GetPackageDependencies(resourceName); if (dep == null) { if (torrentDownloader == null) { torrentDownloader = new TorrentDownloader(this); //lazy initialization } dep = torrentDownloader.GetFileDependencies(resourceName); } if (dep != null) { Download down = null; foreach (var dept in dep) { if (!string.IsNullOrEmpty(dept)) { var dd = GetResource(DownloadType.NOTKNOWN, dept); if (dd != null) { if (down == null) { down = dd; } else { down.AddNeededDownload(dd); } } } } return(down); } return(null); }
public Download GetResource(DownloadType type, string name) { if (name == "zk:dev" || name == "Zero-K $VERSION") { return(null); } lock (downloads) { downloads.RemoveAll(x => x.IsAborted || x.IsComplete != null); // remove already completed downloads from list} var existing = downloads.FirstOrDefault(x => x.Name == name || x.Alias == name); if (existing != null) { return(existing); } } if (scanner?.HasResource(name) == true) { return(null); } if (SpringPaths.HasEngineVersion(name)) { return(null); } // check rapid to determine type if (type == DownloadType.NOTKNOWN) { if (packageDownloader.GetByInternalName(name) != null || packageDownloader.GetByTag(name) != null) { type = DownloadType.RAPID; } else { packageDownloader.LoadMasterAndVersions().Wait(); if (packageDownloader.GetByInternalName(name) != null || packageDownloader.GetByTag(name) != null) { type = DownloadType.RAPID; } else { type = DownloadType.MAP; } } } lock (downloads) { if (type == DownloadType.DEMO) { var target = new Uri(name); var targetName = target.Segments.Last(); var filePath = Utils.MakePath(SpringPaths.WritableDirectory, "demos", targetName); if (File.Exists(filePath)) { return(null); } var down = new WebFileDownload(name, filePath, null); down.DownloadType = type; downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs <Download>(down)); //create dowload bar (handled by MainWindow.cs) down.Start(); return(down); } if (type == DownloadType.MAP || type == DownloadType.MISSION) { if (torrentDownloader == null) { torrentDownloader = new TorrentDownloader(this); //lazy initialization } var down = torrentDownloader.DownloadTorrent(name); if (down != null) { down.DownloadType = type; downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs <Download>(down)); return(down); } } if (type == DownloadType.RAPID) { var down = packageDownloader.GetPackageDownload(name); if (down != null) { down.DownloadType = type; down.Alias = name; downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs <Download>(down)); return(down); } } if (type == DownloadType.ENGINE) { var down = new EngineDownload(name, SpringPaths); down.DownloadType = type; downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs <Download>(down)); down.Start(); return(down); } return(null); } }
public Download GetResource(DownloadType type, string name) { lock (downloads) { downloads.RemoveAll(x => x.IsAborted || x.IsComplete != null); // remove already completed downloads from list} var existing = downloads.FirstOrDefault(x => x.Name == name); if (existing != null) { return(existing); } } if (scanner != null && scanner.HasResource(name)) { return(null); } if (type == DownloadType.MOD || type == DownloadType.UNKNOWN) { packageDownloader.LoadMasterAndVersions(false).Wait(); } lock (downloads) { if (type == DownloadType.DEMO) { var target = new Uri(name); var targetName = target.Segments.Last(); var filePath = Utils.MakePath(SpringPaths.WritableDirectory, "demos", targetName); if (File.Exists(filePath)) { return(null); } try { Directory.CreateDirectory(Path.GetDirectoryName(filePath)); } catch {} var down = new WebFileDownload(name, filePath, null); downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs <Download>(down)); //create dowload bar (handled by MainWindow.cs) down.Start(); return(down); } if (type == DownloadType.MOD || type == DownloadType.UNKNOWN) { var down = packageDownloader.GetPackageDownload(name); if (down != null) { downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs <Download>(down)); return(down); } } if (type == DownloadType.MAP || type == DownloadType.MOD || type == DownloadType.UNKNOWN || type == DownloadType.MISSION) { if (torrentDownloader == null) { torrentDownloader = new TorrentDownloader(this); //lazy initialization } var down = torrentDownloader.DownloadTorrent(name); if (down != null) { downloads.Add(down); DownloadAdded.RaiseAsyncEvent(this, new EventArgs <Download>(down)); return(down); } } if (type == DownloadType.GAME) { throw new ApplicationException(string.Format("{0} download not supported in this version", type)); } return(null); } }
public Download GetResource(DownloadType type, string name) { if (name.StartsWith("rapid://")) // note this is not super clean as supplied name might be used for tracking. { name = name.Substring(8); type = DownloadType.RAPID; } if (name == "zk:dev" || name == "Zero-K $VERSION") { return(null); } lock (locker) { // remove already completed downloads from list foreach (var d in downloads.Values.ToList()) { if (d != null && (d.IsAborted || d.IsComplete != null)) { Download dummy; downloads.TryRemove(d.Name, out dummy); } } var existing = downloads.Values.FirstOrDefault(x => x != null && (x.Name == name || x.Alias == name)); if (existing != null) { return(existing); } if (scanner?.HasResource(name) == true) { return(null); } if (SpringPaths.HasEngineVersion(name)) { return(null); } // check rapid to determine type if (type == DownloadType.NOTKNOWN) { if (packageDownloader.GetByInternalName(name) != null || packageDownloader.GetByTag(name) != null) { type = DownloadType.RAPID; } else { packageDownloader.LoadMasterAndVersions().Wait(); if (packageDownloader.GetByInternalName(name) != null || packageDownloader.GetByTag(name) != null) { type = DownloadType.RAPID; } else { type = DownloadType.MAP; } } } if (type == DownloadType.DEMO) { var target = new Uri(name); var targetName = target.Segments.Last(); var filePath = Utils.MakePath(SpringPaths.WritableDirectory, "demos", targetName); if (File.Exists(filePath)) { return(null); } var down = new WebFileDownload(name, filePath, null); down.DownloadType = type; downloads[down.Name] = down; DownloadAdded.RaiseAsyncEvent(this, new EventArgs <Download>(down)); //create download bar (handled by MainWindow.cs) down.Start(); return(down); } if (type == DownloadType.MAP || type == DownloadType.MISSION) { if (torrentDownloader == null) { torrentDownloader = new TorrentDownloader(this); //lazy initialization } var down = torrentDownloader.DownloadTorrent(name); if (down != null) { down.DownloadType = type; downloads[down.Name] = down; DownloadAdded.RaiseAsyncEvent(this, new EventArgs <Download>(down)); return(down); } } if (type == DownloadType.RAPID) { var down = packageDownloader.GetPackageDownload(name); if (down != null) { down.DownloadType = type; down.Alias = name; downloads[down.Name] = down; DownloadAdded.RaiseAsyncEvent(this, new EventArgs <Download>(down)); return(down); } } if (type == DownloadType.ENGINE) { var down = new EngineDownload(name, SpringPaths); down.DownloadType = type; downloads[down.Name] = down; DownloadAdded.RaiseAsyncEvent(this, new EventArgs <Download>(down)); down.Start(); return(down); } return(null); } }