コード例 #1
0
ファイル: MusicView.cs プロジェクト: Xen0byte/simpleDLNA
 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);
         }
     }
 }
コード例 #2
0
ファイル: SeriesView.cs プロジェクト: zhengfish/simpleDLNA
 protected override void SortFolder(IMediaFolder folder,
                                    SimpleKeyedVirtualFolder series)
 {
     foreach (var f in folder.ChildFolders.ToList())
     {
         SortFolder(f, series);
     }
     foreach (var i in folder.ChildItems.ToList())
     {
         var title = i.Title;
         if (string.IsNullOrWhiteSpace(title))
         {
             continue;
         }
         var m = regSeries.Match(title);
         if (!m.Success)
         {
             continue;
         }
         var ser = m.Groups[1].Value;
         if (string.IsNullOrEmpty(ser))
         {
             continue;
         }
         series.GetFolder(ser.StemNameBase()).AddResource(i);
         folder.RemoveResource(i);
     }
 }
コード例 #3
0
ファイル: ByTitleView.cs プロジェクト: Xen0byte/simpleDLNA
        public override IMediaFolder Transform(IMediaFolder oldRoot)
        {
            var root   = new VirtualClonedFolder(oldRoot);
            var titles = new SimpleKeyedVirtualFolder(root, "titles");

            SortFolder(root, titles);
            foreach (var i in root.ChildFolders.ToList())
            {
                root.ReleaseFolder(i);
            }
            foreach (var i in titles.ChildFolders.ToList())
            {
                if (i.ChildCount > 100)
                {
                    DebugFormat("Partioning folder {0}", i.Title);
                    using (var prefixer = new Prefixer())
                    {
                        PartitionChildren(i as VirtualFolder, prefixer);
                    }
                }

                root.AdoptFolder(i);
            }

            return(root);
        }
コード例 #4
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);
        }
コード例 #5
0
ファイル: ByTitleView.cs プロジェクト: dmusz/simpleDLNA
        private static void SortFolder(VirtualFolder folder, SimpleKeyedVirtualFolder titles)
        {
            foreach (var f in folder.ChildFolders.ToList())
            {
                SortFolder(f as VirtualFolder, titles);
            }

            foreach (var c in folder.ChildItems.ToList())
            {
                var pre = GetTitle(c);
                pre = pre[0].ToString().ToUpperInvariant();
                titles.GetFolder(pre).AddResource(c);
                folder.RemoveResource(c);
            }
        }
コード例 #6
0
ファイル: SiteView.cs プロジェクト: dburner/simpleDLNA
 protected override void SortFolder(IMediaFolder folder,
                                    SimpleKeyedVirtualFolder series)
 {
     foreach (var f in folder.ChildFolders.ToList())
     {
         SortFolder(f, series);
     }
     foreach (var i in folder.ChildItems.ToList())
     {
         try
         {
             var title = i.Title;
             if (string.IsNullOrWhiteSpace(title))
             {
                 throw new Exception("No title");
             }
             var m = regSites.Match(title);
             if (!m.Success)
             {
                 throw new Exception("No match");
             }
             var site = m.Groups["site"].Value;
             if (string.IsNullOrEmpty(site))
             {
                 throw new Exception("No site");
             }
             site = site.Replace(" ", "").Replace("\t", "").Replace("-", "");
             site = regNumberStrip.Replace(site, string.Empty).TrimEnd();
             if (!regWord.IsMatch(site))
             {
                 throw new Exception("Not a site");
             }
             folder.RemoveResource(i);
             series.GetFolder(site.StemNameBase()).AddResource(i);
         }
         catch (Exception ex)
         {
             DebugFormat("{0} - {1}", ex.Message, i.Title);
             folder.RemoveResource(i);
             series.AddResource(i);
         }
     }
 }
コード例 #7
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);
        }
コード例 #8
0
ファイル: SeriesView.cs プロジェクト: everyonce/simpleDLNA
        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);
            }
            return(root);
        }
コード例 #9
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);
        }
コード例 #10
0
        public override IMediaFolder Transform(IMediaFolder Root)
        {
            var root   = new VirtualClonedFolder(Root);
            var series = new SimpleKeyedVirtualFolder(root, "Series");
            var movies = new SimpleKeyedVirtualFolder(root, "Movies");

            //SortFolder(root, series);

            /*
             * foreach (var f in series.ChildFolders.ToList()) {
             * var fsmi = f as VirtualFolder;
             * root.AdoptFolder(fsmi);
             * }
             * if (!cascade) {
             * 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 c in i.ChildItems)
             * {
             *  var c0 = c as IMediaVideoResource;
             *  var folder = cascaded.GetFolder(c0 != null ? c0.MovieTitle : i.Title);
             *  folder.AddResource(c);
             * }
             * }
             * foreach (var i in root.ChildItems.ToList()) {
             * //        var folder = cascaded.GetFolder(i.Title.StemCompareBase().Substring(0, 1).ToUpper());
             * //        folder.AddResource(i);
             * //        cascaded.AddResource(i);
             * var c0 = i as IMediaVideoResource;
             * var folder = cascaded.GetFolder(c0 != null ? c0.MovieTitle : i.Title);
             * folder.AddResource(i);
             * }
             */
            /*
             * var items = (from i in root.AllItems.ToList()
             *            let d = (i as IMediaVideoResource).InfoDate
             *            orderby d
             *            select i).ToList();
             */
            foreach (var c in root.AllItems.ToList())
            {
                var c0     = c as IMediaVideoResource;
                var folder = (c0 != null && c0.IsSeries ? series : movies).GetFolder(c0 != null ? c0.MovieTitle : c.Title);
                //var folder = new DoubleKeyedVirtualFolder((c0 != null && c0.IsSeries ? series : movies),(c0 != null ? c0.MovieTitle : c.Title) );
                if (c0.Progress <= 85)
                {
                    folder.AddResource(c);
                }
                else
                {
                    var folder1 = folder.ChildFolders.ToList().Find(f => f.Title == "WATCHED");
                    if (folder1 == null)
                    {
                        folder1 = new VirtualFolder(folder, "WATCHED");
                    }

                    folder1.AddResource(c);
                    folder.AdoptFolder(folder1);
                }

                root.RemoveResource(c);
            }
            foreach (var f in root.ChildFolders.ToList())
            {
                root.ReleaseFolder(f);
            }

            root.AdoptFolder(series);
            root.AdoptFolder(movies);
            return(root);
        }
コード例 #11
0
ファイル: CascadedView.cs プロジェクト: dburner/simpleDLNA
 protected abstract void SortFolder(IMediaFolder folder,
                                    SimpleKeyedVirtualFolder series);