fix refresh of tv recordings

pull/702/head
Luke Pulverenti 11 years ago
parent 326fa5a670
commit cf9ef0e43d

@ -69,17 +69,7 @@ namespace MediaBrowser.Api.Library
public object Get(GetPhyscialPaths request)
{
var result = _libraryManager.RootFolder.Children
.SelectMany(c =>
{
var locationType = c.LocationType;
if (locationType != LocationType.Remote && locationType != LocationType.Virtual)
{
return c.PhysicalLocations;
}
return new List<string>();
})
.SelectMany(c => c.PhysicalLocations)
.ToList();
return ToOptimizedSerializedResultUsingCache(result);

@ -243,8 +243,8 @@ namespace MediaBrowser.Api
public object Get(GetFile request)
{
var item = _dtoService.GetItemByDtoId(request.Id);
if (item.LocationType == LocationType.Remote || item.LocationType == LocationType.Virtual)
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
{
throw new ArgumentException("This command cannot be used for remote or virtual items.");
}
@ -331,8 +331,7 @@ namespace MediaBrowser.Api
{
if (item.Parent is AggregateFolder)
{
return user.RootFolder.GetChildren(user, true).FirstOrDefault(i => i.LocationType == LocationType.FileSystem &&
i.PhysicalLocations.Contains(item.Path));
return user.RootFolder.GetChildren(user, true).FirstOrDefault(i => i.PhysicalLocations.Contains(item.Path));
}
return item;
@ -442,12 +441,9 @@ namespace MediaBrowser.Api
var parent = item.Parent;
if (item.LocationType == LocationType.Offline)
{
throw new InvalidOperationException(string.Format("{0} is currently offline.", item.Name));
}
var locationType = item.LocationType;
if (item.LocationType == LocationType.FileSystem)
if (locationType == LocationType.FileSystem || locationType == LocationType.Offline)
{
foreach (var path in item.GetDeletePaths().ToList())
{

@ -157,6 +157,16 @@ namespace MediaBrowser.Controller.Entities
}
}
public virtual bool SupportsLocalMetadata
{
get
{
var locationType = LocationType;
return locationType == LocationType.FileSystem || locationType == LocationType.Offline;
}
}
/// <summary>
/// This is just a helper for convenience
/// </summary>

@ -1052,50 +1052,17 @@ namespace MediaBrowser.Controller.Entities
throw new ArgumentNullException();
}
try
if (string.Equals(Path, path, StringComparison.OrdinalIgnoreCase))
{
var locationType = LocationType;
if (locationType == LocationType.Remote && string.Equals(Path, path, StringComparison.OrdinalIgnoreCase))
{
return this;
}
if (locationType != LocationType.Virtual && PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase))
{
return this;
}
}
catch (IOException ex)
{
Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
return this;
}
return RecursiveChildren.Where(i => i.LocationType != LocationType.Virtual).FirstOrDefault(i =>
if (PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase))
{
try
{
if (string.Equals(i.Path, path, StringComparison.OrdinalIgnoreCase))
{
return true;
}
if (i.LocationType != LocationType.Remote)
{
if (i.PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase))
{
return true;
}
}
return this;
}
return false;
}
catch (IOException ex)
{
Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
return false;
}
});
return RecursiveChildren.FirstOrDefault(i => string.Equals(i.Path, path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase));
}
public override bool IsPlayed(User user)

@ -136,6 +136,12 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <returns><c>true</c> if [is save local metadata enabled]; otherwise, <c>false</c>.</returns>
bool IsSaveLocalMetadataEnabled();
/// <summary>
/// Gets a value indicating whether [supports local metadata].
/// </summary>
/// <value><c>true</c> if [supports local metadata]; otherwise, <c>false</c>.</value>
bool SupportsLocalMetadata { get; }
}
public static class HasImagesExtensions

@ -185,7 +185,7 @@ namespace MediaBrowser.Controller.Entities.TV
{
get
{
return LocationType == Model.Entities.LocationType.Virtual && PremiereDate.HasValue && PremiereDate.Value < DateTime.UtcNow;
return LocationType == LocationType.Virtual && PremiereDate.HasValue && PremiereDate.Value < DateTime.UtcNow;
}
}
@ -198,7 +198,7 @@ namespace MediaBrowser.Controller.Entities.TV
[IgnoreDataMember]
public bool IsVirtualUnaired
{
get { return LocationType == Model.Entities.LocationType.Virtual && IsUnaired; }
get { return LocationType == LocationType.Virtual && IsUnaired; }
}
[IgnoreDataMember]

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Controller.Entities
{
@ -18,5 +19,18 @@ namespace MediaBrowser.Controller.Entities
{
return base.GetNonCachedChildren(directoryService).Concat(LibraryManager.RootFolder.VirtualChildren);
}
public override ItemUpdateType BeforeMetadataRefresh()
{
var updateType = base.BeforeMetadataRefresh();
if (string.Equals("default", Name, System.StringComparison.OrdinalIgnoreCase))
{
Name = "Default Media Library";
updateType = updateType | ItemUpdateType.MetadataEdit;
}
return updateType;
}
}
}

@ -25,19 +25,6 @@ namespace MediaBrowser.Controller.LiveTv
public string ServiceName { get; set; }
/// <summary>
/// Returns the folder containing the item.
/// If the item is a folder, it returns the folder itself
/// </summary>
/// <value>The containing folder path.</value>
public override string ContainingFolderPath
{
get
{
return Path;
}
}
/// <summary>
/// Gets a value indicating whether this instance is owned item.
/// </summary>

@ -46,19 +46,6 @@ namespace MediaBrowser.Controller.LiveTv
}
}
/// <summary>
/// Returns the folder containing the item.
/// If the item is a folder, it returns the folder itself
/// </summary>
/// <value>The containing folder path.</value>
public override string ContainingFolderPath
{
get
{
return Path;
}
}
/// <summary>
/// Gets a value indicating whether this instance is owned item.
/// </summary>

@ -2,7 +2,6 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using System.Collections.Generic;
using System.IO;
@ -35,16 +34,7 @@ namespace MediaBrowser.Providers.All
return true;
}
var locationType = item.LocationType;
if (locationType == LocationType.FileSystem ||
locationType == LocationType.Offline)
{
return false;
}
// These always save locally
if (item is IItemByName || item is User)
if (item.SupportsLocalMetadata)
{
return false;
}

@ -2,6 +2,7 @@
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using System;
@ -26,9 +27,7 @@ namespace MediaBrowser.Providers.All
public bool Supports(IHasImages item)
{
var locationType = item.LocationType;
if (locationType == LocationType.FileSystem)
if (item.SupportsLocalMetadata)
{
// Episode has it's own provider
if (item.IsOwnedItem || item is Episode || item is Audio)
@ -39,7 +38,7 @@ namespace MediaBrowser.Providers.All
return true;
}
if (locationType == LocationType.Virtual)
if (item.LocationType == LocationType.Virtual)
{
var season = item as Season;

@ -60,9 +60,14 @@ namespace MediaBrowser.Providers
protected abstract FileInfo GetXmlFile(ItemInfo info);
protected virtual FileInfo GetXmlFile(ItemInfo info, IDirectoryService directoryService)
{
return GetXmlFile(info);
}
public bool HasChanged(IHasMetadata item, IDirectoryService directoryService, DateTime date)
{
var file = GetXmlFile(new ItemInfo { IsInMixedFolder = item.IsInMixedFolder, Path = item.Path });
var file = GetXmlFile(new ItemInfo { IsInMixedFolder = item.IsInMixedFolder, Path = item.Path }, directoryService);
if (file == null)
{

@ -15,7 +15,7 @@ namespace MediaBrowser.Providers.Folders
public bool Supports(IHasImages item)
{
return item is CollectionFolder && item.LocationType == LocationType.FileSystem;
return item is CollectionFolder && item.SupportsLocalMetadata;
}
public int Order

@ -93,13 +93,9 @@ namespace MediaBrowser.Providers.Manager
{
var series = season.Series;
if (series != null)
if (series != null && series.SupportsLocalMetadata)
{
var seriesLocationType = series.LocationType;
if (seriesLocationType == LocationType.FileSystem || seriesLocationType == LocationType.Offline)
{
saveLocally = true;
}
saveLocally = true;
}
}
}

@ -351,7 +351,7 @@ namespace MediaBrowser.Providers.Manager
return false;
}
if (item.LocationType != LocationType.FileSystem && provider is ILocalMetadataProvider)
if (!item.SupportsLocalMetadata && provider is ILocalMetadataProvider)
{
return false;
}

@ -148,7 +148,7 @@ namespace MediaBrowser.Providers.MediaInfo
return true;
}
if (item.LocationType == LocationType.FileSystem)
if (item.SupportsLocalMetadata)
{
var video = item as Video;

@ -27,8 +27,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -27,8 +27,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -27,8 +27,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -22,8 +22,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -31,8 +31,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -29,8 +29,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -27,8 +27,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -31,8 +31,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -41,8 +41,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -31,8 +31,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -27,8 +27,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -28,8 +28,7 @@ namespace MediaBrowser.Providers.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
{
var locationType = item.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
if (!item.SupportsLocalMetadata)
{
return false;
}

@ -18,7 +18,7 @@ namespace MediaBrowser.Providers.TV
public bool Supports(IHasImages item)
{
return item is Episode && item.LocationType == LocationType.FileSystem;
return item is Episode && item.SupportsLocalMetadata;
}
public List<LocalImageInfo> GetImages(IHasImages item, IDirectoryService directoryService)
@ -77,28 +77,5 @@ namespace MediaBrowser.Providers.TV
})
.ToList();
}
private List<LocalImageInfo> GetFilesFromMetadataFolder(string filenameWithoutExtension, IEnumerable<FileInfo> metadataFiles)
{
return metadataFiles
.Where(i =>
{
if (BaseItem.SupportedImageExtensions.Contains(i.Extension))
{
if (string.Equals(filenameWithoutExtension, Path.GetFileNameWithoutExtension(i.Name), StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
})
.Select(i => new LocalImageInfo
{
FileInfo = i,
Type = ImageType.Primary
})
.ToList();
}
}
}

@ -30,5 +30,15 @@ namespace MediaBrowser.Providers.TV
return new FileInfo(metadataFile);
}
protected override FileInfo GetXmlFile(ItemInfo info, IDirectoryService directoryService)
{
var metadataPath = Path.GetDirectoryName(info.Path);
metadataPath = Path.Combine(metadataPath, "metadata");
var metadataFile = Path.Combine(metadataPath, Path.ChangeExtension(Path.GetFileName(info.Path), ".xml"));
return directoryService.GetFile(metadataFile);
}
}
}

@ -273,8 +273,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{
if (item.LocationType == LocationType.FileSystem)
{
return collections.Where(i => i.LocationType == LocationType.FileSystem &&
i.PhysicalLocations.Contains(item.Path)).Cast<T>();
return collections.Where(i => i.PhysicalLocations.Contains(item.Path)).Cast<T>();
}
}
@ -283,7 +282,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{
if (item.Id == user.RootFolder.Id)
{
return new T[] { item };
return new[] { item };
}
return new T[] { };

@ -161,7 +161,6 @@ namespace MediaBrowser.Server.Implementations.IO
.RootFolder
.Children
.OfType<Folder>()
.Where(i => i.LocationType != LocationType.Remote && i.LocationType != LocationType.Virtual)
.SelectMany(f => f.PhysicalLocations)
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderBy(i => i)

@ -1399,22 +1399,7 @@ namespace MediaBrowser.Server.Implementations.Library
.Distinct()
.SelectMany(i => i.Children)
.OfType<CollectionFolder>()
.Where(i =>
{
var locationType = i.LocationType;
if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
{
return false;
}
if (string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase))
{
return true;
}
return i.PhysicalLocations.Contains(item.Path);
})
.Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path))
.Select(i => i.CollectionType)
.Where(i => !string.IsNullOrEmpty(i))
.Distinct()

@ -615,13 +615,9 @@ namespace MediaBrowser.Server.Implementations.Session
}
var items = command.ItemIds.Select(i => _libraryManager.GetItemById(new Guid(i)))
.Where(i => i.LocationType != LocationType.Virtual)
.ToList();
if (items.Any(i => i.LocationType == LocationType.Virtual))
{
throw new ArgumentException("Virtual items are not playable.");
}
if (command.PlayCommand != PlayCommand.PlayNow)
{
if (items.Any(i => !session.QueueableMediaTypes.Contains(i.MediaType, StringComparer.OrdinalIgnoreCase)))

Loading…
Cancel
Save