Beispiel #1
0
        private void UpdatePreview(List <TVSettings.FilenameProcessorRE> rel)
        {
            lvPreview.BeginUpdate();
            DirectoryInfo d = new DirectoryInfo(txtFolder.Text);

            foreach (FileInfo fi in d.GetFiles())
            {
                if (!TVSettings.Instance.UsefulExtension(fi.Extension, true))
                {
                    continue; // move on
                }
                ShowItem si = cbShowList.SelectedIndex >= 0 ? shows[cbShowList.SelectedIndex] : null;
                bool     r  = TVDoc.FindSeasEp(fi, out int seas, out int ep, out int maxEp, si, rel, false,
                                               out TVSettings.FilenameProcessorRE matchRex);

                ListViewItem lvi = new ListViewItem {
                    Text = fi.Name
                };
                lvi.SubItems.Add((seas == -1) ? "-" : seas.ToString());
                lvi.SubItems.Add((ep == -1) ? "-" : ep + ((maxEp != -1) ? "-" + maxEp : ""));
                lvi.SubItems.Add((matchRex == null) ? "-" : matchRex.Notes);
                if (!r)
                {
                    lvi.BackColor = Helpers.WarningColor();
                }

                lvPreview.Items.Add(lvi);
            }

            lvPreview.EndUpdate();
        }
Beispiel #2
0
        private void FillExamples()
        {
            if (eps is null)
            {
                return;
            }

            lvTest.Items.Clear();
            foreach (ProcessedEpisode pe in eps)
            {
                ListViewItem lvi = new ListViewItem();
                string       fn  = TVSettings.Instance.FilenameFriendly(cn.NameFor(pe));
                lvi.Text = fn;

                bool   ok   = FinderHelper.FindSeasEp(new FileInfo(fn + ".avi"), out int seas, out int ep, out int maxEp, pe.Show);
                bool   ok1  = ok && seas == pe.AppropriateSeasonNumber;
                bool   ok2  = ok && ep == pe.AppropriateEpNum;
                string pre1 = ok1 ? "" : "* ";
                string pre2 = ok2 ? "" : "* ";

                lvi.SubItems.Add(pre1 + (seas != -1 ? seas.ToString() : ""));
                lvi.SubItems.Add(pre2 + (ep != -1 ? ep.ToString() : "") + (maxEp != -1 ? "-" + maxEp : ""));

                lvi.Tag = pe;

                if (!ok || !ok1 || !ok2)
                {
                    lvi.BackColor = Helpers.WarningColor();
                }

                lvTest.Items.Add(lvi);
            }
        }
        private void FillPreview()
        {
            lvPreview.Items.Clear();
            if ((string.IsNullOrEmpty(txtFolder.Text)) || (!Directory.Exists(txtFolder.Text)))
            {
                txtFolder.BackColor = Helpers.WarningColor();
                return;
            }
            else
            {
                txtFolder.BackColor = SystemColors.Window;
            }

            if (Grid1.RowsCount <= 1) // 1 for header
            {
                return;               // empty
            }

            lvPreview.Enabled = true;

            List <TVSettings.FilenameProcessorRE> rel = new List <TVSettings.FilenameProcessorRE>();

            if (chkTestAll.Checked)
            {
                for (int i = 1; i < Grid1.RowsCount; i++)
                {
                    TVSettings.FilenameProcessorRE re = RegExForRow(i);
                    if (re != null)
                    {
                        rel.Add(re);
                    }
                }
            }
            else
            {
                int[] rowsIndex = Grid1.Selection.GetSelectionRegion().GetRowsIndex();
                if (rowsIndex.Length == 0)
                {
                    return;
                }

                TVSettings.FilenameProcessorRE re2 = RegExForRow(rowsIndex[0]);
                if (re2 != null)
                {
                    rel.Add(re2);
                }
                else
                {
                    return;
                }
            }

            UpdatePreview(rel);
        }
Beispiel #4
0
        private void RadioButton2_CheckedChanged(object sender, EventArgs e)
        {
            lvPreview.Items.Clear();
            lvPreview.BeginUpdate();

            ListViewItem lvi = new ListViewItem
            {
                Text      = "Please wait as we download current torrent queue",
                BackColor = Helpers.WarningColor()
            };

            lvPreview.Items.Add(lvi);

            lvPreview.EndUpdate();
            StartTimer();
        }
        private void txtFolder_TextChanged(object sender, System.EventArgs e)
        {
            bool ok = true;

            if (!string.IsNullOrEmpty(this.txtFolder.Text))
            {
                try
                {
                    ok = System.IO.Directory.Exists(this.txtFolder.Text);
                }
                catch
                {
                }
            }
            this.txtFolder.BackColor = ok ? System.Drawing.SystemColors.Window : Helpers.WarningColor();
        }
Beispiel #6
0
        private void txtFolder_TextChanged()
        {
            bool ok = true;

            if (!string.IsNullOrEmpty(txtFolder.Text))
            {
                try
                {
                    ok = System.IO.Directory.Exists(txtFolder.Text);
                }
                catch
                {
                    // ignored
                }
            }
            txtFolder.BackColor = ok ? SystemColors.Window : Helpers.WarningColor();
        }
Beispiel #7
0
        private void UpdatePreview([NotNull] List <TVSettings.FilenameProcessorRE> rel)
        {
            lvPreview.BeginUpdate();

            DirectoryInfo d = new DirectoryInfo(txtFolder.Text);

            foreach (FileInfo fi in d.GetFiles())
            {
                if (!TVSettings.Instance.FileHasUsefulExtension(fi, true))
                {
                    continue; // move on
                }

                ShowItem si = cbShowList.SelectedIndex >= 0 ? shows[cbShowList.SelectedIndex] : null;
                bool     r  = FinderHelper.FindSeasEp(fi, out int seas, out int ep, out int maxEp, si, rel, false,
                                                      out TVSettings.FilenameProcessorRE matchRex);

                IEnumerable <ShowItem> matchingShows = FinderHelper.FindMatchingShows(fi, shows);
                string bestShowName   = FinderHelper.FindBestMatchingShow(fi, shows)?.ShowName;
                string otherShowNames = string.Join(", ",
                                                    matchingShows.Select(item => item.ShowName).Where(s => s != bestShowName));

                string showDisplayString =
                    otherShowNames.Any() ? bestShowName + " - (" + otherShowNames + ")" : bestShowName;

                ListViewItem lvi = new ListViewItem {
                    Text = fi.Name
                };
                lvi.SubItems.Add(showDisplayString);
                lvi.SubItems.Add(seas == -1 ? "-" : seas.ToString());
                lvi.SubItems.Add(ep == -1 ? "-" : ep + (maxEp != -1 ? "-" + maxEp : ""));
                lvi.SubItems.Add(matchRex is null ? "-" : matchRex.Notes);
                if (!r)
                {
                    lvi.BackColor = Helpers.WarningColor();
                }

                lvPreview.Items.Add(lvi);
            }

            lvPreview.EndUpdate();
        }
Beispiel #8
0
        private void FillExamples()
        {
            if (this.Eps == null)
            {
                return;
            }

            this.lvTest.Items.Clear();
            foreach (ProcessedEpisode pe in this.Eps)
            {
                ListViewItem lvi = new ListViewItem();
                string       fn  = TVSettings.Instance.FilenameFriendly(this.CN.NameForExt(pe, null, 0));
                lvi.Text = fn;

                bool ok  = false;
                bool ok1 = false;
                bool ok2 = false;
                if (fn.Length < 255)
                {
                    int seas;
                    int ep;
                    ok  = TVDoc.FindSeasEp(new FileInfo(fn + ".avi"), out seas, out ep, pe.SI);
                    ok1 = ok && (seas == pe.SeasonNumber);
                    ok2 = ok && (ep == pe.EpNum);
                    string pre1 = ok1 ? "" : "* ";
                    string pre2 = ok2 ? "" : "* ";

                    lvi.SubItems.Add(pre1 + ((seas != -1) ? seas.ToString() : ""));
                    lvi.SubItems.Add(pre2 + ((ep != -1) ? ep.ToString() : ""));
                    lvi.Tag = pe;
                }
                if (!ok || !ok1 || !ok2)
                {
                    lvi.BackColor = Helpers.WarningColor();
                }
                this.lvTest.Items.Add(lvi);
            }
        }
        private void AddItemToListView(string filename, int seas, int ep, int maxEp, TVSettings.FilenameProcessorRE?matchRex, bool r)
        {
            IEnumerable <ShowConfiguration> matchingShows = FinderHelper.FindMatchingShows(filename, shows);
            string bestShowName = FinderHelper.FindBestMatchingShow(filename, shows)?.ShowName;

            string otherShowNames    = matchingShows.Select(item => item.ShowName).Where(s => s != bestShowName).ToCsv();
            string showDisplayString = otherShowNames.Any() ? bestShowName + " - (" + otherShowNames + ")" : bestShowName;

            ListViewItem lvi = new ListViewItem {
                Text = filename
            };

            lvi.SubItems.Add(showDisplayString);
            lvi.SubItems.Add(seas == -1 ? "-" : seas.ToString());
            lvi.SubItems.Add(ep == -1 ? "-" : ep + (maxEp != -1 ? "-" + maxEp : ""));
            lvi.SubItems.Add(matchRex is null ? "-" : matchRex.Notes);
            if (!r)
            {
                lvi.BackColor = Helpers.WarningColor();
            }

            lvPreview.Items.Add(lvi);
        }
Beispiel #10
0
        private void FillPreview()
        {
            this.lvPreview.Items.Clear();
            if ((string.IsNullOrEmpty(this.txtFolder.Text)) || (!Directory.Exists(this.txtFolder.Text)))
            {
                this.txtFolder.BackColor = Helpers.WarningColor();
                return;
            }
            else
            {
                this.txtFolder.BackColor = System.Drawing.SystemColors.Window;
            }

            if (this.Grid1.RowsCount <= 1) // 1 for header
            {
                return;                    // empty
            }
            this.lvPreview.Enabled = true;

            List <FilenameProcessorRE> rel = new List <FilenameProcessorRE>();

            if (this.chkTestAll.Checked)
            {
                for (int i = 1; i < this.Grid1.RowsCount; i++)
                {
                    FilenameProcessorRE re = this.REForRow(i);
                    if (re != null)
                    {
                        rel.Add(re);
                    }
                }
            }
            else
            {
                int[] rowsIndex = this.Grid1.Selection.GetSelectionRegion().GetRowsIndex();
                if (rowsIndex.Length == 0)
                {
                    return;
                }

                FilenameProcessorRE re2 = this.REForRow(rowsIndex[0]);
                if (re2 != null)
                {
                    rel.Add(re2);
                }
                else
                {
                    return;
                }
            }

            this.lvPreview.BeginUpdate();
            DirectoryInfo d = new DirectoryInfo(this.txtFolder.Text);

            foreach (FileInfo fi in d.GetFiles())
            {
                int seas;
                int ep;

                if (!this.TheSettings.UsefulExtension(fi.Extension, true))
                {
                    continue; // move on
                }
                ShowItem     si  = this.cbShowList.SelectedIndex >= 0 ? this.SIL[this.cbShowList.SelectedIndex] : null;
                bool         r   = TVDoc.FindSeasEp(fi, out seas, out ep, si, rel, false);
                ListViewItem lvi = new ListViewItem();
                lvi.Text = fi.Name;
                lvi.SubItems.Add((seas == -1) ? "-" : seas.ToString());
                lvi.SubItems.Add((ep == -1) ? "-" : ep.ToString());
                if (!r)
                {
                    lvi.BackColor = Helpers.WarningColor();
                }
                this.lvPreview.Items.Add(lvi);
            }
            this.lvPreview.EndUpdate();
        }