Exemple #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;
        }
Exemple #2
0
        private static string GuessShowName(FolderMonitorEntry ai, ShowLibrary library)
        {
            // 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 library.SeasonWords())
            {
                string seasonFinder = ".*" + seasonWord + "[ _\\.]+([0-9]+).*";
                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);
        }
 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;
 }
        private void EditEntry(FolderMonitorEntry fme)
        {
            FolderMonitorEdit ed = new FolderMonitorEdit(fme);

            if ((ed.ShowDialog() != DialogResult.OK) || (ed.Code == -1))
            {
                return;
            }

            fme.TVDBCode = ed.Code;
        }
        private void bnEditEntry_Click(object sender, System.EventArgs e)
        {
            if (lvFMNewShows.SelectedItems.Count == 0)
            {
                return;
            }

            FolderMonitorEntry fme = this.lvFMNewShows.SelectedItems[0].Tag as FolderMonitorEntry;

            EditEntry(fme);
            this.UpdateFMListItem(fme, true);
        }
        private void bnNewFolderOpen_Click(object sender, System.EventArgs e)
        {
            if (this.lvFMNewShows.SelectedItems.Count == 0)
            {
                return;
            }
            FolderMonitorEntry ai = this.lvFMNewShows.SelectedItems[0].Tag as FolderMonitorEntry;

            if (ai != null)
            {
                Helpers.SysOpen(ai.Folder);
            }
        }
 private void bnRemoveNewFolder_Click(object sender, System.EventArgs e)
 {
     if (this.lvFMNewShows.SelectedItems.Count == 0)
     {
         return;
     }
     foreach (ListViewItem lvi in this.lvFMNewShows.SelectedItems)
     {
         FolderMonitorEntry ai = (FolderMonitorEntry)(lvi.Tag);
         this.engine.AddItems.Remove(ai);
     }
     this.FillFMNewShowList(false);
 }
        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;
            }
        }
Exemple #9
0
        public static void GuessShowItem(FolderMonitorEntry ai, ShowLibrary library)
        {
            string showName = GuessShowName(ai, library);

            if (string.IsNullOrEmpty(showName))
            {
                return;
            }

            TheTVDB.Instance.GetLock("GuessShowItem");

            SeriesInfo ser = TheTVDB.Instance.GetSeries(showName);

            if (ser != null)
            {
                ai.TVDBCode = ser.TVDBCode;
            }

            TheTVDB.Instance.Unlock("GuessShowItem");
        }
        //private void ProcessAddItems(FolderMonitorEntryList toAdd)
        //{
        //    foreach (FolderMonitorEntry ai in toAdd)
        //    {
        //        if (ai.TheSeries == null)
        //            continue; // skip

        //        // see if there is a matching show item
        //        ShowItem found = null;
        //        foreach (ShowItem si in this.mDoc.GetShowItems(true))
        //        {
        //            if ((ai.TheSeries != null) && (ai.TheSeries.TVDBCode == si.TVDBCode))
        //            {
        //                found = si;
        //                break;
        //            }
        //        }
        //        this.mDoc.UnlockShowItems();
        //        if (found == null)
        //        {
        //           xxx
        //               ShowItem si = new ShowItem(this.mDoc.GetTVDB(false, ""));
        //            si.TVDBCode = ai.TheSeries.TVDBCode;
        //            //si->ShowName = ai->TheSeries->Name;
        //            this.mDoc.GetShowItems(true).Add(si);
        //            this.mDoc.UnlockShowItems();
        //            this.mDoc.GenDict();
        //            found = si;
        //        }

        //        if ((ai.FolderMode == FolderModeEnum.kfmFolderPerSeason) || (ai.FolderMode == FolderModeEnum.kfmFlat))
        //        {
        //            found.AutoAdd_FolderBase = ai.Folder;
        //            found.AutoAdd_FolderPerSeason = ai.FolderMode == FolderModeEnum.kfmFolderPerSeason;
        //            string foldername = "Season ";

        //            foreach (DirectoryInfo di in new DirectoryInfo(ai.Folder).GetDirectories("*Season *"))
        //            {
        //                string s = di.FullName;
        //                string f = ai.Folder;
        //                if (!f.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
        //                    f = f + System.IO.Path.DirectorySeparatorChar;
        //                f = Regex.Escape(f);
        //                s = Regex.Replace(s, f + "(.*Season ).*", "$1", RegexOptions.IgnoreCase);
        //                if (!string.IsNullOrEmpty(s))
        //                {
        //                    foldername = s;
        //                    break;
        //                }
        //            }

        //            found.AutoAdd_SeasonFolderName = foldername;
        //        }

        //        if ((ai.FolderMode == FolderModeEnum.kfmSpecificSeason) && (ai.SpecificSeason != -1))
        //        {
        //            if (!found.ManualFolderLocations.ContainsKey(ai.SpecificSeason))
        //                found.ManualFolderLocations[ai.SpecificSeason] = new StringList();
        //            found.ManualFolderLocations[ai.SpecificSeason].Add(ai.Folder);
        //        }

        //        this.mDoc.Stats().AutoAddedShows++;
        //    }

        //    this.mDoc.Dirty();
        //    toAdd.Clear();

        //    this.FillFMNewShowList(true);
        //}

        //private void GuessAll() // not all -> selected only
        //{
        //    foreach (FolderMonitorEntry ai in this.mDoc.AddItems)
        //        this.mDoc.MonitorGuessShowItem(ai);
        //    this.FillFMNewShowList(false);
        //}

        private void bnVisitTVcom_Click(object sender, System.EventArgs e)
        {
            if (lvFMNewShows.SelectedItems.Count == 0)
            {
                return;
            }

            FolderMonitorEntry fme = this.lvFMNewShows.SelectedItems[0].Tag as FolderMonitorEntry;

            if (fme == null)
            {
                return;
            }

            int code = fme.TVDBCode;

            if (code != -1)
            {
                Helpers.SysOpen(TheTVDB.Instance.WebsiteURL(code, -1, false));
            }
        }
        private void bnIgnoreNewFolder_Click(object sender, System.EventArgs e)
        {
            if (this.lvFMNewShows.SelectedItems.Count == 0)
            {
                return;
            }

            DialogResult res = MessageBox.Show("Add selected folders to the 'Bulk Add Shows' ignore folders list?", "Bulk Add Shows", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (res != DialogResult.Yes)
            {
                return;
            }

            foreach (ListViewItem lvi in this.lvFMNewShows.SelectedItems)
            {
                FolderMonitorEntry ai = (FolderMonitorEntry)(lvi.Tag);
                TVSettings.Instance.IgnoreFolders.Add(ai.Folder.ToLower());
                this.engine.AddItems.Remove(ai);
            }
            this.mDoc.SetDirty();
            this.FillFMNewShowList(false);
            this.FillFolderStringLists();
        }
Exemple #12
0
        public bool CheckFolderForShows(DirectoryInfo di2, bool andGuess, out DirectoryInfo[] subDirs)
        {
            // ..and not already a folder for one of our shows
            string theFolder = di2.FullName.ToLower();

            foreach (ShowItem si in this.mDoc.Library.GetShowItems())
            {
                if (si.AutoAddNewSeasons && !string.IsNullOrEmpty(si.AutoAdd_FolderBase) &&
                    theFolder.IsSubfolderOf(si.AutoAdd_FolderBase))
                {
                    // we're looking at a folder that is a subfolder of an existing show
                    Logger.Info("Rejecting {0} as it's already part of {1}.", theFolder, si.ShowName);
                    subDirs = null;
                    return(true);
                }

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

                            Logger.Info("Rejecting {0} as it's already part of {1}:{2}.", theFolder, si.ShowName, folder);
                            subDirs = null;
                            return(true);
                        }
                    }
                }
            } // for each showitem


            //We don't have it already
            bool hasSeasonFolders;

            try
            {
                hasSeasonFolders = HasSeasonFolders(di2, out string folderName, out DirectoryInfo[] subDirectories, out bool padNumber);

                subDirs = subDirectories;

                //This is an indication that something is wrong
                if (subDirectories is null)
                {
                    return(false);
                }

                bool hasSubFolders = subDirectories.Length > 0;
                if (!hasSubFolders || hasSeasonFolders)
                {
                    if (TVSettings.Instance.BulkAddCompareNoVideoFolders && !HasFilmFiles(di2))
                    {
                        return(false);
                    }

                    if (TVSettings.Instance.BulkAddIgnoreRecycleBin && di2.FullName.Contains("$RECYCLE.BIN", StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                    if (TVSettings.Instance.BulkAddIgnoreRecycleBin && di2.FullName.Contains("\\@Recycle\\", StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }



                    // ....its good!
                    FolderMonitorEntry ai = new FolderMonitorEntry(di2.FullName, hasSeasonFolders, folderName, padNumber);
                    this.AddItems.Add(ai);
                    Logger.Info("Adding {0} as a new folder", theFolder);
                    if (andGuess)
                    {
                        GuessShowItem(ai, this.mDoc.Library);
                    }
                }
            }
            catch (UnauthorizedAccessException)
            {
                Logger.Info("Can't access {0}, so ignoring it", di2.FullName);
                subDirs = null;
                return(true);
            }

            return(hasSeasonFolders);
        }