public QuickSaveDialog(ChapterInfo pgc)
        {
            InitializeComponent();

              this.pgc = pgc;
              QuickSave(Settings.Default.LastOpenDir);
        }
 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;
 }
 protected void OnStreamDetected(ChapterInfo pgc)
 {
     if (StreamDetected != null)
     {
         StreamDetected(this, new ProgramChainArg()
         {
             ProgramChain = pgc
         });
     }
 }
Exemple #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();
 }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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;
            }
        }
Exemple #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);
 }
Exemple #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));
        }
        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;
        }
        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;
        }
        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;
              }
            }
              }
        }
Exemple #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));
            });
        }
 public abstract void PopulateNames(string hash, ChapterInfo chapterInfo);
Exemple #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();
 }
Exemple #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;
              }
        }
Exemple #17
0
        public static ChapterInfo Load(string filename)
        {
            XDocument doc = XDocument.Load(filename);

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

            return(ChapterInfo.Load(doc.Root));
        }
 public abstract void Upload(ChapterInfo chapterInfo);
 public abstract List<SearchResult> Search(ChapterInfo chapterInfo);
 protected void OnChaptersLoaded(ChapterInfo pgc)
 {
     if (ChaptersLoaded != null) ChaptersLoaded(this, new ProgramChainArg() { ProgramChain = pgc });
 }
Exemple #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;
            }
        }
 protected void OnStreamDetected(ChapterInfo pgc)
 {
     if (StreamDetected != null) StreamDetected(this, new ProgramChainArg() { ProgramChain = pgc });
 }
 public abstract void PopulateNames(SearchResult result, ChapterInfo chapterInfo, bool includeDurations);