/// <summary> /// Creates a temporary container and sends it to the default associated application to DLC. /// </summary> /// <param name="link">The link.</param> private void SendToLinkContainerDownloader(Link link) { var tmp = Path.Combine(Path.GetTempPath(), Utils.CreateSlug(link.Release.Replace('.', ' ').Replace('_', ' ') + " " + link.Source.Name + " " + Utils.Rand.Next().ToString("x"), false) + ".dlc"); File.WriteAllText(tmp, DLCAPI.CreateDLC(link.Release, link.FileURL.Split('\0'))); Utils.Run(tmp); }
/// <summary> /// Rewrites a list of HTTP links to a local DLC container path. /// </summary> /// <param name="link">The link.</param> /// <returns>New copy of the link pointing to a DLC container.</returns> private Link RewriteHTTPLinksToDLC(Link link) { var tmp = Path.Combine(Path.GetTempPath(), Utils.CreateSlug(link.Release.Replace('.', ' ').Replace('_', ' ') + " " + link.Source.Name + " " + Utils.Rand.Next().ToString("x"), false) + ".dlc"); File.WriteAllText(tmp, DLCAPI.CreateDLC(link.Release, link.FileURL.Split('\0'))); return(new Link(link.Source) { Release = link.Release, InfoURL = link.InfoURL, FileURL = tmp, Infos = link.Infos, Quality = link.Quality, Size = link.Size }); }
/// <summary> /// Downloads the specified file to the default download path. /// </summary> /// <param name="link">The link.</param> public static void DownloadFile(Link link) { var file = Path.Combine(Settings.Get("Automatic Download Path"), Utils.SanitizeFileName(link.Release.CutIfLonger(200)).Replace('/', '-')); switch (link.Source.Type) { case Types.Torrent: case Types.Usenet: link.Source.Downloader.Download(link, file + (link.Source.Type == Types.Torrent ? ".torrent" : link.Source.Type == Types.Usenet ? ".nzb" : string.Empty)); break; case Types.DirectHTTP: File.WriteAllText(file + ".rsdf", DLCAPI.CreateRSDF(link.FileURL.Split('\0'))); break; case Types.HTTP: File.WriteAllText(file + ".url", "[InternetShortcut]\r\nURL=" + (link.FileURL ?? link.InfoURL)); return; } }