protected override void DoCheck(SetProgressDelegate prog, ICollection <ShowItem> showList, TVDoc.ScanSettings settings) { // get list of files being downloaded by uTorrent string resDatFile = TVSettings.Instance.ResumeDatPath; if (string.IsNullOrEmpty(resDatFile) || !File.Exists(resDatFile)) { return; } try { BTResume btr = new BTResume(prog, resDatFile); if (!btr.LoadResumeDat()) { return; } List <TorrentEntry> downloading = btr.AllFilesBeingDownloaded(); SearchForAppropriateDownloads(downloading, DownloadApp.uTorrent, settings); } catch (FormatException fex) { LOGGER.Error($"Got a format exception accessing {resDatFile}, message: {fex.Message}"); } }
public List <TorrentEntry>?GetTorrentDownloads() { string resDatFile = TVSettings.Instance.ResumeDatPath; try { // get list of files being downloaded by uTorrent if (string.IsNullOrEmpty(resDatFile) || !File.Exists(resDatFile)) { return(null); } BTResume btr = new BTResume((percent, message) => { }, resDatFile); if (!btr.LoadResumeDat()) { return(null); } return(btr.AllFilesBeingDownloaded()); } catch (IOException i) { Logger.Warn($"Could not get downloads from uTorrent: {i.Message}"); return(null); } catch (FormatException fex) { Logger.Warn($"Could not parse contents of uTorrent resource file: Got a format exception accessing {resDatFile}, message: {fex.Message}"); return(null); } }
internal static IEnumerable <TorrentEntry> GetTorrentDownloads() { // get list of files being downloaded by uTorrent string resDatFile = TVSettings.Instance.ResumeDatPath; if (string.IsNullOrEmpty(resDatFile) || !File.Exists(resDatFile)) { return(null); } BTResume btr = new BTResume((percent, message) => { }, resDatFile); if (!btr.LoadResumeDat()) { return(null); } return(btr.AllFilesBeingDownloaded()); }
protected override void DoCheck(SetProgressDelegate prog, ICollection <ShowItem> showList, TVDoc.ScanSettings settings) { // get list of files being downloaded by uTorrent string resDatFile = TVSettings.Instance.ResumeDatPath; if (string.IsNullOrEmpty(resDatFile) || !File.Exists(resDatFile)) { return; } BTResume btr = new BTResume(prog, resDatFile); if (!btr.LoadResumeDat()) { return; } List <TorrentEntry> downloading = btr.AllFilesBeingDownloaded(); SearchForAppropriateDownloads(downloading, DownloadApp.uTorrent, settings); }
public override void Check(SetProgressDelegate prog, int startpct, int totPct) { // get list of files being downloaded by uTorrent string resDatFile = TVSettings.Instance.ResumeDatPath; if (string.IsNullOrEmpty(resDatFile) || !File.Exists(resDatFile)) { return; } BTResume btr = new BTResume(prog, resDatFile); if (!btr.LoadResumeDat()) { return; } List <TorrentEntry> downloading = btr.AllFilesBeingDownloaded(); SearchForAppropriateDownloads(prog, startpct, totPct, downloading, DownloadApp.uTorrent); }
public void CheckAgainstuTorrent(SetProgressDelegate prog, int startpct, int totPct) { // get list of files being downloaded by uTorrent string resDatFile = this.Settings.ResumeDatPath; if (string.IsNullOrEmpty(resDatFile) || !File.Exists(resDatFile)) return; BTResume btr = new BTResume(prog, resDatFile); if (!btr.LoadResumeDat(Args)) return; List<TorrentEntry> downloading = btr.AllFilesBeingDownloaded(this.Settings, Args); ItemList newList = new ItemList(); ItemList toRemove = new ItemList(); int c = this.TheActionList.Count + 2; int n = 1; prog.Invoke(startpct + totPct * n / c); foreach (Item Action1 in this.TheActionList) { if (this.ActionCancel) return; n++; prog.Invoke(100 * n / c); if (!(Action1 is ItemMissing)) continue; ItemMissing Action = (ItemMissing) (Action1); string showname = Helpers.SimplifyName(Action.Episode.SI.ShowName); foreach (TorrentEntry te in downloading) { FileInfo file = new FileInfo(te.DownloadingTo); if (!this.Settings.UsefulExtension(file.Extension, false)) // not a usefile file extension continue; if (this.SimplifyAndCheckFilename(file.FullName, showname, true, false)) // if (Regex::Match(simplifiedfname,"\\b"+showname+"\\b",RegexOptions::IgnoreCase)->Success) { int seasF; int epF; if (this.FindSeasEp(file, out seasF, out epF, Action.Episode.SI) && (seasF == Action.Episode.SeasonNumber) && (epF == Action.Episode.EpNum)) { toRemove.Add(Action1); newList.Add(new ItemuTorrenting(te, Action.Episode, Action.TheFileNoExt)); break; } } } } foreach (Item i in toRemove) this.TheActionList.Remove(i); foreach (Item Action in newList) this.TheActionList.Add(Action); prog.Invoke(startpct + totPct); }
public override void Check(SetProgressDelegate prog, int startpct, int totPct) { // get list of files being downloaded by uTorrent string resDatFile = TVSettings.Instance.ResumeDatPath; if (string.IsNullOrEmpty(resDatFile) || !File.Exists(resDatFile)) { return; } BTResume btr = new BTResume(prog, resDatFile); if (!btr.LoadResumeDat()) { return; } List <TorrentEntry> downloading = btr.AllFilesBeingDownloaded(); ItemList newList = new ItemList(); ItemList toRemove = new ItemList(); int c = this.ActionList.Count + 2; int n = 1; prog.Invoke(startpct); foreach (Item action1 in this.ActionList) { if (this.ActionCancel) { return; } prog.Invoke(startpct + (totPct - startpct) * (++n) / (c)); if (!(action1 is ItemMissing action)) { continue; } foreach (TorrentEntry te in downloading) { FileInfo file = new FileInfo(te.DownloadingTo); if (!TVSettings.Instance.UsefulExtension(file.Extension, false)) // not a usefile file extension { continue; } //do any of the possible names for the series match the filename? bool matched = (action.Episode.SI.getSimplifiedPossibleShowNames().Any(name => FileHelper.SimplifyAndCheckFilename(file.FullName, name))); if (!matched) { continue; } if (TVDoc.FindSeasEp(file, out int seasF, out int epF, out int maxEp, action.Episode.SI) && (seasF == action.Episode.AppropriateSeasonNumber) && (epF == action.Episode.AppropriateEpNum)) { toRemove.Add(action1); newList.Add(new ItemuTorrenting(te, action.Episode, action.TheFileNoExt)); break; } } } foreach (Item i in toRemove) { this.ActionList.Remove(i); } foreach (Item action in newList) { this.ActionList.Add(action); } prog.Invoke(totPct); }
public override void Check(SetProgressDelegate prog, int startpct, int totPct) { // get list of files being downloaded by uTorrent string resDatFile = TVSettings.Instance.ResumeDatPath; if (string.IsNullOrEmpty(resDatFile) || !File.Exists(resDatFile)) { return; } BTResume btr = new BTResume(prog, resDatFile); if (!btr.LoadResumeDat()) { return; } List <TorrentEntry> downloading = btr.AllFilesBeingDownloaded(); ItemList newList = new ItemList(); ItemList toRemove = new ItemList(); int c = this.TheActionList.Count + 2; int n = 1; prog.Invoke(startpct + totPct * n / c); foreach (Item Action1 in this.TheActionList) { if (this.ActionCancel) { return; } n++; prog.Invoke(100 * n / c); if (!(Action1 is ItemMissing)) { continue; } ItemMissing Action = (ItemMissing)(Action1); string showname = Helpers.SimplifyName(Action.Episode.SI.ShowName); foreach (TorrentEntry te in downloading) { FileInfo file = new FileInfo(te.DownloadingTo); if (!TVSettings.Instance.UsefulExtension(file.Extension, false)) // not a usefile file extension { continue; } if (FileHelper.SimplifyAndCheckFilename(file.FullName, showname, true, false)) // if (Regex::Match(simplifiedfname,"\\b"+showname+"\\b",RegexOptions::IgnoreCase)->Success) { int seasF; int epF; if (TVDoc.FindSeasEp(file, out seasF, out epF, Action.Episode.SI) && (seasF == Action.Episode.SeasonNumber) && (epF == Action.Episode.EpNum)) { toRemove.Add(Action1); newList.Add(new ItemuTorrenting(te, Action.Episode, Action.TheFileNoExt)); break; } } } } foreach (Item i in toRemove) { this.TheActionList.Remove(i); } foreach (Item Action in newList) { this.TheActionList.Add(Action); } prog.Invoke(startpct + totPct); }