sync fixes

This commit is contained in:
Luke Pulverenti 2014-12-28 01:21:39 -05:00
parent 7bce2e04b6
commit 5278959ede
25 changed files with 192 additions and 281 deletions

View File

@ -112,11 +112,11 @@ namespace MediaBrowser.Api
{ {
link.PrimaryVersionId = null; link.PrimaryVersionId = null;
await link.UpdateToRepository(ItemUpdateType.MetadataDownload, CancellationToken.None).ConfigureAwait(false); await link.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
} }
video.LinkedAlternateVersions.Clear(); video.LinkedAlternateVersions.Clear();
await video.UpdateToRepository(ItemUpdateType.MetadataDownload, CancellationToken.None).ConfigureAwait(false); await video.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
} }
public void Post(MergeVersions request) public void Post(MergeVersions request)
@ -184,7 +184,7 @@ namespace MediaBrowser.Api
{ {
item.PrimaryVersionId = primaryVersion.Id; item.PrimaryVersionId = primaryVersion.Id;
await item.UpdateToRepository(ItemUpdateType.MetadataDownload, CancellationToken.None).ConfigureAwait(false); await item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
primaryVersion.LinkedAlternateVersions.Add(new LinkedChild primaryVersion.LinkedAlternateVersions.Add(new LinkedChild
{ {
@ -193,7 +193,7 @@ namespace MediaBrowser.Api
}); });
} }
await primaryVersion.UpdateToRepository(ItemUpdateType.MetadataDownload, CancellationToken.None).ConfigureAwait(false); await primaryVersion.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
} }
} }
} }

View File

@ -4,6 +4,7 @@ using SharpCompress.Archive.SevenZip;
using SharpCompress.Archive.Tar; using SharpCompress.Archive.Tar;
using SharpCompress.Common; using SharpCompress.Common;
using SharpCompress.Reader; using SharpCompress.Reader;
using SharpCompress.Reader.Zip;
using System.IO; using System.IO;
namespace MediaBrowser.Common.Implementations.Archiving namespace MediaBrowser.Common.Implementations.Archiving
@ -48,6 +49,21 @@ namespace MediaBrowser.Common.Implementations.Archiving
} }
} }
public void ExtractAllFromZip(Stream source, string targetPath, bool overwriteExistingFiles)
{
using (var reader = ZipReader.Open(source))
{
var options = ExtractOptions.ExtractFullPath;
if (overwriteExistingFiles)
{
options = options | ExtractOptions.Overwrite;
}
reader.WriteAllToDirectory(targetPath, options);
}
}
/// <summary> /// <summary>
/// Extracts all from7z. /// Extracts all from7z.
/// </summary> /// </summary>

View File

@ -19,7 +19,7 @@ namespace MediaBrowser.Controller.Entities.Movies
public class BoxSet : Folder, IHasTrailers, IHasKeywords, IHasPreferredMetadataLanguage, IHasDisplayOrder, IHasLookupInfo<BoxSetInfo>, IMetadataContainer, IHasShares public class BoxSet : Folder, IHasTrailers, IHasKeywords, IHasPreferredMetadataLanguage, IHasDisplayOrder, IHasLookupInfo<BoxSetInfo>, IMetadataContainer, IHasShares
{ {
public List<Share> Shares { get; set; } public List<Share> Shares { get; set; }
public BoxSet() public BoxSet()
{ {
RemoteTrailers = new List<MediaUrl>(); RemoteTrailers = new List<MediaUrl>();
@ -171,10 +171,13 @@ namespace MediaBrowser.Controller.Entities.Movies
{ {
var userId = user.Id.ToString("N"); var userId = user.Id.ToString("N");
return Shares.Any(i => string.Equals(userId, i.UserId, StringComparison.OrdinalIgnoreCase)) || // Need to check Count > 0 for boxsets created prior to the introduction of Shares
if (Shares.Count > 0 && !Shares.Any(i => string.Equals(userId, i.UserId, StringComparison.OrdinalIgnoreCase)))
{
return false;
}
// Need to support this for boxsets created prior to the creation of Shares return true;
Shares.Count == 0;
} }
return false; return false;

View File

@ -49,7 +49,7 @@ namespace MediaBrowser.LocalMetadata.Savers
!(item is GameSystem) && !(item is GameSystem) &&
!(item is Playlist)) !(item is Playlist))
{ {
return updateType >= ItemUpdateType.MetadataDownload; return updateType >= ItemUpdateType.MetadataEdit;
} }
} }

View File

@ -23,6 +23,14 @@ namespace MediaBrowser.Model.IO
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param> /// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles); void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles);
/// <summary>
/// Extracts all from zip.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="targetPath">The target path.</param>
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
void ExtractAllFromZip(Stream source, string targetPath, bool overwriteExistingFiles);
/// <summary> /// <summary>
/// Extracts all from7z. /// Extracts all from7z.
/// </summary> /// </summary>

View File

@ -75,7 +75,7 @@ namespace MediaBrowser.Providers.BoxSets
if (!string.Equals(currentOfficialRating ?? string.Empty, item.OfficialRating ?? string.Empty, if (!string.Equals(currentOfficialRating ?? string.Empty, item.OfficialRating ?? string.Empty,
StringComparison.OrdinalIgnoreCase)) StringComparison.OrdinalIgnoreCase))
{ {
updateType = updateType | ItemUpdateType.MetadataDownload; updateType = updateType | ItemUpdateType.MetadataEdit;
} }
} }

View File

@ -54,7 +54,7 @@ namespace MediaBrowser.Providers.Music
if (currentList.Count != item.Genres.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Genres.OrderBy(i => i), StringComparer.OrdinalIgnoreCase)) if (currentList.Count != item.Genres.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Genres.OrderBy(i => i), StringComparer.OrdinalIgnoreCase))
{ {
updateType = updateType | ItemUpdateType.MetadataDownload; updateType = updateType | ItemUpdateType.MetadataEdit;
} }
} }
@ -68,7 +68,7 @@ namespace MediaBrowser.Providers.Music
if (currentList.Count != item.Studios.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Studios.OrderBy(i => i), StringComparer.OrdinalIgnoreCase)) if (currentList.Count != item.Studios.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Studios.OrderBy(i => i), StringComparer.OrdinalIgnoreCase))
{ {
updateType = updateType | ItemUpdateType.MetadataDownload; updateType = updateType | ItemUpdateType.MetadataEdit;
} }
} }
@ -81,15 +81,15 @@ namespace MediaBrowser.Providers.Music
if (!string.Equals(item.Name, name, StringComparison.Ordinal)) if (!string.Equals(item.Name, name, StringComparison.Ordinal))
{ {
item.Name = name; item.Name = name;
updateType = updateType | ItemUpdateType.MetadataDownload; updateType = updateType | ItemUpdateType.MetadataEdit;
} }
} }
} }
}
updateType = updateType | SetAlbumArtistFromSongs(item, songs); updateType = updateType | SetAlbumArtistFromSongs(item, songs);
updateType = updateType | SetArtistsFromSongs(item, songs); updateType = updateType | SetArtistsFromSongs(item, songs);
updateType = updateType | SetDateFromSongs(item, songs); updateType = updateType | SetDateFromSongs(item, songs);
}
return updateType; return updateType;
} }
@ -106,7 +106,7 @@ namespace MediaBrowser.Providers.Music
if (!item.AlbumArtists.SequenceEqual(albumArtists, StringComparer.OrdinalIgnoreCase)) if (!item.AlbumArtists.SequenceEqual(albumArtists, StringComparer.OrdinalIgnoreCase))
{ {
item.AlbumArtists = albumArtists; item.AlbumArtists = albumArtists;
updateType = updateType | ItemUpdateType.MetadataDownload; updateType = updateType | ItemUpdateType.MetadataEdit;
} }
return updateType; return updateType;
@ -124,7 +124,7 @@ namespace MediaBrowser.Providers.Music
if (currentList.Count != item.Artists.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Artists.OrderBy(i => i), StringComparer.OrdinalIgnoreCase)) if (currentList.Count != item.Artists.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Artists.OrderBy(i => i), StringComparer.OrdinalIgnoreCase))
{ {
updateType = updateType | ItemUpdateType.MetadataDownload; updateType = updateType | ItemUpdateType.MetadataEdit;
} }
return updateType; return updateType;
@ -158,7 +158,7 @@ namespace MediaBrowser.Providers.Music
if ((originalPremiereDate ?? DateTime.MinValue) != (item.PremiereDate ?? DateTime.MinValue) || if ((originalPremiereDate ?? DateTime.MinValue) != (item.PremiereDate ?? DateTime.MinValue) ||
(originalProductionYear ?? -1) != (item.ProductionYear ?? -1)) (originalProductionYear ?? -1) != (item.ProductionYear ?? -1))
{ {
updateType = updateType | ItemUpdateType.MetadataDownload; updateType = updateType | ItemUpdateType.MetadataEdit;
} }
return updateType; return updateType;

View File

@ -35,19 +35,22 @@ namespace MediaBrowser.Providers.Music
{ {
var updateType = base.BeforeSave(item); var updateType = base.BeforeSave(item);
if (!item.IsAccessedByName && !item.LockedFields.Contains(MetadataFields.Genres)) if (!item.IsAccessedByName && !item.IsLocked)
{ {
var songs = item.RecursiveChildren.OfType<Audio>().ToList(); if (!item.LockedFields.Contains(MetadataFields.Genres))
var currentList = item.Genres.ToList();
item.Genres = songs.SelectMany(i => i.Genres)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
if (currentList.Count != item.Genres.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Genres.OrderBy(i => i), StringComparer.OrdinalIgnoreCase))
{ {
updateType = updateType | ItemUpdateType.MetadataDownload; var songs = item.RecursiveChildren.OfType<Audio>().ToList();
var currentList = item.Genres.ToList();
item.Genres = songs.SelectMany(i => i.Genres)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
if (currentList.Count != item.Genres.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Genres.OrderBy(i => i), StringComparer.OrdinalIgnoreCase))
{
updateType = updateType | ItemUpdateType.MetadataEdit;
}
} }
} }

View File

@ -210,7 +210,7 @@ namespace MediaBrowser.Providers.TV
await zipStream.CopyToAsync(ms).ConfigureAwait(false); await zipStream.CopyToAsync(ms).ConfigureAwait(false);
ms.Position = 0; ms.Position = 0;
_zipClient.ExtractAll(ms, seriesDataPath, true); _zipClient.ExtractAllFromZip(ms, seriesDataPath, true);
} }
} }

View File

@ -68,6 +68,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// </summary> /// </summary>
/// <value>The entity resolvers enumerable.</value> /// <value>The entity resolvers enumerable.</value>
private IItemResolver[] EntityResolvers { get; set; } private IItemResolver[] EntityResolvers { get; set; }
private IMultiItemResolver[] MultiItemResolvers { get; set; }
/// <summary> /// <summary>
/// Gets or sets the comparers. /// Gets or sets the comparers.
@ -196,9 +197,10 @@ namespace MediaBrowser.Server.Implementations.Library
EntityResolutionIgnoreRules = rules.ToArray(); EntityResolutionIgnoreRules = rules.ToArray();
PluginFolderCreators = pluginFolders.ToArray(); PluginFolderCreators = pluginFolders.ToArray();
EntityResolvers = resolvers.OrderBy(i => i.Priority).ToArray(); EntityResolvers = resolvers.OrderBy(i => i.Priority).ToArray();
MultiItemResolvers = EntityResolvers.OfType<IMultiItemResolver>().ToArray();
IntroProviders = introProviders.ToArray(); IntroProviders = introProviders.ToArray();
Comparers = itemComparers.ToArray(); Comparers = itemComparers.ToArray();
PostscanTasks = postscanTasks.OrderBy(i => PostscanTasks = postscanTasks.OrderBy(i =>
{ {
var hasOrder = i as IHasOrder; var hasOrder = i as IHasOrder;
@ -344,7 +346,7 @@ namespace MediaBrowser.Server.Implementations.Library
try try
{ {
await UpdateItem(season, ItemUpdateType.MetadataDownload, cancellationToken).ConfigureAwait(false); await UpdateItem(season, ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -658,9 +660,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (parent != null) if (parent != null)
{ {
var multiItemResolvers = EntityResolvers.OfType<IMultiItemResolver>(); foreach (var resolver in MultiItemResolvers)
foreach (var resolver in multiItemResolvers)
{ {
var result = resolver.ResolveMultiple(parent, fileList, collectionType, directoryService); var result = resolver.ResolveMultiple(parent, fileList, collectionType, directoryService);

View File

@ -121,14 +121,28 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
ILibraryManager libraryManager) ILibraryManager libraryManager)
{ {
var discSubfolderCount = 0; var discSubfolderCount = 0;
var notMultiDisc = false;
foreach (var fileSystemInfo in list) foreach (var fileSystemInfo in list)
{ {
if ((fileSystemInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory) if ((fileSystemInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
{ {
if (allowSubfolders && IsAlbumSubfolder(fileSystemInfo, directoryService, logger, fileSystem, libraryManager)) if (allowSubfolders)
{ {
discSubfolderCount++; var path = fileSystemInfo.FullName;
var isMultiDisc = IsMultiDiscFolder(path);
var hasMusic = ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);
if (isMultiDisc && hasMusic)
{
logger.Debug("Found multi-disc folder: " + path);
discSubfolderCount++;
}
else if (hasMusic)
{
// If there are folders underneath with music that are not multidisc, then this can't be a multi-disc album
notMultiDisc = true;
}
} }
} }
@ -140,34 +154,15 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
} }
} }
return discSubfolderCount > 0; if (notMultiDisc)
}
private static bool IsAlbumSubfolder(FileSystemInfo directory, IDirectoryService directoryService, ILogger logger, IFileSystem fileSystem, ILibraryManager libraryManager)
{
var path = directory.FullName;
if (IsMultiDiscFolder(path))
{ {
logger.Debug("Found multi-disc folder: " + path); return false;
return ContainsMusic(directoryService.GetFileSystemEntries(path), false, directoryService, logger, fileSystem, libraryManager);
} }
return false; return discSubfolderCount > 0 && discSubfolderCount > 10;
} }
public static bool IsMultiDiscFolder(string path) private static bool IsMultiDiscFolder(string path)
{
return IsMultiDiscAlbumFolder(path);
}
/// <summary>
/// Determines whether [is multi disc album folder] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [is multi disc album folder] [the specified path]; otherwise, <c>false</c>.</returns>
private static bool IsMultiDiscAlbumFolder(string path)
{ {
var parser = new AlbumParser(new ExtendedNamingOptions(), new Naming.Logging.NullLogger()); var parser = new AlbumParser(new ExtendedNamingOptions(), new Naming.Logging.NullLogger());
var result = parser.ParseMultiPart(path); var result = parser.ParseMultiPart(path);

View File

@ -4,6 +4,7 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using System; using System;
using System.IO; using System.IO;
using System.Linq;
namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
{ {
@ -24,6 +25,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
// Contains [boxset] in the path // Contains [boxset] in the path
if (args.IsDirectory) if (args.IsDirectory)
{ {
if (IsInvalid(args.GetCollectionType()))
{
return null;
}
var filename = Path.GetFileName(args.Path); var filename = Path.GetFileName(args.Path);
if (string.IsNullOrEmpty(filename)) if (string.IsNullOrEmpty(filename))
@ -45,6 +51,17 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
return null; return null;
} }
private bool IsInvalid(string collectionType)
{
var validCollectionTypes = new[]
{
CollectionType.Movies,
CollectionType.BoxSets
};
return !validCollectionTypes.Contains(collectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
}
/// <summary> /// <summary>
/// Sets the initial item values. /// Sets the initial item values.
/// </summary> /// </summary>

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers; using MediaBrowser.Controller.Resolvers;
@ -183,7 +182,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, collectionType); return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, collectionType);
} }
return FindMovie<Movie>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, collectionType); return FindMovie<Video>(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, collectionType);
} }
if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
@ -346,6 +345,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
{ {
var movie = (T)result.Items[0]; var movie = (T)result.Items[0];
movie.IsInMixedFolder = false; movie.IsInMixedFolder = false;
movie.Name = Path.GetFileName(movie.ContainingFolderPath);
return movie; return movie;
} }
@ -446,21 +446,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
} }
} }
// Don't do any resolving within a series structure
if (string.IsNullOrEmpty(collectionType))
{
if (HasParent<Series>(parent) || HasParent<Season>(parent))
{
return true;
}
// Since the looping is expensive, this is an optimization to help us avoid it
if (files.Select(i => i.Name).Contains("series.xml", StringComparer.OrdinalIgnoreCase))
{
return true;
}
}
var validCollectionTypes = new[] var validCollectionTypes = new[]
{ {
string.Empty, string.Empty,
@ -472,25 +457,5 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
return !validCollectionTypes.Contains(collectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase); return !validCollectionTypes.Contains(collectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
} }
private bool HasParent<T>(Folder parent)
where T : Folder
{
if (parent != null)
{
var item = parent as T;
// Just in case the user decided to nest episodes.
// Not officially supported but in some cases we can handle it.
if (item == null)
{
item = parent.Parents.OfType<T>().FirstOrDefault();
}
return item != null;
}
return false;
}
} }
} }

View File

@ -17,8 +17,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
protected override Photo Resolve(ItemResolveArgs args) protected override Photo Resolve(ItemResolveArgs args)
{ {
// Must be an image file within a photo collection // Must be an image file within a photo collection
if (!args.IsDirectory && if (string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase) &&
string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase) && !args.IsDirectory &&
IsImageFile(args.Path)) IsImageFile(args.Path))
{ {
return new Photo return new Photo

View File

@ -1,14 +1,8 @@
using MediaBrowser.Common.IO; using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers; using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Naming.Common;
using MediaBrowser.Naming.TV;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
@ -18,17 +12,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
/// </summary> /// </summary>
public class SeriesResolver : FolderResolver<Series> public class SeriesResolver : FolderResolver<Series>
{ {
private readonly IFileSystem _fileSystem;
private readonly ILogger _logger;
private readonly ILibraryManager _libraryManager;
public SeriesResolver(IFileSystem fileSystem, ILogger logger, ILibraryManager libraryManager)
{
_fileSystem = fileSystem;
_logger = logger;
_libraryManager = libraryManager;
}
/// <summary> /// <summary>
/// Gets the priority. /// Gets the priority.
/// </summary> /// </summary>
@ -50,27 +33,16 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
{ {
if (args.IsDirectory) if (args.IsDirectory)
{ {
// Avoid expensive tests against VF's and all their children by not allowing this
if (args.Parent.IsRoot)
{
return null;
}
var collectionType = args.GetCollectionType(); var collectionType = args.GetCollectionType();
// If there's a collection type and it's not tv, it can't be a series // If there's a collection type and it's not tv, it can't be a series
if (!string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
{
return null;
}
if (args.HasParent<Series>() || args.HasParent<Season>())
{
return null;
}
if (IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager))
{ {
if (args.HasParent<Series>())
{
return null;
}
return new Series return new Series
{ {
Path = args.Path, Path = args.Path,
@ -82,88 +54,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
return null; return null;
} }
/// <summary>
/// Determines whether [is series folder] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <param name="fileSystemChildren">The file system children.</param>
/// <param name="directoryService">The directory service.</param>
/// <param name="fileSystem">The file system.</param>
/// <param name="logger">The logger.</param>
/// <param name="libraryManager">The library manager.</param>
/// <returns><c>true</c> if [is series folder] [the specified path]; otherwise, <c>false</c>.</returns>
public static bool IsSeriesFolder(string path, IEnumerable<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService, IFileSystem fileSystem, ILogger logger, ILibraryManager libraryManager)
{
foreach (var child in fileSystemChildren)
{
var attributes = child.Attributes;
if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
//logger.Debug("Igoring series file or folder marked hidden: {0}", child.FullName);
continue;
}
// Can't enforce this because files saved by Bitcasa are always marked System
//if ((attributes & FileAttributes.System) == FileAttributes.System)
//{
// logger.Debug("Igoring series subfolder marked system: {0}", child.FullName);
// continue;
//}
if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
{
if (IsSeasonFolder(child.FullName))
{
//logger.Debug("{0} is a series because of season folder {1}.", path, child.FullName);
return true;
}
}
else
{
var fullName = child.FullName;
if (libraryManager.IsVideoFile(fullName) || IsVideoPlaceHolder(fullName))
{
return true;
}
}
}
logger.Debug("{0} is not a series folder.", path);
return false;
}
/// <summary>
/// Determines whether [is place holder] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [is place holder] [the specified path]; otherwise, <c>false</c>.</returns>
/// <exception cref="System.ArgumentNullException">path</exception>
private static bool IsVideoPlaceHolder(string path)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException("path");
}
var extension = Path.GetExtension(path);
return string.Equals(extension, ".disc", StringComparison.OrdinalIgnoreCase);
}
/// <summary>
/// Determines whether [is season folder] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [is season folder] [the specified path]; otherwise, <c>false</c>.</returns>
private static bool IsSeasonFolder(string path)
{
var seasonNumber = new SeasonPathParser(new ExtendedNamingOptions(), new RegexProvider()).Parse(path, true).SeasonNumber;
return seasonNumber.HasValue;
}
/// <summary> /// <summary>
/// Sets the initial item values. /// Sets the initial item values.
/// </summary> /// </summary>

View File

@ -860,6 +860,13 @@ namespace MediaBrowser.Server.Implementations.Library
private async Task UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent) private async Task UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent)
{ {
// The xml serializer will output differently if the type is not exact
if (userPolicy.GetType() != typeof(UserPolicy))
{
var json = _jsonSerializer.SerializeToString(userPolicy);
userPolicy = _jsonSerializer.DeserializeFromString<UserPolicy>(json);
}
var updateConfig = user.Policy.IsAdministrator != userPolicy.IsAdministrator || var updateConfig = user.Policy.IsAdministrator != userPolicy.IsAdministrator ||
user.Policy.EnableLiveTvManagement != userPolicy.EnableLiveTvManagement || user.Policy.EnableLiveTvManagement != userPolicy.EnableLiveTvManagement ||
user.Policy.EnableLiveTvAccess != userPolicy.EnableLiveTvAccess || user.Policy.EnableLiveTvAccess != userPolicy.EnableLiveTvAccess ||

View File

@ -420,7 +420,7 @@
"HeaderMediaLocations": "Media Locations", "HeaderMediaLocations": "Media Locations",
"LabelFolderTypeValue": "Folder type: {0}", "LabelFolderTypeValue": "Folder type: {0}",
"LabelPathSubstitutionHelp": "Optional: Path substitution can map server paths to network shares that clients can access for direct playback.", "LabelPathSubstitutionHelp": "Optional: Path substitution can map server paths to network shares that clients can access for direct playback.",
"FolderTypeMixed": "Mixed content", "FolderTypeUnset": "Unset (mixed content)",
"FolderTypeMovies": "Movies", "FolderTypeMovies": "Movies",
"FolderTypeMusic": "Music", "FolderTypeMusic": "Music",
"FolderTypeAdultVideos": "Adult videos", "FolderTypeAdultVideos": "Adult videos",
@ -660,5 +660,5 @@
"LabelItemLimitHelp": "Optional. Set a limit to the number of items that will be synced.", "LabelItemLimitHelp": "Optional. Set a limit to the number of items that will be synced.",
"MessageBookPluginRequired": "Requires installation of the Bookshelf plugin", "MessageBookPluginRequired": "Requires installation of the Bookshelf plugin",
"MessageGamePluginRequired": "Requires installation of the GameBrowser plugin", "MessageGamePluginRequired": "Requires installation of the GameBrowser plugin",
"MessageMixedContentHelp": "Content will be displayed as a plain folder structure" "MessageUnsetContentHelp": "Content will be displayed as plain folders. For best results use the metadata manager to set the content types of sub-folders."
} }

View File

@ -377,8 +377,8 @@
"LabelMaxScreenshotsPerItem": "Maximum number of screenshots per item:", "LabelMaxScreenshotsPerItem": "Maximum number of screenshots per item:",
"LabelMinBackdropDownloadWidth": "Minimum backdrop download width:", "LabelMinBackdropDownloadWidth": "Minimum backdrop download width:",
"LabelMinScreenshotDownloadWidth": "Minimum screenshot download width:", "LabelMinScreenshotDownloadWidth": "Minimum screenshot download width:",
"ButtonAddScheduledTaskTrigger": "Add Task Trigger", "ButtonAddScheduledTaskTrigger": "Add Trigger",
"HeaderAddScheduledTaskTrigger": "Add Task Trigger", "HeaderAddScheduledTaskTrigger": "Add Trigger",
"ButtonAdd": "Add", "ButtonAdd": "Add",
"LabelTriggerType": "Trigger Type:", "LabelTriggerType": "Trigger Type:",
"OptionDaily": "Daily", "OptionDaily": "Daily",

View File

@ -51,7 +51,7 @@
</Reference> </Reference>
<Reference Include="MediaBrowser.Naming, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="MediaBrowser.Naming, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.22\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath> <HintPath>..\packages\MediaBrowser.Naming.1.0.0.23\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
</Reference> </Reference>
<Reference Include="Mono.Nat, Version=1.2.21.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Mono.Nat, Version=1.2.21.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>

View File

@ -73,17 +73,6 @@ namespace MediaBrowser.Server.Implementations.Session
_logger.ErrorException("Error reporting session ended.", ex); _logger.ErrorException("Error reporting session ended.", ex);
} }
} }
else
{
var capabilities = new ClientCapabilities
{
PlayableMediaTypes = Session.PlayableMediaTypes,
SupportedCommands = Session.SupportedCommands,
SupportsMediaControl = SupportsMediaControl
};
_sessionManager.ReportCapabilities(Session.Id, capabilities);
}
} }
private IWebSocketConnection GetActiveSocket() private IWebSocketConnection GetActiveSocket()

View File

@ -316,35 +316,26 @@ namespace MediaBrowser.Server.Implementations.Sync
var video = item as Video; var video = item as Video;
if (video != null) if (video != null)
{ {
jobItem.OutputPath = await Sync(jobItem, video, deviceProfile, cancellationToken).ConfigureAwait(false); await Sync(jobItem, video, deviceProfile, cancellationToken).ConfigureAwait(false);
} }
else if (item is Audio) else if (item is Audio)
{ {
jobItem.OutputPath = await Sync(jobItem, (Audio)item, deviceProfile, cancellationToken).ConfigureAwait(false); await Sync(jobItem, (Audio)item, deviceProfile, cancellationToken).ConfigureAwait(false);
} }
else if (item is Photo) else if (item is Photo)
{ {
jobItem.OutputPath = await Sync(jobItem, (Photo)item, deviceProfile, cancellationToken).ConfigureAwait(false); await Sync(jobItem, (Photo)item, deviceProfile, cancellationToken).ConfigureAwait(false);
} }
else if (item is Game) else
{ {
jobItem.OutputPath = await Sync(jobItem, (Game)item, deviceProfile, cancellationToken).ConfigureAwait(false); await SyncGeneric(jobItem, item, deviceProfile, cancellationToken).ConfigureAwait(false);
} }
else if (item is Book)
{
jobItem.OutputPath = await Sync(jobItem, (Book)item, deviceProfile, cancellationToken).ConfigureAwait(false);
}
jobItem.Progress = 50;
jobItem.Status = SyncJobItemStatus.Transferring;
await _syncRepo.Update(jobItem).ConfigureAwait(false);
} }
private async Task<string> Sync(SyncJobItem jobItem, Video item, DeviceProfile profile, CancellationToken cancellationToken) private async Task Sync(SyncJobItem jobItem, Video item, DeviceProfile profile, CancellationToken cancellationToken)
{ {
var options = new VideoOptions var options = new VideoOptions
{ {
@ -359,26 +350,33 @@ namespace MediaBrowser.Server.Implementations.Sync
var mediaSource = streamInfo.MediaSource; var mediaSource = streamInfo.MediaSource;
jobItem.MediaSourceId = streamInfo.MediaSourceId; jobItem.MediaSourceId = streamInfo.MediaSourceId;
await _syncRepo.Update(jobItem).ConfigureAwait(false);
if (streamInfo.PlayMethod != PlayMethod.Transcode) if (streamInfo.PlayMethod == PlayMethod.Transcode)
{
await _syncRepo.Update(jobItem).ConfigureAwait(false);
}
else
{ {
if (mediaSource.Protocol == MediaProtocol.File) if (mediaSource.Protocol == MediaProtocol.File)
{ {
return mediaSource.Path; jobItem.OutputPath = mediaSource.Path;
} }
if (mediaSource.Protocol == MediaProtocol.Http) if (mediaSource.Protocol == MediaProtocol.Http)
{ {
return await DownloadFile(jobItem, mediaSource, cancellationToken).ConfigureAwait(false); jobItem.OutputPath = await DownloadFile(jobItem, mediaSource, cancellationToken).ConfigureAwait(false);
} }
throw new InvalidOperationException(string.Format("Cannot direct stream {0} protocol", mediaSource.Protocol)); throw new InvalidOperationException(string.Format("Cannot direct stream {0} protocol", mediaSource.Protocol));
} }
// TODO: Transcode // TODO: Transcode
return mediaSource.Path; jobItem.OutputPath = mediaSource.Path;
jobItem.Progress = 50;
jobItem.Status = SyncJobItemStatus.Transferring;
await _syncRepo.Update(jobItem).ConfigureAwait(false);
} }
private async Task<string> Sync(SyncJobItem jobItem, Audio item, DeviceProfile profile, CancellationToken cancellationToken) private async Task Sync(SyncJobItem jobItem, Audio item, DeviceProfile profile, CancellationToken cancellationToken)
{ {
var options = new AudioOptions var options = new AudioOptions
{ {
@ -393,38 +391,48 @@ namespace MediaBrowser.Server.Implementations.Sync
var mediaSource = streamInfo.MediaSource; var mediaSource = streamInfo.MediaSource;
jobItem.MediaSourceId = streamInfo.MediaSourceId; jobItem.MediaSourceId = streamInfo.MediaSourceId;
await _syncRepo.Update(jobItem).ConfigureAwait(false);
if (streamInfo.PlayMethod != PlayMethod.Transcode) if (streamInfo.PlayMethod == PlayMethod.Transcode)
{
await _syncRepo.Update(jobItem).ConfigureAwait(false);
}
else
{ {
if (mediaSource.Protocol == MediaProtocol.File) if (mediaSource.Protocol == MediaProtocol.File)
{ {
return mediaSource.Path; jobItem.OutputPath = mediaSource.Path;
} }
if (mediaSource.Protocol == MediaProtocol.Http) if (mediaSource.Protocol == MediaProtocol.Http)
{ {
return await DownloadFile(jobItem, mediaSource, cancellationToken).ConfigureAwait(false); jobItem.OutputPath = await DownloadFile(jobItem, mediaSource, cancellationToken).ConfigureAwait(false);
} }
throw new InvalidOperationException(string.Format("Cannot direct stream {0} protocol", mediaSource.Protocol)); throw new InvalidOperationException(string.Format("Cannot direct stream {0} protocol", mediaSource.Protocol));
} }
// TODO: Transcode // TODO: Transcode
return mediaSource.Path; jobItem.OutputPath = mediaSource.Path;
jobItem.Progress = 50;
jobItem.Status = SyncJobItemStatus.Transferring;
await _syncRepo.Update(jobItem).ConfigureAwait(false);
} }
private async Task<string> Sync(SyncJobItem jobItem, Photo item, DeviceProfile profile, CancellationToken cancellationToken) private async Task Sync(SyncJobItem jobItem, Photo item, DeviceProfile profile, CancellationToken cancellationToken)
{ {
return item.Path; jobItem.OutputPath = item.Path;
jobItem.Progress = 50;
jobItem.Status = SyncJobItemStatus.Transferring;
await _syncRepo.Update(jobItem).ConfigureAwait(false);
} }
private async Task<string> Sync(SyncJobItem jobItem, Game item, DeviceProfile profile, CancellationToken cancellationToken) private async Task SyncGeneric(SyncJobItem jobItem, BaseItem item, DeviceProfile profile, CancellationToken cancellationToken)
{ {
return item.Path; jobItem.OutputPath = item.Path;
}
private async Task<string> Sync(SyncJobItem jobItem, Book item, DeviceProfile profile, CancellationToken cancellationToken) jobItem.Progress = 50;
{ jobItem.Status = SyncJobItemStatus.Transferring;
return item.Path; await _syncRepo.Update(jobItem).ConfigureAwait(false);
} }
private async Task<string> DownloadFile(SyncJobItem jobItem, MediaSourceInfo mediaSource, CancellationToken cancellationToken) private async Task<string> DownloadFile(SyncJobItem jobItem, MediaSourceInfo mediaSource, CancellationToken cancellationToken)

View File

@ -1,5 +1,4 @@
using System.IO; using MediaBrowser.Common;
using MediaBrowser.Common;
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
@ -20,6 +19,7 @@ using MediaBrowser.Model.Users;
using MoreLinq; using MoreLinq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -337,7 +337,19 @@ namespace MediaBrowser.Server.Implementations.Sync
UserId = job.UserId UserId = job.UserId
}; };
syncedItem.Item = _dtoService().GetBaseItemDto(libraryItem, new DtoOptions()); var dtoOptions = new DtoOptions();
// Remove some bloat
dtoOptions.Fields.Remove(ItemFields.MediaStreams);
dtoOptions.Fields.Remove(ItemFields.IndexOptions);
dtoOptions.Fields.Remove(ItemFields.MediaSourceCount);
dtoOptions.Fields.Remove(ItemFields.OriginalPrimaryImageAspectRatio);
dtoOptions.Fields.Remove(ItemFields.Path);
dtoOptions.Fields.Remove(ItemFields.SeriesGenres);
dtoOptions.Fields.Remove(ItemFields.Settings);
dtoOptions.Fields.Remove(ItemFields.SyncInfo);
syncedItem.Item = _dtoService().GetBaseItemDto(libraryItem, dtoOptions);
// TODO: this should be the media source of the transcoded output // TODO: this should be the media source of the transcoded output
syncedItem.Item.MediaSources = syncedItem.Item.MediaSources syncedItem.Item.MediaSources = syncedItem.Item.MediaSources
@ -370,10 +382,11 @@ namespace MediaBrowser.Server.Implementations.Sync
var jobItemResult = GetJobItems(new SyncJobItemQuery var jobItemResult = GetJobItems(new SyncJobItemQuery
{ {
TargetId = targetId, TargetId = targetId,
//Status = SyncJobItemStatus.Transferring Status = SyncJobItemStatus.Transferring
}); });
return jobItemResult.Items.Select(GetJobItemInfo).ToList(); return jobItemResult.Items.Select(GetJobItemInfo)
.ToList();
} }
} }
} }

View File

@ -227,7 +227,7 @@ namespace MediaBrowser.Server.Implementations.Sync
_saveJobCommand.GetParameter(index++).Value = job.TargetId; _saveJobCommand.GetParameter(index++).Value = job.TargetId;
_saveJobCommand.GetParameter(index++).Value = job.Name; _saveJobCommand.GetParameter(index++).Value = job.Name;
_saveJobCommand.GetParameter(index++).Value = job.Quality; _saveJobCommand.GetParameter(index++).Value = job.Quality;
_saveJobCommand.GetParameter(index++).Value = job.Status; _saveJobCommand.GetParameter(index++).Value = job.Status.ToString();
_saveJobCommand.GetParameter(index++).Value = job.Progress; _saveJobCommand.GetParameter(index++).Value = job.Progress;
_saveJobCommand.GetParameter(index++).Value = job.UserId; _saveJobCommand.GetParameter(index++).Value = job.UserId;
_saveJobCommand.GetParameter(index++).Value = string.Join(",", job.RequestedItemIds.ToArray()); _saveJobCommand.GetParameter(index++).Value = string.Join(",", job.RequestedItemIds.ToArray());
@ -466,13 +466,14 @@ namespace MediaBrowser.Server.Implementations.Sync
whereClauses.Add("TargetId=@TargetId"); whereClauses.Add("TargetId=@TargetId");
cmd.Parameters.Add(cmd, "@TargetId", DbType.String).Value = query.TargetId; cmd.Parameters.Add(cmd, "@TargetId", DbType.String).Value = query.TargetId;
} }
if (query.Status.HasValue) if (query.Status.HasValue)
{ {
whereClauses.Add("Status=@Status"); whereClauses.Add("Status=@Status");
cmd.Parameters.Add(cmd, "@Status", DbType.String).Value = query.Status.Value.ToString(); cmd.Parameters.Add(cmd, "@Status", DbType.String).Value = query.Status.Value.ToString();
} }
if (query.IsCompleted.HasValue) else if (query.IsCompleted.HasValue)
{ {
if (query.IsCompleted.Value) if (query.IsCompleted.Value)
{ {
@ -561,7 +562,7 @@ namespace MediaBrowser.Server.Implementations.Sync
_saveJobItemCommand.GetParameter(index++).Value = jobItem.MediaSourceId; _saveJobItemCommand.GetParameter(index++).Value = jobItem.MediaSourceId;
_saveJobItemCommand.GetParameter(index++).Value = jobItem.JobId; _saveJobItemCommand.GetParameter(index++).Value = jobItem.JobId;
_saveJobItemCommand.GetParameter(index++).Value = jobItem.OutputPath; _saveJobItemCommand.GetParameter(index++).Value = jobItem.OutputPath;
_saveJobItemCommand.GetParameter(index++).Value = jobItem.Status; _saveJobItemCommand.GetParameter(index++).Value = jobItem.Status.ToString();
_saveJobItemCommand.GetParameter(index++).Value = jobItem.TargetId; _saveJobItemCommand.GetParameter(index++).Value = jobItem.TargetId;
_saveJobItemCommand.GetParameter(index++).Value = jobItem.DateCreated; _saveJobItemCommand.GetParameter(index++).Value = jobItem.DateCreated;
_saveJobItemCommand.GetParameter(index++).Value = jobItem.Progress; _saveJobItemCommand.GetParameter(index++).Value = jobItem.Progress;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MediaBrowser.Naming" version="1.0.0.21" targetFramework="net45" /> <package id="MediaBrowser.Naming" version="1.0.0.23" targetFramework="net45" />
<package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" /> <package id="Mono.Nat" version="1.2.21.0" targetFramework="net45" />
<package id="morelinq" version="1.1.0" targetFramework="net45" /> <package id="morelinq" version="1.1.0" targetFramework="net45" />
</packages> </packages>

View File

@ -131,10 +131,6 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\ThirdParty\libgdiplus\osx\libgdiplus.dylib">
<Link>libgdiplus.dylib</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\ThirdParty\libwebp\osx\libwebp.5.dylib"> <None Include="..\ThirdParty\libwebp\osx\libwebp.5.dylib">
<Link>libwebp\osx\libwebp.5.dylib</Link> <Link>libwebp\osx\libwebp.5.dylib</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>