public void CleanCache()
        {
            //some safety validations to be sure we don't accidentally clear out downloaded trailers because of a load failure
            if (this.ActualChildren.Count < 5)
            {
                return;
            }
            //clear files no longer referenced from our cache
            //first build a list of files that are there
            var cacheFiles = new DirectoryInfo(Plugin.proxy.CacheDirectory).GetFiles();

            //then go through and match them up to current items
            Logger.ReportInfo("MBTrailers - Clearing cache of old trailers.");
            foreach (var file in cacheFiles)
            {
                MediaBrowser.Library.Entities.BaseItem item = this.ActualChildren.Find(i => System.IO.Path.GetFileName(i.Path) == file.Name);
                if (item == null && (DateTime.UtcNow - file.CreationTimeUtc) > TimeSpan.FromDays(60)) //if not there and old
                {
                    try
                    {
                        File.Delete(file.FullName); // not in our children anymore clean it up
                        Logger.ReportInfo("MBTrailers deleted old trailer download from cache: " + file.FullName);
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Unable to clear file from trailercache: " + file.FullName, e);
                    }
                }
            }
        }
示例#2
0
 protected bool IsVisible(BaseItem item)
 {
     return((!Filters.IsFavorite || item.IsFavorite) && (!Filters.IsUnWatched || !item.Watched));
 }
示例#3
0
        void AddItemToIndex(Dictionary <BaseItem, List <BaseItem> > index, BaseItem item, BaseItem child)
        {
            List <BaseItem> subItems;

            if (!index.TryGetValue(item, out subItems))
            {
                subItems    = new List <BaseItem>();
                index[item] = subItems;
            }
            if (child is Episode)
            {
                //we want to group these by series - find or create a series head
                Episode     episode       = child as Episode;
                Folder      currentSeries = episode.Parent is IndexFolder ? episode.Parent : episode.Series; //may already be indexed
                IndexFolder series        = (IndexFolder)index[item].Find(i => i.Id == (item.Name + currentSeries.Name).GetMD5());
                if (series == null)
                {
                    series = new IndexFolder()
                    {
                        Id                 = (item.Name + currentSeries.Name).GetMD5(),
                        Name               = currentSeries.Name,
                        Overview           = currentSeries.Overview,
                        PrimaryImagePath   = currentSeries.PrimaryImagePath,
                        SecondaryImagePath = currentSeries.SecondaryImagePath,
                        BannerImagePath    = currentSeries.BannerImagePath,
                        BackdropImagePaths = currentSeries.BackdropImagePaths
                    };
                    index[item].Add(series);
                }
                series.AddChild(episode);
            }
            else
            {
                if (!(child is Season))
                {
                    subItems.Add(child);                     //never want seasons
                }
            }
        }
示例#4
0
 public ApiGenreFolder(BaseItem item, string searchParentId = null, string[] includeTypes = null, string[] excludeTypes = null, Folder parent = null) : base(item, searchParentId, includeTypes, excludeTypes, parent)
 {
 }
示例#5
0
 public void AddChild(BaseItem child)
 {
     this.ActualChildren.Add(child);
     child.Parent = this;
 }
示例#6
0
 public void RemoveVirtualChild(BaseItem child)
 {
     virtualChildren.Remove(virtualChildren.Find(c => c.Id == child.Id));
 }
示例#7
0
 public void AddVirtualChild(BaseItem child)
 {
     virtualChildren.Add(child);
 }