예제 #1
0
    public void SeriesMatchesAreCorrect()
    {
      List<string> shouldMatchPaths = new List<string>
                          {
                            @"\\SAGESERVER\TV Series\Almost Human\Almost.Human.S01E01.720p.HDTV.X264-DIMENSION.mkv",
                            @"F:\TVSeries\The Bill Engvall Show\Season 1\The Bill Engvall Show - 101 - Good People.avi" ,
                            @"G:\Serien\The Big Bang Theory\Staffel 1 [DEU-ENG][720p]\S01E01 Penny und die Physiker.mkv" ,
                            @"G:\Serien\The Big Bang Theory\Staffel 1 [DEU-ENG][720p]\1x01 Penny und die Physiker.mkv" ,
                            @"D:\Capture\EUReKA - Die geheime Stadt\EUReKA - Die geheime Stadt - (Lyncht Fargo) S4 E3 - 2011-05-02 - 21_15.ts",
                            @"M:\Serien\Stargate Universe Season 1\Stargate Universe S01.E01_02 - Die Destiny.avi",
                            @"M:\Serien\Caprica\Caprica 1x01 - Pilot (1).mkv",
                            @"M:\\Serien\\Fringe Season 3\\Fringe S03E04 - Träumen Gestaltwandler von elektrischen Schafen.avi",
                            @"\The.Vampire.Diaries.S03-E13.720p.WEB-DL.mkv",
                            @"\Nikita.S02_E02.720p.WEB-DL.mkv",
                            @"\Switched.at.Birth.S01E10.The Homecoming.720p.WEB-DL.DD5.1.H.264-NT.mkv",
                            @"\The.Lying.Game.111.WEB.DL.mkv",
                            @"\Unforgettable.S01E02.720p.WEB-DL.mkv",
                            @"\Grimm.S01E06.720p.HDTV.X264-DIMENSION.mkv",
                            @"\The.Secret.Circle.S01E01.720p.WEB-DL.mkv",
                            @"\Lost.Girl.S02E06.720p.WEB-DL.mkv",
                            @"\Fringe.S04E08.720p.WEB-DL.mkv",
                            @"\the_fades.1x01.720p_hdtv_x264-fov.mkv",
                            @"\Once.Upon.A.Time.S01E13.720p.WEB-DL.mkv",
                            @"\The.Lying.Game.114.WEB.DL.mkv",
                            @"X:\USB_Backup\Filme\CodecTest\Dr. House - S01E01 Irgendwas.mkv",
                            @"Z:\Serien\Hawaii Five-O\Staffel 02\11 - In Der Falle.mkv",
                            @"Z:\Serien\Hawaii Five-O\Season 02\11 - In Der Falle.mkv",
                            @"Z:\Serien\Hawaii Five-O\02. Staffel\12 - In Der Falle.mkv",
                            @"Z:\Serien\Hawaii Five-O\Temporada 02\11 - In Der Falle.mkv",
                            @"Z:\Serien\Hawaii Five-O\02\11 - In Der Falle.mkv",
                            //@"Z:\Serien\Hawaii Five-O\2\11 In Der Falle.mkv",
                            @"Z:\Serien\The Mentalist\4\11 - Die Geister, Die Wir Riefen.mkv",
                            //@"Z:\Serien\The Mentalist\4\11 Die Geister, Die Wir Riefen.mkv",
                            @"\\BNAS\TV\All\Comedy\Farther Ted\Series 1\01 - Good Luke Father Ted.mkv",
                            @"\\BNAS\TV\All\Comedy\Black Adder\Black Adder 1\01 - The Foretelling.avi",
                          };

      SeriesMatcher matcher = new SeriesMatcher();
      foreach (string folderOrFileName in shouldMatchPaths)
      {
        SeriesInfo seriesInfo;
        IResourceAccessor ra;
        bool match = matcher.MatchSeries(folderOrFileName, out seriesInfo);
        Assert.IsTrue(match, string.Format("Failed to match path '{0}'", folderOrFileName));
      }
    }
    protected bool ExtractSeriesData(string localFsResourcePath, IDictionary<Guid, MediaItemAspect> extractedAspectData)
    {
      SeriesInfo seriesInfo = null;

      string extensionUpper = StringUtils.TrimToEmpty(Path.GetExtension(localFsResourcePath)).ToUpper();

      // Try to get extended information out of matroska files)
      if (extensionUpper == ".MKV" || extensionUpper == ".MK3D")
      {
        MatroskaInfoReader mkvReader = new MatroskaInfoReader(localFsResourcePath);
        // Add keys to be extracted to tags dictionary, matching results will returned as value
        Dictionary<string, IList<string>> tagsToExtract = MatroskaConsts.DefaultTags;
        mkvReader.ReadTags(tagsToExtract);

        string title = string.Empty;
        IList<string> tags = tagsToExtract[MatroskaConsts.TAG_SIMPLE_TITLE];
        if (tags != null)
          title = tags.FirstOrDefault();

        if (!string.IsNullOrEmpty(title))
          MediaItemAspect.SetAttribute(extractedAspectData, MediaAspect.ATTR_TITLE, title);

        string yearCandidate = null;
        tags = tagsToExtract[MatroskaConsts.TAG_EPISODE_YEAR] ?? tagsToExtract[MatroskaConsts.TAG_SEASON_YEAR];
        if (tags != null)
          yearCandidate = (tags.FirstOrDefault() ?? string.Empty).Substring(0, 4);

        int year;
        if (int.TryParse(yearCandidate, out year))
          MediaItemAspect.SetAttribute(extractedAspectData, MediaAspect.ATTR_RECORDINGTIME, new DateTime(year, 1, 1));

        tags = tagsToExtract[MatroskaConsts.TAG_EPISODE_SUMMARY];
        string plot = tags != null ? tags.FirstOrDefault() : string.Empty;
        if (!string.IsNullOrEmpty(plot))
          MediaItemAspect.SetAttribute(extractedAspectData, VideoAspect.ATTR_STORYPLOT, plot);

        // Series and episode handling. Prefer information from tags.
        seriesInfo = GetSeriesFromTags(tagsToExtract);
      }

      // If now information from mkv were found, try name matching
      if (seriesInfo == null || !seriesInfo.IsCompleteMatch)
      {
        // Try to match series from folder and file namings
        SeriesMatcher seriesMatcher = new SeriesMatcher();
        seriesMatcher.MatchSeries(localFsResourcePath, out seriesInfo);
      }

      // Lookup online information (incl. fanart)
      if (seriesInfo != null && seriesInfo.IsCompleteMatch)
      {
        SeriesTvDbMatcher.Instance.FindAndUpdateSeries(seriesInfo);
        seriesInfo.SetMetadata(extractedAspectData);
      }
      return (seriesInfo != null && seriesInfo.IsCompleteMatch);
    }
예제 #3
0
 public void SeriesFalseMatches()
 {
   List<string> shouldNotMatchPaths = new List<string>
                       {
                         @"\\Fool's Gold (2008).mkv",
                         @"Into the Blue (2005)",
                         @"\\Iron Man 2 Disc 1.mkv",
                         @"\\Salt - Blu-ray™.mkv",
                         @"\\Transformers Revenge of the Fallen Disc 1.mkv",
                         // FIXME: this one is currently wrongly matched
                         // @"Polizeiruf 110\Polizeiruf 110 - SE - Liebeswahn (Das Erste HD - 2014-01-12 20_15).ts",
                       };
   SeriesMatcher matcher = new SeriesMatcher();
   foreach (string folderOrFileName in shouldNotMatchPaths)
   {
     SeriesInfo seriesInfo;
     bool match = matcher.MatchSeries(folderOrFileName, out seriesInfo);
     Assert.IsFalse(match, string.Format("Wrong match for '{0}' should not be matched!", folderOrFileName));
   }
 }
    protected bool ExtractSeriesData(string localFsResourcePath, IDictionary<Guid, MediaItemAspect> extractedAspectData)
    {
      // If resource is not a video file, the MediaAspect's title is not available
      string title;
      if (!MediaItemAspect.TryGetAttribute(extractedAspectData, MediaAspect.ATTR_TITLE, out title) || string.IsNullOrEmpty(title))
        return false;

      SeriesInfo seriesInfo;

      // Try to get extended information out of matroska files)
      MatroskaMatcher matroskaMatcher = new MatroskaMatcher();
      matroskaMatcher.MatchSeries(localFsResourcePath, out seriesInfo, ref extractedAspectData);

      // If no information from mkv were found, try name matching
      if (seriesInfo == null || !seriesInfo.IsCompleteMatch)
      {
        // Try to match series from folder and file namings
        SeriesMatcher seriesMatcher = new SeriesMatcher();
        seriesMatcher.MatchSeries(localFsResourcePath, out seriesInfo);
      }

      // Lookup online information (incl. fanart)
      if (seriesInfo != null && seriesInfo.IsCompleteMatch)
      {
        SeriesTvDbMatcher.Instance.FindAndUpdateSeries(seriesInfo);
        seriesInfo.SetMetadata(extractedAspectData);
      }
      return (seriesInfo != null && seriesInfo.IsCompleteMatch);
    }
    protected bool ExtractSeriesData(string localFsResourcePath, IDictionary<Guid, MediaItemAspect> extractedAspectData)
    {
      // VideoAspect must be present to be sure it is actually a video resource.
      if (!extractedAspectData.ContainsKey(VideoAspect.ASPECT_ID))
        return false;

      SeriesInfo seriesInfo;

      // Try to get extended information out of matroska files)
      MatroskaMatcher matroskaMatcher = new MatroskaMatcher();
      matroskaMatcher.MatchSeries(localFsResourcePath, out seriesInfo, ref extractedAspectData);

      // If no information from mkv were found, try name matching
      if (seriesInfo == null || !seriesInfo.IsCompleteMatch)
      {
        // Try to match series from folder and file namings
        SeriesMatcher seriesMatcher = new SeriesMatcher();
        seriesMatcher.MatchSeries(localFsResourcePath, out seriesInfo);
      }

      // Lookup online information (incl. fanart)
      if (seriesInfo != null && seriesInfo.IsCompleteMatch)
      {
        SeriesTvDbMatcher.Instance.FindAndUpdateSeries(seriesInfo);
        seriesInfo.SetMetadata(extractedAspectData);
      }
      return (seriesInfo != null && seriesInfo.IsCompleteMatch);
    }
    protected bool ExtractSeriesData(ILocalFsResourceAccessor lfsra, IDictionary<Guid, MediaItemAspect> extractedAspectData)
    {
      // VideoAspect must be present to be sure it is actually a video resource.
      if (!extractedAspectData.ContainsKey(VideoAspect.ASPECT_ID))
        return false;

      SeriesInfo seriesInfo;

      // Try to get extended information out of matroska files)
      MatroskaMatcher matroskaMatcher = new MatroskaMatcher();
      if (matroskaMatcher.MatchSeries(lfsra, out seriesInfo, ref extractedAspectData))
      {
        ServiceRegistration.Get<ILogger>().Debug("ExtractSeriesData: Found SeriesInformation by MatroskaMatcher for {0}, IMDB {1}, TVDB {2}, IsCompleteMatch {3}",
          seriesInfo.Series, seriesInfo.ImdbId, seriesInfo.TvdbId, seriesInfo.IsCompleteMatch);
      }

      // If no information from mkv were found, try name matching
      if (seriesInfo == null || !seriesInfo.IsCompleteMatch)
      {
        // Try to match series from folder and file namings
        SeriesMatcher seriesMatcher = new SeriesMatcher();
        seriesMatcher.MatchSeries(lfsra, out seriesInfo);
      }

      // Lookup online information (incl. fanart)
      if (seriesInfo != null && seriesInfo.IsCompleteMatch)
      {
        SeriesTvDbMatcher.Instance.FindAndUpdateSeries(seriesInfo);
        seriesInfo.SetMetadata(extractedAspectData);
      }
      return (seriesInfo != null && seriesInfo.IsCompleteMatch);
    }
    protected bool ExtractSeriesData(ILocalFsResourceAccessor lfsra, IDictionary<Guid, MediaItemAspect> extractedAspectData)
    {
      // VideoAspect must be present to be sure it is actually a video resource.
      if (!extractedAspectData.ContainsKey(VideoAspect.ASPECT_ID))
        return false;

      SeriesInfo seriesInfo = null;

      // First check if we already have a complete match from a previous MDE
      string title;
      int tvDbId;
      int seasonNumber;
      IEnumerable<int> episodeNumbers;
      if (MediaItemAspect.TryGetAttribute(extractedAspectData, MediaAspect.ATTR_TITLE, out title) &&
          MediaItemAspect.TryGetAttribute(extractedAspectData, SeriesAspect.ATTR_TVDB_ID, out tvDbId) &&
          MediaItemAspect.TryGetAttribute(extractedAspectData, SeriesAspect.ATTR_SEASON, out seasonNumber) &&
          (episodeNumbers = extractedAspectData[SeriesAspect.ASPECT_ID].GetCollectionAttribute<int>(SeriesAspect.ATTR_EPISODE)) != null)
      {
        seriesInfo = new SeriesInfo
        {
          Series = title,
          TvdbId = tvDbId,
          SeasonNumber = seasonNumber,
        };
        episodeNumbers.ToList().ForEach(n => seriesInfo.EpisodeNumbers.Add(n));
      }

      // If there was no complete match, yet, try to get extended information out of matroska files)
      if (seriesInfo == null || !seriesInfo.IsCompleteMatch)
      {
        MatroskaMatcher matroskaMatcher = new MatroskaMatcher();
        if (matroskaMatcher.MatchSeries(lfsra, out seriesInfo, ref extractedAspectData))
        {
          ServiceRegistration.Get<ILogger>().Debug("ExtractSeriesData: Found SeriesInformation by MatroskaMatcher for {0}, IMDB {1}, TVDB {2}, IsCompleteMatch {3}",
            seriesInfo.Series, seriesInfo.ImdbId, seriesInfo.TvdbId, seriesInfo.IsCompleteMatch);
        }
      }

      // If no information was found before, try name matching
      if (seriesInfo == null || !seriesInfo.IsCompleteMatch)
      {
        // Try to match series from folder and file namings
        SeriesMatcher seriesMatcher = new SeriesMatcher();
        seriesMatcher.MatchSeries(lfsra, out seriesInfo);
      }

      // Lookup online information (incl. fanart)
      if (seriesInfo != null && seriesInfo.IsCompleteMatch)
      {
        SeriesTvDbMatcher.Instance.FindAndUpdateSeries(seriesInfo);
        if (!_onlyFanArt)
          seriesInfo.SetMetadata(extractedAspectData);
      }
      return (seriesInfo != null && seriesInfo.IsCompleteMatch && !_onlyFanArt);
    }