Ejemplo n.º 1
0
 private static void SortFolder(VirtualFolder folder,
                                TripleKeyedVirtualFolder artists,
                                TripleKeyedVirtualFolder performers,
                                DoubleKeyedVirtualFolder albums,
                                SimpleKeyedVirtualFolder genres)
 {
     foreach (var f in folder.ChildFolders.ToList())
     {
         SortFolder(f as VirtualFolder, artists, performers, albums, genres);
     }
     foreach (var i in folder.ChildItems.ToList())
     {
         var ai = i as IMediaAudioResource;
         if (ai == null)
         {
             continue;
         }
         var album = ai.MetaAlbum ?? "Unspecified album";
         albums.GetFolder(album.StemCompareBase().First().ToString().ToUpper(CultureInfo.CurrentUICulture))
         .GetFolder(album.StemNameBase()).AddResource(i);
         LinkTriple(artists, ai, ai.MetaArtist, album);
         LinkTriple(performers, ai, ai.MetaPerformer, album);
         var genre = ai.MetaGenre;
         if (genre != null)
         {
             genres.GetFolder(genre.StemNameBase()).AddResource(i);
         }
     }
 }
Ejemplo n.º 2
0
        public override IMediaFolder Transform(IMediaFolder oldRoot)
        {
            var root   = new VirtualClonedFolder(oldRoot);
            var sorted = new SimpleKeyedVirtualFolder(root, Name);

            SortFolder(root, sorted);
            DebugFormat("sort {0} - {1}", sorted.ChildFolders.Count(), sorted.ChildItems.Count());
            DebugFormat("root {0} - {1}", root.ChildFolders.Count(), root.ChildItems.Count());
            foreach (var f in sorted.ChildFolders.ToList())
            {
                if (f.ChildCount < 2)
                {
                    foreach (var file in f.ChildItems)
                    {
                        root.AddResource(file);
                    }
                    continue;
                }

                var fsmi = f as VirtualFolder;
                root.AdoptFolder(fsmi);
            }

            foreach (var f in sorted.ChildItems.ToList())
            {
                root.AddResource(f);
            }
            DebugFormat("merg {0} - {1}", root.ChildFolders.Count(), root.ChildItems.Count());
            MergeFolders(root, root);
            DebugFormat("done {0} - {1}", root.ChildFolders.Count(), root.ChildItems.Count());

            if (!cascade || root.ChildFolders.LongCount() <= 50)
            {
                return(root);
            }
            var cascaded = new DoubleKeyedVirtualFolder(root, "Series");

            foreach (var i in root.ChildFolders.ToList())
            {
                var folder = cascaded.GetFolder(i.Title.StemCompareBase().Substring(0, 1).ToUpper());
                folder.AdoptFolder(i);
            }

            foreach (var i in root.ChildItems.ToList())
            {
                var folder = cascaded.GetFolder(i.Title.StemCompareBase().Substring(0, 1).ToUpper());
                folder.AddResource(i);
            }

            return(cascaded);
        }
Ejemplo n.º 3
0
        public override IMediaFolder Transform(IMediaFolder Root)
        {
            var root       = new VirtualClonedFolder(Root);
            var artists    = new TripleKeyedVirtualFolder(root, "Artists");
            var performers = new TripleKeyedVirtualFolder(root, "Performers");
            var albums     = new DoubleKeyedVirtualFolder(root, "Albums");
            var genres     = new SimpleKeyedVirtualFolder(root, "Genre");
            var folders    = new VirtualFolder(root, "Folders");

            SortFolder(root, artists, performers, albums, genres);
            foreach (var f in root.ChildFolders.ToList())
            {
                folders.AdoptFolder(f);
            }
            root.AdoptFolder(artists);
            root.AdoptFolder(performers);
            root.AdoptFolder(albums);
            root.AdoptFolder(genres);
            root.AdoptFolder(folders);
            return(root);
        }
Ejemplo n.º 4
0
        public override IMediaFolder Transform(IMediaFolder Root)
        {
            var root   = new VirtualClonedFolder(Root);
            var series = new SimpleKeyedVirtualFolder(root, "Series");

            SortFolder(root, series);
            foreach (var f in series.ChildFolders.ToList())
            {
                if (f.ChildCount < 2)
                {
                    foreach (var file in f.ChildItems)
                    {
                        root.AddResource(file);
                    }
                    continue;
                }
                var fsmi = f as VirtualFolder;
                root.AdoptFolder(fsmi);
            }
            if (!cascade || root.ChildFolders.LongCount() <= 50)
            {
                return(root);
            }
            var cascaded = new DoubleKeyedVirtualFolder(root, "Series");

            foreach (var i in root.ChildFolders.ToList())
            {
                var folder = cascaded.GetFolder(i.Title.StemCompareBase().Substring(0, 1).ToUpper());
                folder.AdoptFolder(i);
            }
            foreach (var i in root.ChildItems.ToList())
            {
                var folder = cascaded.GetFolder(i.Title.StemCompareBase().Substring(0, 1).ToUpper());
                folder.AddResource(i);
            }
            return(cascaded);
        }