Example #1
0
        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}");
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        private void bnUTGo_Click(object sender, System.EventArgs e)
        {
            if (!this.CheckResumeDatPath())
            {
                return;
            }

            string searchFolder  = this.txtUTSearchFolder.Text;
            string resumeDatFile = TVSettings.Instance.ResumeDatPath;
            bool   testMode      = this.chkUTTest.Checked;

            if (!File.Exists(resumeDatFile))
            {
                return;
            }

            if (!testMode && !CheckUTorrentClosed())
            {
                return;
            }
            //
            //				 int action = actNone;
            //				 if (chkUTSearchSubfolders->Checked)
            //					 action |=  actSearchSubfolders;
            //
            //
            //
            //				 if ( (action & (actRename | actCopy | actMatchMissing | actHashSearch)) == 0 )
            //					 return;
            //

            this.lvUTResults.Items.Clear();

            BTResume btp = new BTResume(this.SetProg, resumeDatFile);

            List <string> sl = new List <String>();

            foreach (string torrent in this.lbUTTorrents.CheckedItems)
            {
                sl.Add(torrent);
            }

            btp.DoWork(sl, searchFolder, this.lvUTResults, this.cbUTUseHashing.Checked, this.cbUTMatchMissing.Checked, this.cbUTSetPrio.Checked,
                       testMode, this.chkUTSearchSubfolders.Checked, this.mDoc.TheActionList, TVSettings.Instance.FNPRegexs,
                       mDoc.Args);

            if (!testMode)
            {
                RestartUTorrent();
            }
        }
Example #4
0
        private void UpdateResumeDats()
        {
            string searchFolder = txtUTSearchFolder.Text;
            string resume_dir   = Path.Combine(Path.GetDirectoryName(TVSettings.Instance.ResumeDatPath), "resume_dir");
            bool   testMode     = chkUTTest.Checked;

            if (!Directory.Exists(resume_dir))
            {
                return;
            }

            if (!testMode && !CheckUTorrentClosed())
            {
                return;
            }

            lvUTResults.Items.Clear();

            List <string> sl    = new List <string>();
            List <string> files = new List <string>();

            foreach (string torrent in lbUTTorrents.CheckedItems)
            {
                sl.Add(Path.Combine(Path.GetDirectoryName(TVSettings.Instance.ResumeDatPath), torrent));
                foreach (var pair in ResumeDats)
                {
                    if (pair.Value == torrent)
                    {
                        files.Add(Path.Combine(resume_dir, pair.Key) + ".dat");
                    }
                }
            }

            foreach (string resumeDatFile in files)
            {
                BTResume btp = new BTResume(SetProg, resumeDatFile);

                btp.DoWork(sl, searchFolder, lvUTResults, cbUTUseHashing.Checked, cbUTMatchMissing.Checked, cbUTSetPrio.Checked,
                           testMode, chkUTSearchSubfolders.Checked, mDoc.TheActionList, TVSettings.Instance.FNPRegexs,
                           mDoc.Args);
            }

            if (!testMode)
            {
                RestartUTorrent();
            }
        }
Example #5
0
        private void bnUTGo_Click(object sender, EventArgs e)
        {
            if (!CheckResumeDatPath())
            {
                return;
            }

            if (Directory.Exists(Path.Combine(Path.GetDirectoryName(TVSettings.Instance.ResumeDatPath), "resume_dir")))
            {
                UpdateResumeDats();
                return;
            }

            string searchFolder  = txtUTSearchFolder.Text;
            string resumeDatFile = TVSettings.Instance.ResumeDatPath;
            bool   testMode      = chkUTTest.Checked;

            if (!File.Exists(resumeDatFile))
            {
                return;
            }

            if (!testMode && !CheckUTorrentClosed())
            {
                return;
            }

            lvUTResults.Items.Clear();

            BTResume btp = new BTResume(SetProg, resumeDatFile);

            List <string> sl = new List <string>();

            foreach (string torrent in lbUTTorrents.CheckedItems)
            {
                sl.Add(Path.Combine(Path.GetDirectoryName(resumeDatFile), torrent));
            }

            btp.DoWork(sl, searchFolder, lvUTResults, cbUTUseHashing.Checked, cbUTMatchMissing.Checked, cbUTSetPrio.Checked,
                       testMode, chkUTSearchSubfolders.Checked, mDoc.TheActionList, TVSettings.Instance.FNPRegexs,
                       mDoc.Args);

            if (!testMode)
            {
                RestartUTorrent();
            }
        }
Example #6
0
        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());
        }
Example #7
0
        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);
        }
Example #8
0
        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);
        }
Example #9
0
        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);
        }
Example #10
0
        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);
        }
Example #11
0
        private void bnUTGo_Click(object sender, System.EventArgs e)
        {
            if (!this.CheckResumeDatPath())
                return;

            string searchFolder = this.txtUTSearchFolder.Text;
            string resumeDatFile = this.mDoc.Settings.ResumeDatPath;
            bool testMode = this.chkUTTest.Checked;

            if (!File.Exists(resumeDatFile))
                return;

            if (!testMode && !CheckUTorrentClosed())
                return;
            //
            //				 int action = actNone;
            //				 if (chkUTSearchSubfolders->Checked)
            //					 action |=  actSearchSubfolders;
            //
            //
            //
            //				 if ( (action & (actRename | actCopy | actMatchMissing | actHashSearch)) == 0 )
            //					 return;
            //

            this.lvUTResults.Items.Clear();

            BTResume btp = new BTResume(this.SetProg, resumeDatFile);

            List<string> sl = new List<String>();

            foreach (string torrent in this.lbUTTorrents.CheckedItems)
                sl.Add(torrent);

            btp.DoWork(sl, searchFolder, this.lvUTResults, this.cbUTUseHashing.Checked, this.cbUTMatchMissing.Checked, this.cbUTSetPrio.Checked,
                       testMode, this.chkUTSearchSubfolders.Checked, this.mDoc.TheActionList, this.mDoc.Settings.FNPRegexs,
                       mDoc.Args);

            if (!testMode)
                RestartUTorrent();
        }
Example #12
0
        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);
        }