sync updates

This commit is contained in:
Luke Pulverenti 2014-12-24 01:28:40 -05:00
parent 381aa7adc5
commit 36577ac42e
15 changed files with 73 additions and 49 deletions

View File

@ -729,7 +729,8 @@ namespace MediaBrowser.Api.Playback
return Math.Min(request.MaxAudioChannels.Value, audioStream.Channels.Value);
}
return request.MaxAudioChannels.Value;
// If we don't have any media info then limit it to 5 to prevent encoding errors due to asking for too many channels
return Math.Min(request.MaxAudioChannels.Value, 5);
}
return request.AudioChannels;

View File

@ -66,6 +66,22 @@ namespace MediaBrowser.Controller.Entities
return CreateResolveArgs(directoryService).FileSystemChildren;
}
internal override bool IsValidFromResolver(BaseItem newItem)
{
var newCollectionFolder = newItem as CollectionFolder;
if (newCollectionFolder != null)
{
if (!string.Equals(CollectionType, newCollectionFolder.CollectionType, StringComparison.OrdinalIgnoreCase))
{
return false;
}
}
return base.IsValidFromResolver(newItem);
}
private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService)
{
var path = ContainingFolderPath;

View File

@ -25,4 +25,9 @@ namespace MediaBrowser.Controller.Sync
/// <returns>DeviceProfile.</returns>
DeviceProfile GetDeviceProfile(SyncTarget target);
}
public interface IHasUniqueTargetIds
{
}
}

View File

@ -1,7 +1,6 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;

View File

@ -649,7 +649,7 @@ namespace MediaBrowser.LocalMetadata.Savers
var hasShares = item as IHasShares;
if (hasShares != null)
{
AddShares(hasShares, builder);
}
}

View File

@ -1043,6 +1043,9 @@
<Compile Include="..\MediaBrowser.Model\Sync\SyncDialogOptions.cs">
<Link>Sync\SyncDialogOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncHelper.cs">
<Link>Sync\SyncHelper.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncItem.cs">
<Link>Sync\SyncItem.cs</Link>
</Compile>

View File

@ -1002,6 +1002,9 @@
<Compile Include="..\MediaBrowser.Model\Sync\SyncDialogOptions.cs">
<Link>Sync\SyncDialogOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncHelper.cs">
<Link>Sync\SyncHelper.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncItem.cs">
<Link>Sync\SyncItem.cs</Link>
</Compile>

View File

@ -374,9 +374,17 @@ namespace MediaBrowser.Model.Dlna
MediaStream stream = TargetAudioStream;
int? streamChannels = stream == null ? null : stream.Channels;
return MaxAudioChannels.HasValue && !IsDirectStream
? (streamChannels.HasValue ? Math.Min(MaxAudioChannels.Value, streamChannels.Value) : MaxAudioChannels.Value)
: streamChannels;
if (MaxAudioChannels.HasValue && !IsDirectStream)
{
if (streamChannels.HasValue)
{
return Math.Min(MaxAudioChannels.Value, streamChannels.Value);
}
return MaxAudioChannels.Value;
}
return streamChannels;
}
}

View File

@ -1,17 +1,15 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Naming.Common;
using MediaBrowser.Naming.TV;
using System;
using System.Collections.Generic;
using System.IO;
using MediaBrowser.Naming.Common;
using MediaBrowser.Naming.IO;
using MediaBrowser.Naming.TV;
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
{
@ -60,10 +58,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
var collectionType = args.GetCollectionType();
var isTvShowsFolder = string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase);
// If there's a collection type and it's not tv, it can't be a series
if (!isTvShowsFolder)
if (!string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
{
return null;
}
@ -73,7 +69,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
return null;
}
if (IsSeriesFolder(args.Path, collectionType, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager))
if (IsSeriesFolder(args.Path, args.FileSystemChildren, args.DirectoryService, _fileSystem, _logger, _libraryManager))
{
return new Series
{
@ -90,14 +86,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
/// Determines whether [is series folder] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <param name="collectionType">Type of the collection.</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, string collectionType, IEnumerable<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService, IFileSystem fileSystem, ILogger logger, ILibraryManager libraryManager)
public static bool IsSeriesFolder(string path, IEnumerable<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService, IFileSystem fileSystem, ILogger logger, ILibraryManager libraryManager)
{
foreach (var child in fileSystemChildren)
{
@ -118,7 +113,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
{
if (IsSeasonFolder(child.FullName, collectionType))
if (IsSeasonFolder(child.FullName))
{
//logger.Debug("{0} is a series because of season folder {1}.", path, child.FullName);
return true;
@ -130,22 +125,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
if (libraryManager.IsVideoFile(fullName) || IsVideoPlaceHolder(fullName))
{
var isTvShowsFolder = string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase);
// We can fast track this for known tv folders
if (isTvShowsFolder)
{
return true;
}
var resolver = new Naming.TV.EpisodeResolver(new ExtendedNamingOptions(), new Naming.Logging.NullLogger());
var episodeInfo = resolver.Resolve(fullName, FileInfoType.File, isTvShowsFolder, false);
if (episodeInfo != null && (episodeInfo.EpisodeNumber.HasValue || episodeInfo.IsByDate))
{
return true;
}
return true;
}
}
}
@ -176,12 +156,10 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
/// Determines whether [is season folder] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <param name="collectionType">Type of the collection.</param>
/// <returns><c>true</c> if [is season folder] [the specified path]; otherwise, <c>false</c>.</returns>
private static bool IsSeasonFolder(string path, string collectionType)
private static bool IsSeasonFolder(string path)
{
var isTvFolder = string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase);
var seasonNumber = new SeasonPathParser(new ExtendedNamingOptions(), new RegexProvider()).Parse(path, isTvFolder).SeasonNumber;
var seasonNumber = new SeasonPathParser(new ExtendedNamingOptions(), new RegexProvider()).Parse(path, true).SeasonNumber;
return seasonNumber.HasValue;
}

View File

@ -8,7 +8,7 @@ using System.Linq;
namespace MediaBrowser.Server.Implementations.Sync
{
public class AppSyncProvider : ISyncProvider
public class AppSyncProvider : ISyncProvider, IHasUniqueTargetIds
{
private readonly IDeviceManager _deviceManager;

View File

@ -69,7 +69,12 @@ namespace MediaBrowser.Server.Implementations.Sync
}
var target = GetSyncTargets(request.UserId)
.First(i => string.Equals(request.TargetId, i.Id));
.FirstOrDefault(i => string.Equals(request.TargetId, i.Id));
if (target == null)
{
throw new ArgumentException("Sync target not found.");
}
var jobId = Guid.NewGuid().ToString("N");
@ -173,17 +178,23 @@ namespace MediaBrowser.Server.Implementations.Sync
private IEnumerable<SyncTarget> GetSyncTargets(ISyncProvider provider, string userId)
{
var providerId = GetSyncProviderId(provider);
return provider.GetSyncTargets().Select(i => new SyncTarget
{
Name = i.Name,
Id = GetSyncTargetId(providerId, i)
Id = GetSyncTargetId(provider, i)
});
}
private string GetSyncTargetId(string providerId, SyncTarget target)
private string GetSyncTargetId(ISyncProvider provider, SyncTarget target)
{
var hasUniqueId = provider as IHasUniqueTargetIds;
if (hasUniqueId != null)
{
return target.Id;
}
var providerId = GetSyncProviderId(provider);
return (providerId + "-" + target.Id).GetMD5().ToString("N");
}

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.522</version>
<version>3.0.523</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.522" />
<dependency id="MediaBrowser.Common" version="3.0.523" />
<dependency id="NLog" version="3.1.0.0" />
<dependency id="SimpleInjector" version="2.6.1" />
<dependency id="sharpcompress" version="0.10.2" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.522</version>
<version>3.0.523</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Model.Signed</id>
<version>3.0.522</version>
<version>3.0.523</version>
<title>MediaBrowser.Model - Signed Edition</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.522</version>
<version>3.0.523</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.522" />
<dependency id="MediaBrowser.Common" version="3.0.523" />
</dependencies>
</metadata>
<files>