コード例 #1
0
        public void AddSubtitles()
        {
            DeleteSubtitles();

            try
            {
                var SubFiles = Directory.GetFiles(TB_FolderPath.Text, "*.srt", SearchOption.AllDirectories);
                var Subs     = new List <Subtitle>();

                if (MovieMode)
                {
                    foreach (var item in SubFiles)
                    {
                        Subs.Add(new Subtitle(item));
                    }

                    foreach (var Movie in Movies)
                    {
                        Movie.AddSubs(Subs.Where(x => MatchMovieAndSubs(x, Movie)));
                    }

                    foreach (var Movie in Movies)
                    {
                        foreach (var Sub in Movie.Subs)
                        {
                            Sub.Movie = Movie;
                        }
                    }

                    L_SubCount.Text = (Movies.Sum(x => x.Subs.Count)).ToString();
                }
                else
                {
                    foreach (var item in SubFiles.Where(x => Episode.PathIsValid(x)))
                    {
                        Subs.Add(new Subtitle(item));
                    }

                    foreach (var Season in Seasons)
                    {
                        foreach (var Episode in Season.Episodes)
                        {
                            Episode.AddSubs(Subs.Where(s => s.EpisodeNumber == Episode.EpisodeNumber && s.SeasonNumber == Episode.SeasonNumber));
                        }
                    }

                    foreach (var Season in Seasons)
                    {
                        foreach (var Episode in Season.Episodes)
                        {
                            foreach (var Sub in Episode.Subs)
                            {
                                Sub.Episode = Episode;
                            }
                        }
                    }

                    L_SubCount.Text = (Seasons.Sum(e => e.Episodes.Sum(x => x.Subs.Count))).ToString();
                }
            }
            catch (Exception ex)
            {
                DeleteSubtitles();
                Form1.ShowError(ex.Message);
                L_SeasonCount.Text      = L_EpCount.Text = L_SubCount.Text = "0";
                L_SeasonCount.ForeColor = L_EpCount.ForeColor = L_SubCount.ForeColor = Color.FromArgb(242, 60, 53);
                Clipboard.SetText(ex.ToString());
                CurrentFormState = FormState.Busy;
            }
        }
コード例 #2
0
        private void B_Continue_Click(object sender, EventArgs e)
        {
            if (TB_FolderPath.Text.Length < 3 || !Directory.Exists(TB_FolderPath.Text))
            {
                MessageBox.Show("Folder Path is not Valid", "Invalid Folder Path", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
            }
            if (L_SeasonCount.Text == "0")
            {
                MessageBox.Show("No " + (MovieMode ? "movies" : "episodes") + " were detected, choose another folder", "No Files Detected", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
            }
            if (SelectedNamingStyle == -1)
            {
                MessageBox.Show("No Naming Style is selected, choose a naming style before continuing", "No Naming Style", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
            }
            if (TB_SeriesName.Text == "")
            {
                MessageBox.Show("Series Name can not be Empty", "No Series Name", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
            }
            if (!MovieMode && !Episode.EpIsValid(NamingStyles[SelectedNamingStyle].GetEpName(new Episode(2, 13, "Ep Name"))))
            {
                if (DialogResult.Cancel == MessageBox.Show("The current Naming Style will not be \ndetectable by the App after the Re-Name.\n\nDo you want to continue anyway?", "Naming Style Undetectable", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk))
                {
                    if (!AddNamingRule())
                    {
                        return;
                    }
                }
                else
                {
                    AddNamingRule();
                }
            }

            Cursor.Current = Cursors.WaitCursor;
            foreach (var Season in Seasons)
            {
                Season.Control?.RefreshName();
                foreach (var Episode in Season.Episodes)
                {
                    Episode.Control?.RefreshName();
                    foreach (var Sub in Episode.Subs)
                    {
                        Sub.Control?.RefreshName();
                    }
                }
            }

            foreach (var Movie in Movies)
            {
                Movie.Control?.RefreshName();
                foreach (var Sub in Movie.Subs)
                {
                    Sub.Control?.RefreshName();
                }
            }

            Form1.reviewSubForm.CB_CleanFolders.Checked   = O_CleanFolders;
            Form1.reviewSubForm.CB_ReOrderFolders.Checked = O_ReOrderFolders;
            Form1.reviewSubForm.ToggleDesignMode();
            Form1.reviewSubForm.Show();
            Hide();
            Cursor.Current = Cursors.Default;
        }
コード例 #3
0
        public void RefreshFolder()
        {
            if (TB_FolderPath.Text == "")
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            ClearFiles();

            try
            {
                BlackList = NameExtractor.PreBlackList;
                if (File.Exists("RenamerBlackList.txt"))
                {
                    var pb = new List <string>();
                    foreach (var item in File.ReadAllLines("RenamerBlackList.txt"))
                    {
                        if (!BlackList.Contains(item))
                        {
                            pb.Add(Regex.Escape(item));
                        }
                    }
                    BlackList = FormatBlackList(BlackList.Union(pb).ToArray());
                }
                else
                {
                    File.WriteAllText("RenamerBlackList.txt", "");
                }
            }
            catch (Exception) { BlackList = FormatBlackList(NameExtractor.PreBlackList); }

            try
            {
                var Files      = new List <string>();
                var VideoFiles = new List <string>();

                foreach (var item in Directory.EnumerateFiles(TB_FolderPath.Text, "*.*", SearchOption.AllDirectories))
                {
                    if (IsVideoFile(item) && (MovieMode || Episode.PathIsValid(item)))
                    {
                        VideoFiles.Add(item);
                        if (VideoFiles.Count > 650)
                        {
                            throw new StackOverflowException("File Count exceeded Limit");
                        }
                    }
                    else
                    {
                        Files.Add(item);
                    }
                }

                if (MovieMode) // Movie Mode
                {
                    foreach (var Video in VideoFiles)
                    {
                        Movies.Add(new Movie(Video));
                    }

                    L_SeasonCount.Text = Movies.Count.ToString();

                    foreach (var Movie in Movies.OrderByDescending(x => x.Name))
                    {
                        Movie.Control = new MovieControl(Movie)
                        {
                            Dock = DockStyle.Top
                        };
                        Form1.reviewSubForm.P_Main.Controls.Add(Movie.Control);
                        Movie.Control.Show();
                    }
                }
                else // Series Mode
                {
                    var Episodes = new List <Episode>();
                    foreach (var item in VideoFiles)
                    {
                        Episodes.Add(new Episode(item));
                    }
                    foreach (var SNumber in Season.GetSeasons(Episodes))
                    {
                        Seasons.Add(new Season(SNumber, Episodes.Where(x => x.SeasonNumber == SNumber).ToList()));
                    }

                    L_SeasonCount.Text = Seasons.Count.ToString();
                    L_EpCount.Text     = Episodes.Count.ToString();

                    foreach (var Season in Seasons.OrderByDescending(x => x.SeasonNumber))
                    {
                        Season.Control = new SeasonControl(Season)
                        {
                            Dock = DockStyle.Top
                        };
                        Form1.reviewSubForm.P_Main.Controls.Add(Season.Control);
                        Season.Control.Show();
                    }
                }

                if (O_IncludeSubs)
                {
                    AddSubtitles();
                }

                JunkFiles = Files.Where(f => Movies.All(m => m.FilePath != f && m.Subs.All(s => s.FilePath != f)) &&
                                        Seasons.All(S => S.Episodes.All(e => e.FilePath != f && e.Subs.All(sub => sub.FilePath != f))) &&
                                        !(new FileInfo(f).Attributes.HasFlag(FileAttributes.Hidden))).ToList();

                if (!O_IncludeSubs)
                {
                    JunkFiles.RemoveAll(x => x.EndsWith(".srt"));
                }

                L_SeasonCount.ForeColor = L_EpCount.ForeColor = L_SubCount.ForeColor = FormState.N_Focused.Color;
                CurrentFormState        = GetFormState();
            }
            catch (Exception ex)
            {
                ClearFiles();
                Form1.ShowError(ex.Message);
                L_SeasonCount.Text      = L_EpCount.Text = L_SubCount.Text = "0";
                L_SeasonCount.ForeColor = L_EpCount.ForeColor = L_SubCount.ForeColor = Color.FromArgb(242, 60, 53);
                Clipboard.SetText(ex.ToString());
                CurrentFormState = FormState.Busy;
            }
            Cursor.Current = Cursors.Default;
        }