fixes #1001 - Support downloading

This commit is contained in:
Luke Pulverenti
2015-02-06 00:39:07 -05:00
parent 4ae6b5f675
commit b6d59c7688
44 changed files with 322 additions and 66 deletions

View File

@@ -32,6 +32,11 @@ namespace MediaBrowser.Controller.Entities
}
}
public override bool CanDelete()
{
return false;
}
/// <summary>
/// The _virtual children
/// </summary>

View File

@@ -113,6 +113,13 @@ namespace MediaBrowser.Controller.Entities.Audio
}
}
public override bool CanDownload()
{
var locationType = LocationType;
return locationType != LocationType.Remote &&
locationType != LocationType.Virtual;
}
/// <summary>
/// Gets or sets the artist.
/// </summary>

View File

@@ -1,14 +1,13 @@
using System.Runtime.Serialization;
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Users;
namespace MediaBrowser.Controller.Entities.Audio
{
@@ -35,6 +34,11 @@ namespace MediaBrowser.Controller.Entities.Audio
get { return true; }
}
public override bool CanDelete()
{
return !IsAccessedByName;
}
protected override IEnumerable<BaseItem> ActualChildren
{
get

View File

@@ -39,6 +39,11 @@ namespace MediaBrowser.Controller.Entities.Audio
}
}
public override bool CanDelete()
{
return false;
}
/// <summary>
/// Gets a value indicating whether this instance is owned item.
/// </summary>

View File

@@ -239,6 +239,38 @@ namespace MediaBrowser.Controller.Entities
get { return this.GetImagePath(ImageType.Primary); }
}
public virtual bool CanDelete()
{
var locationType = LocationType;
return locationType != LocationType.Remote &&
locationType != LocationType.Virtual;
}
public virtual bool IsAuthorizedToDelete(User user)
{
return user.Policy.EnableContentDeletion;
}
public bool CanDelete(User user)
{
return CanDelete() && IsAuthorizedToDelete(user);
}
public virtual bool CanDownload()
{
return false;
}
public virtual bool IsAuthorizedToDownload(User user)
{
return user.Policy.EnableContentDownloading;
}
public bool CanDownload(User user)
{
return CanDownload() && IsAuthorizedToDownload(user);
}
/// <summary>
/// Gets or sets the date created.
/// </summary>

View File

@@ -11,5 +11,10 @@ namespace MediaBrowser.Controller.Entities
{
get { return null; }
}
public override bool CanDelete()
{
return false;
}
}
}

View File

@@ -2,6 +2,7 @@
using MediaBrowser.Model.Configuration;
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Users;
namespace MediaBrowser.Controller.Entities
@@ -37,6 +38,13 @@ namespace MediaBrowser.Controller.Entities
Tags = new List<string>();
}
public override bool CanDownload()
{
var locationType = LocationType;
return locationType != LocationType.Remote &&
locationType != LocationType.Virtual;
}
protected override bool GetBlockUnratedValue(UserPolicy config)
{
return config.BlockUnratedItems.Contains(UnratedItem.Book);

View File

@@ -35,6 +35,11 @@ namespace MediaBrowser.Controller.Entities
}
}
public override bool CanDelete()
{
return false;
}
public string CollectionType { get; set; }
/// <summary>

View File

@@ -1,10 +1,10 @@
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Model.Users;
namespace MediaBrowser.Controller.Entities
{
@@ -38,6 +38,13 @@ namespace MediaBrowser.Controller.Entities
public List<Guid> LocalTrailerIds { get; set; }
public List<Guid> RemoteTrailerIds { get; set; }
public override bool CanDownload()
{
var locationType = LocationType;
return locationType != LocationType.Remote &&
locationType != LocationType.Virtual;
}
/// <summary>
/// Gets or sets the tags.
/// </summary>

View File

@@ -43,6 +43,11 @@ namespace MediaBrowser.Controller.Entities
}
}
public override bool CanDelete()
{
return false;
}
public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
{
return inputItems.Where(GetItemFilter());

View File

@@ -34,6 +34,11 @@ namespace MediaBrowser.Controller.Entities
}
}
public override bool CanDelete()
{
return false;
}
/// <summary>
/// Gets a value indicating whether this instance is owned item.
/// </summary>

View File

@@ -15,6 +15,10 @@ namespace MediaBrowser.Controller.Entities
/// <returns>IEnumerable{BaseItem}.</returns>
IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems);
/// <summary>
/// Gets the item filter.
/// </summary>
/// <returns>Func&lt;BaseItem, System.Boolean&gt;.</returns>
Func<BaseItem, bool> GetItemFilter();
}

View File

@@ -74,6 +74,11 @@ namespace MediaBrowser.Controller.Entities.Movies
}
}
public override bool IsAuthorizedToDelete(User user)
{
return true;
}
/// <summary>
/// Gets the trailer ids.
/// </summary>

View File

@@ -45,6 +45,11 @@ namespace MediaBrowser.Controller.Entities
}
}
public override bool CanDelete()
{
return false;
}
/// <summary>
/// Gets a value indicating whether this instance is owned item.
/// </summary>

View File

@@ -40,6 +40,11 @@ namespace MediaBrowser.Controller.Entities
}
}
public override bool CanDelete()
{
return false;
}
/// <summary>
/// Gets a value indicating whether this instance is owned item.
/// </summary>

View File

@@ -40,6 +40,11 @@ namespace MediaBrowser.Controller.Entities
return result.Items;
}
public override bool CanDelete()
{
return false;
}
public override IEnumerable<BaseItem> GetRecursiveChildren(User user, Func<BaseItem, bool> filter)
{
var result = GetItems(new InternalItemsQuery

View File

@@ -64,6 +64,19 @@ namespace MediaBrowser.Controller.Entities
LinkedAlternateVersions = new List<LinkedChild>();
}
public override bool CanDownload()
{
if (VideoType == VideoType.HdDvd || VideoType == VideoType.Dvd ||
VideoType == VideoType.BluRay)
{
return false;
}
var locationType = LocationType;
return locationType != LocationType.Remote &&
locationType != LocationType.Virtual;
}
[IgnoreDataMember]
public override bool SupportsAddingToPlaylist
{

View File

@@ -34,6 +34,11 @@ namespace MediaBrowser.Controller.Entities
}
}
public override bool CanDelete()
{
return false;
}
/// <summary>
/// Gets a value indicating whether this instance is owned item.
/// </summary>