Beispiel #1
0
        /// <summary>
        /// Gets a special collection of playlists suitable for synchronization.
        /// </summary>
        /// <returns></returns>
        public PlaylistCollection GetPreferredPlaylists()
        {
            PlaylistCollection playlists = new PlaylistCollection();

            Invoke((Action)delegate
            {
                // CurrentPlaylist would be null if viewing the iTunes Store
                int currentID = CurrentPlaylist == null ? 0 : CurrentPlaylist.PlaylistID;

                foreach (IITPlaylist ilist in itunes.LibrarySource.Playlists)
                {
                    if (ilist != null)
                    {
                        if ((ilist.Kind != ITPlaylistKind.ITPlaylistKindUser) ||
                            ilist.Name.Equals(Resx.PlaylistGenius))
                        {
                            continue;
                        }

                        IITUserPlaylist ulist = (IITUserPlaylist)ilist;

                        if ((ulist.SpecialKind == ITUserPlaylistSpecialKind.ITUserPlaylistSpecialKindNone) ||
                            (ulist.SpecialKind == ITUserPlaylistSpecialKind.ITUserPlaylistSpecialKindPurchases) ||
                            (ulist.SpecialKind == ITUserPlaylistSpecialKind.ITUserPlaylistSpecialKindFolder))
                        {
                            if (ulist.Tracks.Count > 0)
                            {
                                Playlist playlist = new Playlist(ulist);
                                playlist.IsSelected = (playlist.PlaylistID == currentID);
                                playlists.Add(playlist);
                            }
                        }
                    }
                }
            });

            return playlists;
        }
Beispiel #2
0
 //========================================================================================
 // Methods
 //========================================================================================
 /// <summary>
 /// Adds a new playlist or updates the name of an existing playlist in the catalog.
 /// </summary>
 /// <param name="playlist"></param>
 public abstract void AddPlaylist(Playlist playlist);
Beispiel #3
0
 /// <summary>
 /// Adds a new playlist or updates the name of an existing playlist in the catalog.
 /// </summary>
 /// <param name="playlist"></param>
 public override void AddPlaylist(Playlist playlist)
 {
 }
Beispiel #4
0
        //========================================================================================
        // Methods
        //========================================================================================
        /// <summary>
        /// Execute the scanner.
        /// </summary>
        public override void Execute()
        {
            Logger.WriteLine(base.name, "Phantom scanner beginning");

            libraryPlaylist = controller.LibraryPlaylist;
            PersistentIDCollection pids;

            if (!String.IsNullOrEmpty(albumFilter) && !String.IsNullOrEmpty(artistFilter))
            {
                pids = catalog.FindTracksByAlbum(albumFilter, artistFilter);
                total = pids.Count;

                Logger.WriteLine(base.name, String.Format(
                    "Analyzing album '{0}' by '{1}' with {2} tracks",
                    albumFilter, artistFilter, total));
            }
            else if (!playlistFilter.IsEmpty)
            {
                pids = catalog.FindTracksByPlaylist(playlistFilter);
                total = pids.Count;

                Logger.WriteLine(base.name, String.Format(
                    "Analyzing playlist '{0}' with {1} tracks",
                    catalog.FindPlaylistName(playlistFilter), total));
            }
            else
            {
                // if a track is deleted from a source's primary playlist, it will be deleted
                // from all playlist's in that source, so we only need look at main "Library"

                pids = catalog.FindTracksByPlaylist(libraryPlaylist.PersistentID);
                total = pids.Count;

                Logger.WriteLine(base.name, String.Format(
                    "Analyzing Library playlist '{0}' with {1} tracks",
                    libraryPlaylist.Name, total));
            }

            ScanTracks(pids);

            pids.Clear();
            pids = null;

            libraryPlaylist = null;

            if (base.isActive)
                Logger.WriteLine(base.name, "Phantom scanner completed");
            else
                Logger.WriteLine(base.name, "Phantom scanner cancelled");
        }
Beispiel #5
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);
                }
            }
        }