Beispiel #1
0
 private static void DoRename(MatchFoundEventArgs args, MovideoSettings settings)
 {
     if (settings.Reorganize)
     {
         var            sourcePath = args.LocalFile.Path;
         IFolderCleaner cleaner    = settings.DeleteEmptyFolders ? new FolderCleaner() : null;
         var            organizer  = new FileOrganizer(settings.TargetPath, settings.RenameTemplate, cleaner);
         organizer.Organize(sourcePath, args.Movie);
     }
 }
Beispiel #2
0
        public int Scan(MovideoSettings settings)
        {
            var count = 0;
            var index = 0;

            var files      = _fileScanner.Scan().ToArray();
            var totalItems = files.Length;


            foreach (var file in files)
            {
                index++;
                OnProgressChanged(index, totalItems);

                var item = _analyzer.Analyze(file);
                if (!item.IsKnown)
                {
                    float accuracy;
                    var   res = TryIdentify(item, out accuracy);
                    if (res != null)
                    {
                        var args = new MatchFoundEventArgs(item, res, accuracy);
                        OnMatchFound(args);

                        if (args.Cancel)
                        {
                            break;
                        }

                        if (args.IsMatch == true)
                        {
                            DoRename(args, settings);

                            UpdateItem(item, res);
                            count++;
                        }
                    }
                }
                else
                {
                    float accuracy;
                    var   movieId = _db.GetMovieIdFor(item);
                    var   movie   = _db.GetMovie(movieId.Value);
                    item.Title = movie.Title;
                    item.Year  = movie.Year;

                    var res  = TryIdentify(item, out accuracy);
                    var args = new MatchFoundEventArgs(item, res, 1);
                    DoRename(args, settings);
                }
            }

            return(count);
        }
Beispiel #3
0
        public Task <int> ScanAsync(MovideoSettings settings)
        {
            var tf = new TaskFactory <int>();

            return(tf.StartNew(() => Scan(settings)));
        }