Пример #1
0
        public AnalyzedItem Analyze(FileInfo file)
        {
            Log.DebugFormat("Analyzing: {0}", file.Name);

            var item = new AnalyzedItem(file);

            var fname   = item.Path.FullName;
            var cleaned = MovieTitleCleaner.Clean(fname);

            item.Title    = cleaned.Title;
            item.SubTitle = cleaned.SubTitle;
            item.Year     = cleaned.Year;

            var mf       = new MediaInfoDotNet.MediaFile(file.FullName);
            var duration = TimeSpan.FromMilliseconds(mf.General.Duration);

            item.Duration = duration;

            var fref = new FileRef(file);

            if (_db.HasHash(fref))
            {
                var hash = _db.GetHashFor(fref);
                Log.DebugFormat("Hash Found: {0}", hash);

                item.Hash = hash;
            }
            else
            {
                var hash = QuickHash(file);
                Log.DebugFormat("Hash Computed: {0}", hash);

                _db.Push(fref, hash);
                item.Hash = hash;
            }

            if (_db.HasMatch(item))
            {
                item.IsKnown = true;
                item.MovieId = _db.GetMovieIdFor(item);

                Log.DebugFormat("Match Found: {0} (MovieId)", item.MovieId);
            }

            return(item);
        }
Пример #2
0
 public bool Equals(FileRef other)
 {
     return(string.Equals(Path, other.Path) && LastModifiedUtc.Equals(other.LastModifiedUtc) &&
            Bytes == other.Bytes);
 }