Example #1
0
        public FolderMonitorEdit(TheTVDB db, FolderMonitorEntry hint)
        {
            this.InitializeComponent();

            this.mTCCF = new TheTVDBCodeFinder("", db);
            this.mTCCF.Dock = DockStyle.Fill;
            this.mTCCF.SelectionChanged += this.CodeChanged;
            this.mTCCF.lvMatches.DoubleClick += this.MatchDoubleClick;

            this.pnlCF.SuspendLayout();
            this.pnlCF.Controls.Add(this.mTCCF);
            this.pnlCF.ResumeLayout();

            if (hint.CodeKnown)
                this.mTCCF.SetHint(hint.TVDBCode.ToString());
            else
            {
                string s = hint.Folder;
                int p = s.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
                this.mTCCF.SetHint(s.Substring(p+1));
            }
            this.Code = -1;
        }
Example #2
0
        public void MonitorGuessShowItem(FolderMonitorEntry ai)
        {
            string showName = this.GuessShowName(ai);

            if (string.IsNullOrEmpty(showName))
                return;

            TheTVDB db = this.GetTVDB(true, "MonitorGuessShowItem");

            SeriesInfo ser = db.FindSeriesForName(showName);
            if (ser != null)
               ai.TVDBCode = ser.TVDBCode;

            db.Unlock("MonitorGuessShowItem");
        }
Example #3
0
        public bool MonitorAddSingleFolder(DirectoryInfo di2, bool andGuess)
        {
            // ..and not already a folder for one of our shows
            string theFolder = di2.FullName.ToLower();
            bool alreadyHaveIt = false;
            foreach (ShowItem si in ShowItems)
            {
                if (si.AutoAddNewSeasons && !string.IsNullOrEmpty(si.AutoAdd_FolderBase) && this.FolderIsSubfolderOf(theFolder, si.AutoAdd_FolderBase))
                {
                    // we're looking at a folder that is a subfolder of an existing show
                    alreadyHaveIt = true;
                    break;
                }

                Dictionary<int, List<string>> afl = si.AllFolderLocations(this.Settings);
                foreach (KeyValuePair<int, List<string>> kvp in afl)
                {
                    foreach (string folder in kvp.Value)
                    {
                        if (theFolder.ToLower() != folder.ToLower())
                            continue;

                        alreadyHaveIt = true;
                        break;
                    }
                }

                if (alreadyHaveIt)
                    break;
            } // for each showitem

            bool hasSeasonFolders = false;
            try
            {
                string folderName = null;
                hasSeasonFolders = MonitorFolderHasSeasonFolders(di2, out folderName);
                bool hasSubFolders = di2.GetDirectories().Length > 0;
                if (!alreadyHaveIt && (!hasSubFolders || hasSeasonFolders))
                {
                    // ....its good!
                    FolderMonitorEntry ai = new FolderMonitorEntry(di2.FullName, hasSeasonFolders, folderName);
                    AddItems.Add(ai);
                    if (andGuess)
                        this.MonitorGuessShowItem(ai);
                }

            }
            catch (UnauthorizedAccessException)
            {
                alreadyHaveIt = true;
            }

            return hasSeasonFolders || alreadyHaveIt;
        }
Example #4
0
        public string GuessShowName(FolderMonitorEntry ai)
        {
            // see if we can guess a season number and show name, too
            // Assume is blah\blah\blah\show\season X
            string showName = ai.Folder;

            foreach (string seasonWord in this.SeasonWords)
            {
                string seasonFinder = ".*" + seasonWord + "[ _\\.]+([0-9]+).*"; // todo: don't look for just one season word
                if (Regex.Matches(showName, seasonFinder, RegexOptions.IgnoreCase).Count == 0)
                    continue;

                try
                {
                    // remove season folder from end of the path
                    showName = Regex.Replace(showName, "(.*)\\\\" + seasonFinder, "$1", RegexOptions.IgnoreCase);
                    break;
                }
                catch (ArgumentException)
                {
                }
            }
            // assume last folder element is the show name
            showName = showName.Substring(showName.LastIndexOf(System.IO.Path.DirectorySeparatorChar.ToString()) + 1);

            return showName;
        }
Example #5
0
        private void EditEntry(FolderMonitorEntry fme)
        {
            FolderMonitorEdit ed = new FolderMonitorEdit(fme);
            if ((ed.ShowDialog() != DialogResult.OK )|| (ed.Code == -1))
                return;

            fme.TVDBCode = ed.Code;
        }
Example #6
0
        private void UpdateFMListItem(FolderMonitorEntry ai, bool makevis)
        {
            foreach (ListViewItem lvi in this.lvFMNewShows.Items)
            {
                if (lvi.Tag != ai) // haven't found the entry yet
                    continue;

                UpdateResultEntry(ai, lvi);

                if (makevis)
                    lvi.EnsureVisible();

                break;
            }
        }
Example #7
0
 private void UpdateResultEntry(FolderMonitorEntry ai, ListViewItem lvi)
 {
     lvi.SubItems.Clear();
     lvi.Text = ai.Folder;
     lvi.SubItems.Add(ai.CodeKnown ? TheTVDB.Instance.GetSeries(ai.TVDBCode).Name : "");
     lvi.SubItems.Add(ai.HasSeasonFoldersGuess ? "Folder per season" : "Flat");
     lvi.SubItems.Add(ai.CodeKnown ? ai.TVDBCode.ToString() : "");
     lvi.Tag = ai;
 }
Example #8
0
        private void EditEntry(FolderMonitorEntry fme)
        {
            FolderMonitorEdit ed = new FolderMonitorEdit(this.mDoc.GetTVDB(false, ""), fme);
            if ((ed.ShowDialog() != DialogResult.OK )|| (ed.Code == -1))
                return;

            fme.TVDBCode = ed.Code;
        }