Exemplo n.º 1
0
        /// <summary>
        /// Clean the specified (current) artist's album.
        /// </summary>
        /// <param name="album"></param>
        /// <param name="artist"></param>
        /// <remarks>
        /// This is invoked automatically whenever a new track is played, as prescribed by
        /// the isCleansed verification.
        /// </remarks>

        public void Clean(string album, string artist)
        {
            if (catalog == null)
            {
                // catalog is null until InitializingScanner is complete
                return;
            }

            bool allowArtworkScanner   = IsScannerAllowed(Resx.I_ScanArtwork);
            bool allowDuplicateScanner = IsScannerAllowed(Resx.I_ScanDuplicates);
            bool allowPhantomScanner   = IsScannerAllowed(Resx.I_ScanPhantoms);

            if (allowArtworkScanner || allowDuplicateScanner || allowPhantomScanner)
            {
                string key = album + "~" + artist;

                string logtext = String.Format("Auto-cleaning album '{0}'", key);
                Logger.WriteAppLog(LogCategory, logtext);
                Logger.WriteLine(LogCategory, logtext);

                cleansed.Add(key);

                if (allowDuplicateScanner)
                {
                    DuplicateScanner dscanner = new DuplicateScanner(controller, catalog);
                    dscanner.AlbumFilter  = album;
                    dscanner.ArtistFilter = artist;
                    AddScanner(dscanner, DuplicateScannerPriority);
                }

                if (allowPhantomScanner)
                {
                    PhantomScanner pscanner = new PhantomScanner(controller, catalog);
                    pscanner.AlbumFilter  = album;
                    pscanner.ArtistFilter = artist;
                    AddScanner(pscanner, PhantomScannerPriority);
                }

                if (allowArtworkScanner && NetworkStatus.IsAvailable)
                {
                    ArtworkScanner ascanner = new ArtworkScanner(controller, catalog);
                    ascanner.AlbumFilter  = album;
                    ascanner.ArtistFilter = artist;
                    AddScanner(ascanner, ArtworkScannerPriority);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Clean either the current album if in the Music library or the current user-defined
        /// playlist by scanning for duplicates and removing phantom tracks within that context.
        /// </summary>
        /// <remarks>
        /// This is invoked manually by the user from the Clean context menu.
        /// </remarks>

        public void CleanContext(bool isAlbumContext)
        {
            if (catalog == null)
            {
                // catalog is null until InitializingScanner is complete
                return;
            }

            if (isAlbumContext)
            {
                // DO NOT dispose current or we'll destroy the original CurrentTrack RCW
                Track  current = controller.CurrentTrack;
                string album   = current.Album;
                string artist  = current.Artist;

                string key     = album + "~" + artist;
                string logtext = String.Format("cleaning album '{0}'", key);
                Logger.WriteAppLog(LogCategory, logtext);
                Logger.WriteLine(LogCategory, logtext);

                cleansed.Add(key);

                var dscanner = new DuplicateScanner(controller, catalog);
                dscanner.AlbumFilter  = album;
                dscanner.ArtistFilter = artist;
                AddScanner(dscanner, DuplicateScannerPriority);

                var pscanner = new PhantomScanner(controller, catalog);
                pscanner.AlbumFilter  = album;
                pscanner.ArtistFilter = artist;
                AddScanner(pscanner, PhantomScannerPriority);

                if (NetworkStatus.IsAvailable)
                {
                    var ascanner = new ArtworkScanner(controller, catalog);
                    ascanner.AlbumFilter  = album;
                    ascanner.ArtistFilter = artist;
                    AddScanner(ascanner, ArtworkScannerPriority);
                }
            }
            else             // (isPlaylistContext)
            {
                // DO NOT dispose current or we'll destory the original CurrentPlaylist RCW
                Playlist current = controller.CurrentPlaylist;

                string logtext = String.Format("cleaning playlist '{0}'", current.Name);
                Logger.WriteAppLog(LogCategory, logtext);
                Logger.WriteLine(LogCategory, logtext);

                var dscanner = new DuplicateScanner(controller, catalog);
                dscanner.PlaylistFilter = current.PersistentID;
                AddScanner(dscanner, DuplicateScannerPriority);

                var pscanner = new PhantomScanner(controller, catalog);
                pscanner.PlaylistFilter = current.PersistentID;
                AddScanner(pscanner, PhantomScannerPriority);

                if (NetworkStatus.IsAvailable)
                {
                    var ascanner = new ArtworkScanner(controller, catalog);
                    ascanner.PlaylistFilter = current.PersistentID;
                    AddScanner(ascanner, ArtworkScannerPriority);
                }
            }
        }