Пример #1
0
        /// <summary>
        /// Gets the ChapterExtractor for the source
        /// </summary>
        /// <param name="strFileOrInputFolder"></param>
        /// <returns>the ChapterExtrator will be returned if found or null if not</returns>
        private ChapterExtractor GetExtractor(string strFileOrInputFolder)
        {
            ChapterExtractor ex = null;

            if (strFileOrInputFolder.ToLowerInvariant().EndsWith(".mpls"))
            {
                ex = new MplsExtractor();
            }
            else if (strFileOrInputFolder.ToLowerInvariant().EndsWith(".txt") || strFileOrInputFolder.ToLowerInvariant().EndsWith(".xml"))
            {
                ex = new TextExtractor();
            }
            else if (!String.IsNullOrEmpty(MeGUI.core.util.FileUtil.GetBlurayPath(strFileOrInputFolder)))
            {
                ex = new BlurayExtractor();
            }
            else if (!String.IsNullOrEmpty(MeGUI.core.util.FileUtil.GetDVDPath(strFileOrInputFolder)))
            {
                ex        = new DvdExtractor();
                this.Text = "Select your Title/PGC";
            }
            else if (System.IO.File.Exists(strFileOrInputFolder))
            {
                ex = new MediaInfoExtractor();
            }

            return(ex);
        }
Пример #2
0
        private void btInput_Click(object sender, EventArgs e)
        {
            if (rbFromFile.Checked)
            {
                openFileDialog.Filter      = "IFO Files (*.ifo)|*.ifo|MPLS Files (*.mpls)|*.mpls|Text Files (*.txt)|*.txt|All Files supported (*.ifo,*.mpls,*.txt)|*.ifo;*.mpls;*.txt";
                openFileDialog.FilterIndex = 4;

                if (this.openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    input.Text = openFileDialog.FileName;

                    if (input.Text.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith("ifo"))
                    {
                        ChapterExtractor ex = new DvdExtractor();
                        using (frmStreamSelect frm = new frmStreamSelect(ex))
                        {
                            if (ex is DvdExtractor)
                            {
                                frm.Text = "Select your PGC";
                            }
                            else
                            {
                                frm.Text = "Select your Playlist";
                            }
                            ex.GetStreams(input.Text);
                            if (frm.ChapterCount == 1 || frm.ShowDialog(this) == DialogResult.OK)
                            {
                                pgc = frm.SelectedSingleChapterInfo;
                                if (pgc.FramesPerSecond == 0)
                                {
                                    pgc.FramesPerSecond = 25.0;
                                }
                                if (String.IsNullOrEmpty(pgc.LangCode))
                                {
                                    pgc.LangCode = "und";
                                }
                            }
                        }
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith("mpls"))
                    {
                        ChapterExtractor ex = new MplsExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else
                    {
                        ChapterExtractor ex = new TextExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                }
            }
            else
            {
                using (FolderBrowserDialog d = new FolderBrowserDialog())
                {
                    d.ShowNewFolderButton = false;
                    d.Description         = "Select DVD, BluRay disc, or folder.";
                    if (d.ShowDialog() == DialogResult.OK)
                    {
                        input.Text = d.SelectedPath;
                        try
                        {
                            ChapterExtractor ex =
                                Directory.Exists(Path.Combine(input.Text, "VIDEO_TS")) ?
                                new DvdExtractor() as ChapterExtractor :
                                File.Exists(Path.Combine(input.Text, "VIDEO_TS.IFO")) ?
                                new DvdExtractor() as ChapterExtractor :
                                Directory.Exists(Path.Combine(Path.Combine(input.Text, "BDMV"), "PLAYLIST")) ?
                                new BlurayExtractor() as ChapterExtractor :
                                null;

                            if (ex == null)
                            {
                                throw new Exception("The location was not detected as DVD, or Blu-Ray.");
                            }

                            using (frmStreamSelect frm = new frmStreamSelect(ex))
                            {
                                if (ex is DvdExtractor)
                                {
                                    frm.Text = "Select your Title";
                                }
                                else
                                {
                                    frm.Text = "Select your Playlist";
                                }
                                ex.GetStreams(input.Text);
                                if (frm.ChapterCount == 1 || frm.ShowDialog(this) == DialogResult.OK)
                                {
                                    pgc = frm.SelectedSingleChapterInfo;
                                    if (pgc.FramesPerSecond == 0)
                                    {
                                        pgc.FramesPerSecond = 25.0;
                                    }
                                    if (String.IsNullOrEmpty(pgc.LangCode))
                                    {
                                        pgc.LangCode = "und";
                                    }
                                }
                            }
                            FreshChapterView();
                            updateTimeLine();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }

            if (chapterListView.Items.Count != 0)
            {
                chapterListView.Items[0].Selected = true;
            }
        }
Пример #3
0
        private void btInput_Click(object sender, EventArgs e)
        {
            if (rbFromFile.Checked)
            {
                openFileDialog.Filter      = "IFO files (*.ifo)|*.ifo|MKV files (*.mkv)|*.mkv|MPLS files (*.mpls)|*.mpls|Text files (*.txt)|*.txt|All supported files (*.ifo,*.mkv,*.mpls,*.txt)|*.ifo;*.mkv;*.mpls;*.txt";
                openFileDialog.FilterIndex = 5;

                if (this.openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    input.Text = openFileDialog.FileName;

                    if (input.Text.ToLowerInvariant().EndsWith("ifo"))
                    {
                        ChapterExtractor ex = new DvdExtractor();
                        using (frmStreamSelect frm = new frmStreamSelect(ex))
                        {
                            if (ex is DvdExtractor)
                            {
                                frm.Text = "Select your PGC";
                            }
                            else
                            {
                                frm.Text = "Select your Playlist";
                            }
                            ex.GetStreams(input.Text);
                            if (frm.ChapterCount <= 1 || frm.ShowDialog(this) == DialogResult.OK)
                            {
                                if (frm.ChapterCount == 0)
                                {
                                    if (MainForm.Instance.Settings.ChapterCreatorMinimumLength > 0)
                                    {
                                        MessageBox.Show("No titles found. Please try to reduce the \"Minimum title length\"");
                                    }
                                    else
                                    {
                                        MessageBox.Show("No titles found.");
                                    }
                                    return;
                                }
                                else
                                {
                                    pgc = frm.SelectedSingleChapterInfo;
                                    if (pgc.FramesPerSecond == 0)
                                    {
                                        MediaInfoFile oInfo = new MediaInfoFile(input.Text);
                                        pgc.FramesPerSecond = oInfo.VideoInfo.FPS;
                                    }
                                    if (String.IsNullOrEmpty(pgc.LangCode))
                                    {
                                        pgc.LangCode = "und";
                                    }
                                }
                            }
                        }
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLowerInvariant().EndsWith("mpls"))
                    {
                        ChapterExtractor ex = new MplsExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLowerInvariant().EndsWith("txt"))
                    {
                        ChapterExtractor ex = new TextExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLowerInvariant().EndsWith("mkv"))
                    {
                        ChapterExtractor ex = new MkvExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else
                    {
                        MessageBox.Show("The input file is not supported.");
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                using (FolderBrowserDialog d = new FolderBrowserDialog())
                {
                    d.ShowNewFolderButton = false;
                    d.Description         = "Select DVD, BluRay disc or folder.";
                    if (d.ShowDialog() == DialogResult.OK)
                    {
                        input.Text = d.SelectedPath;
                        try
                        {
                            ChapterExtractor ex =
                                Directory.Exists(Path.Combine(input.Text, "VIDEO_TS")) ?
                                new DvdExtractor() as ChapterExtractor :
                                File.Exists(Path.Combine(input.Text, "VIDEO_TS.IFO")) ?
                                new DvdExtractor() as ChapterExtractor :
                                Directory.Exists(Path.Combine(Path.Combine(input.Text, "BDMV"), "PLAYLIST")) ?
                                new BlurayExtractor() as ChapterExtractor :
                                null;

                            if (ex == null)
                            {
                                MessageBox.Show("The input folder is not supported.");
                                return;
                            }

                            using (frmStreamSelect frm = new frmStreamSelect(ex))
                            {
                                if (ex is DvdExtractor)
                                {
                                    frm.Text = "Select your Title";
                                }
                                else
                                {
                                    frm.Text = "Select your Playlist";
                                }
                                ex.GetStreams(input.Text);
                                if (frm.ChapterCount <= 1 || frm.ShowDialog(this) == DialogResult.OK)
                                {
                                    if (frm.ChapterCount == 0)
                                    {
                                        if (MainForm.Instance.Settings.ChapterCreatorMinimumLength > 0)
                                        {
                                            MessageBox.Show("No titles found. Please try to reduce the \"Minimum title length\"");
                                        }
                                        else
                                        {
                                            MessageBox.Show("No titles found.");
                                        }
                                        return;
                                    }
                                    else
                                    {
                                        pgc = frm.SelectedSingleChapterInfo;
                                        if (pgc.FramesPerSecond == 0)
                                        {
                                            MediaInfoFile oInfo = new MediaInfoFile(input.Text);
                                            pgc.FramesPerSecond = oInfo.VideoInfo.FPS;
                                        }
                                        if (String.IsNullOrEmpty(pgc.LangCode))
                                        {
                                            pgc.LangCode = "und";
                                        }
                                    }
                                }
                            }
                            FreshChapterView();
                            updateTimeLine();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }

            if (chapterListView.Items.Count != 0)
            {
                chapterListView.Items[0].Selected = true;
            }

            if (pgc.FramesPerSecond > 0)
            {
                fpsChooser.Value = (decimal)pgc.FramesPerSecond;
                bFPSKnown        = true;
            }
            else
            {
                bFPSKnown = false;
            }

            string path = String.Empty;

            if (Directory.Exists(MainForm.Instance.Settings.DefaultOutputDir) && FileUtil.IsDirWriteable(MainForm.Instance.Settings.DefaultOutputDir))
            {
                path = MainForm.Instance.Settings.DefaultOutputDir;
            }
            else if (!String.IsNullOrEmpty(input.Text) && Directory.Exists(Path.GetDirectoryName(input.Text)) && FileUtil.IsDirWriteable(Path.GetDirectoryName(input.Text)))
            {
                path = Path.GetDirectoryName(input.Text);
            }

            string file = String.Empty;

            if (String.IsNullOrEmpty(Path.GetFileNameWithoutExtension(input.Text)))
            {
                file = "Chapter Information.txt";
            }
            else
            {
                file = Path.GetFileNameWithoutExtension(input.Text) + " - Chapter Information.txt";
            }
            if (rbXML.Checked)
            {
                Path.ChangeExtension(file, "xml");
            }
            else if (rbQPF.Checked)
            {
                Path.ChangeExtension(file, "qpf");
            }

            if (String.IsNullOrEmpty(path))
            {
                output.Text = file;
            }
            else
            {
                output.Text = Path.Combine(path, file);
            }
        }