public static void Run(EpisodeTorrentSearcherResult torrent) { var fileName = @"torrents\" + torrent.Title + ".torrent"; Logger.Get("General").Build().Message("Starting process: " + fileName).Debug(); Process.Start(fileName); }
Torrent Download(Episode episode, EpisodeTorrentSearcherResult result) { var webClient = new CustomWebClient(); if(!Directory.Exists("Torrents")) Directory.CreateDirectory("Torrents"); var fileName = @"torrents\" + result.Title + ".torrent"; try { webClient.DownloadFile(result.DownloadURL, fileName); } catch(Exception e) { Logger.Build().Episode(episode.ID).Message("Error downloading torrent: " + result.DownloadURL + " - " + e).Error(); return null; } Torrent torrent; try { torrent = TorrentParser.ParseFile(fileName); } catch(Exception e) { Logger.Build().Episode(Episode.ID).Message("Error parsing torrent file: " + fileName + "-->" + e).Error(); return null; } return torrent; }
string DisplayResult(EpisodeTorrentSearcherResult result) { return String.Format("{0} ({1}/{2}) {3}MB", result.Title, result.Seeds, result.Leechs, result.MB); }
void LogDownload(EpisodeTrackerDBContext db, Episode episode, EpisodeTorrentSearcherResult result) { var ids = db.Episodes.Where(ep => ep.SeriesID == episode.SeriesID) .WhereTVMatch(result.Match) .Select(ep => ep.ID) .ToArray(); Logger.Build() .Episode(episode.ID) .Message("Logging download for episode IDs: " + String.Join(", ", ids)) .Debug(); foreach(var id in ids) { db.EpisodeDownloadLog.Add(new EpisodeDownloadLog { EpisodeID = id, Date = DateTime.Now, URL = result.DownloadURL.OriginalString }); } db.SaveChanges(); }