private string MovieTitle(string title)
        {
            var theTitle = string.Empty;
              try
              {
              Logger.Debug("Extracting Movie title from " + title);
              var mi = new MediaInfo(title);
              mi.Analyse();
              Logger.Debug("   Movie title is " + mi.Title);
              theTitle = mi.Title;
              }
              catch (PathTooLongException ex)
              {
              Logger.Error(string.Format("{0}:- Title has {1} characters", ex.Message, title.Length
                  ));
              theTitle = title.Substring(0, 100);
              }
              catch (System.Exception)
              {

              throw;
              }

              return theTitle;
        }
 public void TestAddingToCollection()
 {
     var mi = new MediaInfo(@".\TestFolder\Judge.Judy.S14E157.2010.02.25.mp5");
      mi.Analyse();
      var sut = new Collector();
      var result = sut.AddToTvCollection(mi);
      Assert.IsTrue(result.Equals(sut.LatestAddition));
 }
 public void TestCollectorHasIt()
 {
     var mi = new MediaInfo(@".\TestFolder\Judge.Judy.S14E157.2010.02.25.mp4");
      mi.Analyse();
      var sut = new Collector();
      var hasIt = sut.HaveIt(mi);
      Assert.IsTrue(hasIt);
 }
        public void TestMacWorldtIsMag()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "Macworld USA - February 2015.pdf", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.MagazineFolder = ".\\Output\\Magazines\\";
            mi.Analyse();
            Assert.IsTrue(mi.IsMagazine);
             }
        }
        public void TestIsNotaMag()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "Apress - Beginning ASP.NET 4.pdf", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.MagazineFolder = ".\\Output\\Magazines\\";
            mi.Analyse();
            Assert.IsFalse(mi.IsMagazine);
            Assert.IsTrue(mi.IsBook);
             }
        }
        public void TestAllNumbers()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "Computeractive UK Issue 438 - December 10, 2014.pdf", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            Assert.IsTrue(mi.ContainsAllNumbers("438"));
            Assert.IsTrue(mi.ContainsAllNumbers("408"));
            Assert.IsFalse(mi.ContainsAllNumbers("mp4"));
            Assert.IsFalse(mi.ContainsAllNumbers("m4o"));
            Assert.IsFalse(mi.ContainsAllNumbers("4pm"));
            Assert.IsFalse(mi.ContainsAllNumbers("4p4"));
             }
        }
        public void TestMediaInfoTvWord()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "married_with_children.1x01.pilot.dvdrip_xvid-fov.avi", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            var tvWord = mi.IsTvWord("1x01");
            Assert.IsTrue(tvWord);
             }
        }
        public void TestMediaInfoTvSample()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "Sliders.S02E04.Sample.avi", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            //  Numbers are stripped out of titles
            Assert.IsFalse(mi.IsTV);
            Assert.IsFalse(mi.IsMovie);
             }
        }
        public void TestMediaInfoTitleWithYear()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "Castle.2009.S07E10.HDTV.x264-LOL.[VTV].mp4", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            var title = mi.DetermineTitle();
            //  Numbers are stripped out of titles
            Assert.IsTrue(title.Equals("Castle [2009]"));
             }
        }
        public void TestMediaInfoJudgeJudySeason20()
        {
            var testCandidates = Directory.GetFiles( ".//Output//DL//", "Judge Judy 2016 07 06 S20E220.mkv", SearchOption.AllDirectories ).ToList();

             foreach ( var item in testCandidates )
             {
            var mi = new MediaInfo( item );
            mi.Analyse();
            //  in progress files are ignored
            Assert.IsTrue( mi.Title.Equals( "Judge Judy" ), "Title is not Judge Judy" );
            Assert.IsTrue( mi.Season.Equals( 20 ), "Season is not 20" );
            Assert.IsTrue( mi.IsTV, "Not TV" );
            Assert.IsFalse( mi.IsMovie, "Is movie" );
             }
        }
        public void TestTvWord()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "ncis.1217.hdtv-lol.mp4", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            var isTV = mi.IsTvWord("1217");
            //  in progress files are ignored
            Assert.IsTrue( isTV);
             }
        }
        public void TestTvHousewives()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "The_Real_Housewives_of_Atlanta_S07E19[480i_HDTV_H.264_mp4].mp4", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            Assert.IsTrue(mi.IsTV);
            Assert.IsFalse(mi.IsMovie);
            Assert.IsTrue(mi.Season.Equals(7));
            Assert.IsTrue(mi.Episode.Equals(19));
             }
        }
        public void TestTvFlash()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "the.flash.2014.116.hdtv-lol.mp4 ", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            Assert.IsTrue(mi.IsTV);
            Assert.IsFalse(mi.IsMovie);
             }
        }
        public void TestMediaInfoNFLAnalysis()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "NFL WK 15 12-14-2014 49ers at Seahawks (Condensed) (1280x720) [Phr0stY].mkv", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            Assert.IsTrue(mi.IsNfl);
            Assert.IsFalse(mi.IsBook);
            Assert.IsFalse(mi.IsTV);
            Assert.IsFalse(mi.IsMovie);
             }
        }
        public void TestMediaInfoNCIS()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "ncis.1217.hdtv-lol.mp4", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            //  in progress files are ignored
            Assert.IsTrue(mi.IsTV);
            Assert.IsFalse(mi.IsMovie);
             }
        }
        public void TestMediaInfoMovie()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "American.Sniper.2014.720p.BRRip.XviD.AC3.SANTi.avi", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            //  Numbers are stripped out of titles
            Assert.IsFalse(mi.IsTV);
            Assert.IsTrue(mi.IsMovie);
            Assert.IsTrue(mi.Title.Equals("American Sniper [2014]"));
             }
        }
        public void TestMediaInfoMagList()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "PC Format 2014-12.pdf", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.MagazineFolder = ".\\Output\\Magazines\\";
            mi.GetMagList();
            mi.Analyse();
            Assert.IsTrue(mi.Magazines.Count > 0);
            Assert.IsTrue(mi.IsMagazine);
             }
        }
        public void TestMediaInfoMagazineAnalysis()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "PC Format 2014-12.pdf", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item) { MagazineFolder = ".//Output//Magazines//" };
            mi.Analyse();
            Assert.IsFalse(mi.IsNfl);
            Assert.IsFalse(mi.IsBook);
            Assert.IsFalse(mi.IsTV);
            Assert.IsFalse(mi.IsMovie);
            Assert.IsTrue(mi.IsMagazine);
             }
        }
        public void TestMediaInfoTvWordType3()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "married_with_children.1x02.pilot.dvdrip_xvid-fov.avi", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            //  Numbers are stripped out of titles
            Assert.IsTrue(mi.Title.Equals("married with children"));
            Assert.IsTrue(mi.IsTV);
            Assert.IsTrue(mi.Season == 1);
            Assert.IsTrue(mi.Episode == 2);
             }
        }
        public void TestMediaInfoPdf()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "Computeractive UK Issue 438 - December 10, 2014.pdf", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.MagazineFolder = ".//Output//Magazines//";
            mi.Analyse();
            //  Numbers are stripped out of titles
            Assert.IsTrue(mi.Title.Equals("Computeractive UK Issue"));
            Assert.IsFalse(mi.IsTV);
            Assert.IsTrue(mi.IsMagazine);
             }
        }
        public void TestTvCriminalMinds()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "criminal minds 1017 hdtv lol.mp4", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            Assert.IsTrue(mi.IsTV);
            Assert.IsFalse(mi.IsMovie);
            Assert.IsTrue(mi.Season.Equals(10));
            Assert.IsTrue(mi.Episode.Equals(17));
             }
        }
        public void TestMediaInfoShieldTitle()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "Marvels.Agents.of.S.H.I.E.L.D.S02E10.HDTV.x264-KILLERS.mp4", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            var title = mi.DetermineTitle();
            //  full stops are stripped out of titles
            Assert.IsTrue(title.Equals("Marvels Agents of S H I E L D"));
             }
        }
        public void TestTvHauntingAustralia()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "Haunting-Australia.S01E01.Woodford.Academy.HDTV.x264-SPASM.mp4", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            Assert.IsTrue(mi.IsTV);
            Assert.IsFalse(mi.IsMovie);
            Assert.IsTrue(mi.Episode.Equals(1));
             }
        }
        private string TvTitle(string title)
        {
            Logger.Trace("Extracting TV title from " + title);
             var mi = new MediaInfo(title);
             mi.Analyse();
             Logger.Debug("TV title is " + mi.TvTitle);

             return mi.TvTitle;
        }
        public void TestMediaInfoGoodnightSweetheart()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "Goodnight Sweetheart  - S01 - E01 - Rites of Passage.avi", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            Assert.IsTrue(mi.Season.Equals(0));  //  basically we dont want an exception
             }
        }
        public void TestMediaInfoBogusMagFolder()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "PC Format 2014-12.pdf", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item) { MagazineFolder = ".//Output//Bogus//" };
            mi.GetMagList();
            Assert.IsNull(mi.Magazines);
             }
        }
        public void TestMediaInfo()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "Mean Machine.mp4", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            Assert.IsTrue(mi.IsMovie);
             }
        }
        public void TestMediaInfoJudgeJudy()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "judge.judy.2015.04.28b.mackey.vs.peak.hdtv.x264-daview.mp4", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            //  in progress files are ignored
            Assert.IsTrue(mi.Title.Equals("Judge Judy"));
            Assert.IsTrue(mi.Season.Equals( 20 ));
            Assert.IsTrue(mi.IsTV);
            Assert.IsFalse(mi.IsMovie);
             }
        }
        public void TestMediaInfoSliders()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "Sliders.1x01_1x02.Pilot.AC3.DVDRip_XviD-FoV.avi",
            SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            Assert.IsTrue(mi.Episode.Equals(1));
             }
        }
        public void TestMediaInfoAlternatTvWord()
        {
            var testCandidates = Directory.GetFiles(".//Output//DL//", "arrow.309.hdtv-lol.mp4", SearchOption.AllDirectories).ToList();

             foreach (var item in testCandidates)
             {
            var mi = new MediaInfo(item);
            mi.Analyse();
            //  Numbers are stripped out of titles
            Assert.IsTrue(mi.Title.Equals("arrow"));
            Assert.IsTrue(mi.IsTV);
            Assert.IsTrue(mi.Season == 3);
            Assert.IsTrue(mi.Episode == 9);
             }
        }