예제 #1
0
        public QuickSaveDialog(ChapterInfo pgc)
        {
            InitializeComponent();

              this.pgc = pgc;
              QuickSave(Settings.Default.LastOpenDir);
        }
예제 #2
0
 private bool Hidden(ChapterInfo pgc)
 {
     if (checkBoxLessThan20mins.Checked && pgc.Duration < TWENTY) return true;
     if (checkBoxLessThan5.Checked && pgc.Chapters.Count < 5) return true;
     if (checkBoxGreaterThan50.Checked && pgc.Chapters.Count > 50) return true;
     return false;
 }
예제 #3
0
 protected void OnStreamDetected(ChapterInfo pgc)
 {
     if (StreamDetected != null)
     {
         StreamDetected(this, new ProgramChainArg()
         {
             ProgramChain = pgc
         });
     }
 }
예제 #4
0
 void OnNew()
 {
     menuTitles.Items.Clear();
     intIndex = 0;
     pgc      = new ChapterInfo()
     {
         Chapters        = new List <ChapterEntry>(),
         FramesPerSecond = Settings.Default.DefaultFps,
         LangCode        = Settings.Default.DefaultLangCode
     };
     FreshChapterView();
 }
예제 #5
0
        public static ChapterInfo Load(XElement root)
        {
            ChapterInfo ci = new ChapterInfo();

            ci.LangCode  = (string)root.Attribute(XNamespace.Xml + "lang");
            ci.Extractor = (string)root.Attribute("extractor");

            if (root.Element(CgNs + "title") != null)
            {
                ci.Title = (string)root.Element(CgNs + "title");
            }

            XElement @ref = root.Element(CgNs + "ref");

            if (@ref != null)
            {
                ci.ChapterSetId = (int?)@ref.Element(CgNs + "chapterSetId");
                ci.ImdbId       = (string)@ref.Element(CgNs + "imdbId");
                ci.MovieDbId    = (int?)@ref.Element(CgNs + "movieDbId");
            }

            if (root.Attribute("confirmations") != null)
            {
                ci.Confirmations = (int)root.Attribute("confirmations");
            }


            XElement src = root.Element(CgNs + "source");

            if (src != null)
            {
                ci.SourceName = (string)src.Element(CgNs + "name");
                if (src.Element(CgNs + "type") != null)
                {
                    ci.SourceType = (string)src.Element(CgNs + "type");
                }
                ci.SourceHash      = (string)src.Element(CgNs + "hash");
                ci.FramesPerSecond = Convert.ToDouble(src.Element(CgNs + "fps").Value, new System.Globalization.NumberFormatInfo());
                ci.Duration        = TimeSpan.Parse(src.Element(CgNs + "duration").Value);
                if (src.Element(CgNs + "volume") != null)
                {
                    ci.VolumeName = (string)src.Element(CgNs + "volume");
                }
            }

            ci.Chapters = root.Element(CgNs + "chapters").Elements(CgNs + "chapter")
                          .Select(e => new ChapterEntry()
            {
                Name = (string)e.Attribute("name"), Time = TimeSpan.Parse((string)e.Attribute("time"))
            }).ToList();
            return(ci);
        }
예제 #6
0
        public float Similarity(ChapterInfo other)
        {
            float count   = 0F;
            float matches = 0F;

            count++;
            if (Title != null && Title.Equals(other.Title, StringComparison.InvariantCultureIgnoreCase))
            {
                matches++;
            }

            count++;
            if (SourceHash != null && SourceHash.Equals(other.SourceHash))
            {
                matches++;
            }

            count++;
            if (LangCode != null && LangCode.Equals(other.LangCode))
            {
                matches++;
            }

            count++;
            if (Math.Abs(Duration.TotalSeconds - other.Duration.TotalSeconds) < 1)
            {
                matches++;
            }

            count++;
            if (Math.Round(FramesPerSecond * 1000) - Math.Round(other.FramesPerSecond * 1000) == 0)
            {
                matches++;
            }

            for (int i = 0; i < Chapters.Count; i++)
            {
                count = count + 2F;
                if (i < other.Chapters.Count)
                {
                    if (Chapters[i].Name != null && Chapters[i].Name.Equals(other.Chapters[i].Name, StringComparison.InvariantCultureIgnoreCase))
                    {
                        matches++;
                    }
                    if (Math.Abs(Chapters[i].Time.TotalSeconds - other.Chapters[i].Time.TotalSeconds) < 1)
                    {
                        matches++;
                    }
                }
            }
            return(matches / count);
        }
예제 #7
0
        private void OpenDisc(string path)
        {
            Cursor          = Cursors.WaitCursor;
            tsslStatus.Text = "Scanning for chapters...";
            try
            {
                ChapterExtractor ex =
                    Directory.Exists(Path.Combine(path, "VIDEO_TS")) ?
                    new DvdExtractor() as ChapterExtractor :
                    Directory.Exists(Path.Combine(path, "ADV_OBJ")) ?
                    new HddvdExtractor() as ChapterExtractor :
                    Directory.Exists(Path.Combine(Path.Combine(path, "BDMV"), "PLAYLIST")) ?
                    new BlurayExtractor() as ChapterExtractor :
                    null;

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


                using (StreamSelectDialog frm = new StreamSelectDialog(ex))
                {
                    ex.GetStreams(path);
                    if (frm.ShowDialog(this) == DialogResult.OK)
                    {
                        Settings.Default.LastOpenDir = new DirectoryPathAbsolute(path).Path;
                        Settings.Default.Save();
                        pgc = frm.ProgramChain;
                        if (pgc.FramesPerSecond == 0)
                        {
                            pgc.FramesPerSecond = Settings.Default.DefaultFps;
                        }
                        if (pgc.LangCode == null)
                        {
                            pgc.LangCode = Settings.Default.DefaultLangCode;
                        }
                        FreshChapterView();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Trace.WriteLine(ex);
                tsslStatus.Text = "Could not load chapters from disc.";
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
예제 #8
0
 private bool Hidden(ChapterInfo pgc)
 {
     if (checkBoxLessThan20mins.Checked && pgc.Duration < TWENTY)
     {
         return(true);
     }
     if (checkBoxLessThan5.Checked && pgc.Chapters.Count < 5)
     {
         return(true);
     }
     if (checkBoxGreaterThan50.Checked && pgc.Chapters.Count > 50)
     {
         return(true);
     }
     return(false);
 }
예제 #9
0
        public static List <ChapterInfo> ReadPgcListFromFile(string file)
        {
            ChapterExtractor ex        = null;
            string           fileLower = file.ToLower();

            if (fileLower.EndsWith("txt"))
            {
                ex = new TextExtractor();
            }
            else if (fileLower.EndsWith("xpl"))
            {
                ex = new XplExtractor();
            }
            else if (fileLower.EndsWith("ifo"))
            {
                ex = new Ifo2Extractor();
            }
            else if (fileLower.EndsWith("mpls"))
            {
                ex = new MplsExtractor();
            }
            else if (fileLower.EndsWith("xml"))
            {
                throw new Exception("Format not yet supported.");
            }
            else if (fileLower.EndsWith("chapters"))
            {
                List <ChapterInfo> ret = new List <ChapterInfo>();
                ret.Add(ChapterInfo.Load(file));
                return(ret);
            }
            else
            {
                throw new Exception("The selected file is not a recognized format.");
            }

            return(ex.GetStreams(file));
        }
예제 #10
0
        public float Similarity(ChapterInfo other)
        {
            float count = 0F;
            float matches = 0F;

            count++;
            if (Title != null && Title.Equals(other.Title, StringComparison.InvariantCultureIgnoreCase)) matches++;

            count++;
            if (SourceHash != null && SourceHash.Equals(other.SourceHash)) matches++;

            count++;
            if (LangCode != null && LangCode.Equals(other.LangCode)) matches++;

            count++;
            if (Math.Abs(Duration.TotalSeconds - other.Duration.TotalSeconds) < 1) matches++;

            count++;
            if (Math.Round(FramesPerSecond * 1000) - Math.Round(other.FramesPerSecond * 1000) == 0) matches++;

            for (int i = 0; i < Chapters.Count; i++)
            {
                count = count + 2F;
                if (i < other.Chapters.Count)
                {
                    if (Chapters[i].Name != null && Chapters[i].Name.Equals(other.Chapters[i].Name, StringComparison.InvariantCultureIgnoreCase)) matches++;
                    if (Math.Abs(Chapters[i].Time.TotalSeconds - other.Chapters[i].Time.TotalSeconds) < 1) matches++;
                }
            }
            return matches / count;
        }
예제 #11
0
        public static ChapterInfo Load(XElement root)
        {
            ChapterInfo ci = new ChapterInfo();
            ci.LangCode = (string)root.Attribute(XNamespace.Xml + "lang");
            ci.Extractor = (string)root.Attribute("extractor");

            if (root.Element(CgNs + "title") != null)
                ci.Title = (string)root.Element(CgNs + "title");

            XElement @ref = root.Element(CgNs + "ref");
            if (@ref != null)
            {
                ci.ChapterSetId = (int?)@ref.Element(CgNs + "chapterSetId");
                ci.ImdbId = (string)@ref.Element(CgNs + "imdbId");
                ci.MovieDbId = (int?)@ref.Element(CgNs + "movieDbId");
            }

            if (root.Attribute("confirmations") != null)
                ci.Confirmations = (int)root.Attribute("confirmations");

            XElement src = root.Element(CgNs + "source");
            if (src != null)
            {
                ci.SourceName = (string)src.Element(CgNs + "name");
                if (src.Element(CgNs + "type") != null)
                    ci.SourceType = (string)src.Element(CgNs + "type");
                ci.SourceHash = (string)src.Element(CgNs + "hash");
                ci.FramesPerSecond = Convert.ToDouble(src.Element(CgNs + "fps").Value, new System.Globalization.NumberFormatInfo());
                ci.Duration = TimeSpan.Parse(src.Element(CgNs + "duration").Value);
                if (src.Element(CgNs + "volume") != null)
                    ci.VolumeName = (string)src.Element(CgNs + "volume");
            }

            ci.Chapters = root.Element(CgNs + "chapters").Elements(CgNs + "chapter")
              .Select(e => new ChapterEntry() { Name = (string)e.Attribute("name"), Time = TimeSpan.Parse((string)e.Attribute("time")) }).ToList();
            return ci;
        }
예제 #12
0
        private void miOpenDisc_Click(object sender, EventArgs e)
        {
            using (FolderBrowserDialog d = new FolderBrowserDialog())
              {
            d.ShowNewFolderButton = false;
            d.Description = "Select DVD, HD-DVD, BluRay disc, or folder.";
            if (d.ShowDialog() == DialogResult.OK)
            {
              Cursor = Cursors.WaitCursor;
              tsslStatus.Text = "Scanning for chapters...";
              try
              {
            ChapterExtractor ex =
              Directory.Exists(Path.Combine(d.SelectedPath, "VIDEO_TS")) ?
              new DvdExtractor() as ChapterExtractor :
              Directory.Exists(Path.Combine(d.SelectedPath, "ADV_OBJ")) ?
              new HddvdExtractor() as ChapterExtractor :
              Directory.Exists(Path.Combine(Path.Combine(d.SelectedPath, "BDMV"), "PLAYLIST")) ?
              new BlurayExtractor() as ChapterExtractor :
              null;

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

            using (StreamSelectDialog frm = new StreamSelectDialog(ex))
            {
              ex.GetStreams(d.SelectedPath);
              if (frm.ShowDialog(this) == DialogResult.OK)
              {
                pgc = frm.ProgramChain;
                if (pgc.FramesPerSecond == 0) pgc.FramesPerSecond = Settings.Default.DefaultFps;
                if (pgc.LangCode == null) pgc.LangCode = Settings.Default.DefaultLangCode;
                AutoLoadNames();
                FreshChapterView();
              }
            }
              }
              catch (Exception ex)
              {
            MessageBox.Show(ex.Message);
            Trace.WriteLine(ex);
            tsslStatus.Text = "Could not load chapters from disc.";
              }
              finally
              {
            Cursor = Cursors.Default;
              }
            }
              }
        }
예제 #13
0
        private void UpdateDatabase(ChapterInfo pgc)
        {
            picDb.Visible = true;
            dbWait = true;
            //duplicate
            ChapterInfo ci = ChapterInfo.Load(pgc.ToXElement());
            ThreadPool.QueueUserWorkItem((w) =>
            {

                // look for direct hits on the names and auto-load them
                if (Settings.Default.AutoUseDatabase && pgc.SourceHash != null)
                {
                    foreach (ChapterGrabber g in ChapterGrabber.Grabbers)
                        if (g.SupportsUpload) g.Upload(ci);
                }
                dbWait = false;
                Invoke(new Action(() => picDb.Visible = titleWait || dbWait));
            });
        }
예제 #14
0
 public abstract void PopulateNames(string hash, ChapterInfo chapterInfo);
예제 #15
0
 void OnNew()
 {
     txtTitle.Text = String.Empty;
     flowResults.Controls.Clear();
     menuTitles.Items.Clear();
       intIndex = 0;
       pgc = new ChapterInfo()
       {
     Chapters = new List<ChapterEntry>(),
     FramesPerSecond = Settings.Default.DefaultFps,
     LangCode = Settings.Default.DefaultLangCode
       };
       FreshChapterView();
 }
예제 #16
0
        public void OpenFile(string file)
        {
            Cursor = Cursors.WaitCursor;
              tsslStatus.Text = "Parsing chapters from file...";
              try
              {
            List<ChapterInfo> temp = ReadPgcListFromFile(file);
            pgc = temp[0];
            if (pgc.FramesPerSecond == 0) pgc.FramesPerSecond = Settings.Default.DefaultFps;
            if (pgc.LangCode == null) pgc.LangCode = Settings.Default.DefaultLangCode;
            AutoLoadNames();

            FreshChapterView();

            AddToRecent(file);
              }
              catch (Exception ex)
              {
            MessageBox.Show(ex.Message);
            Trace.WriteLine(ex);
            tsslStatus.Text = "Failed to load chapters from file.";
              }
              finally
              {
            Cursor = Cursors.Default;
              }
        }
예제 #17
0
        public static ChapterInfo Load(string filename)
        {
            XDocument doc = XDocument.Load(filename);

            return(ChapterInfo.Load(doc.Root));
        }
예제 #18
0
        public static ChapterInfo Load(XmlReader r)
        {
            XDocument doc = XDocument.Load(r);

            return(ChapterInfo.Load(doc.Root));
        }
예제 #19
0
 public abstract void Upload(ChapterInfo chapterInfo);
예제 #20
0
 public abstract List<SearchResult> Search(ChapterInfo chapterInfo);
예제 #21
0
 protected void OnChaptersLoaded(ChapterInfo pgc)
 {
     if (ChaptersLoaded != null) ChaptersLoaded(this, new ProgramChainArg() { ProgramChain = pgc });
 }
예제 #22
0
        private void OpenDisc(string path)
        {
            Cursor = Cursors.WaitCursor;
            tsslStatus.Text = "Scanning for chapters...";
            try
            {
            ChapterExtractor ex =
              Directory.Exists(Path.Combine(path, "VIDEO_TS")) ?
              new DvdExtractor() as ChapterExtractor :
              Directory.Exists(Path.Combine(path, "ADV_OBJ")) ?
              new HddvdExtractor() as ChapterExtractor :
              Directory.Exists(Path.Combine(Path.Combine(path, "BDMV"), "PLAYLIST")) ?
              new BlurayExtractor() as ChapterExtractor :
              null;

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

            using (StreamSelectDialog frm = new StreamSelectDialog(ex))
            {
                ex.GetStreams(path);
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    Settings.Default.LastOpenDir = new DirectoryPathAbsolute(path).Path;
                    Settings.Default.Save();
                    pgc = frm.ProgramChain;
                    if (pgc.FramesPerSecond == 0) pgc.FramesPerSecond = Settings.Default.DefaultFps;
                    if (pgc.LangCode == null) pgc.LangCode = Settings.Default.DefaultLangCode;
                    AutoLoadNames();
                    FreshChapterView();
                }
            }
            }
            catch (Exception ex)
            {
            MessageBox.Show(ex.Message);
            Trace.WriteLine(ex);
            tsslStatus.Text = "Could not load chapters from disc.";
            }
            finally
            {
            Cursor = Cursors.Default;
            }
        }
예제 #23
0
 protected void OnStreamDetected(ChapterInfo pgc)
 {
     if (StreamDetected != null) StreamDetected(this, new ProgramChainArg() { ProgramChain = pgc });
 }
예제 #24
0
 public abstract void PopulateNames(SearchResult result, ChapterInfo chapterInfo, bool includeDurations);