fixed for new collection creation

This commit is contained in:
Luke Pulverenti 2015-04-26 00:39:40 -04:00
parent a7b32d4ec0
commit 6562824a84
8 changed files with 94 additions and 12 deletions

View File

@ -62,12 +62,15 @@ namespace MediaBrowser.Api.Movies
public async Task<object> Post(CreateCollection request) public async Task<object> Post(CreateCollection request)
{ {
var userId = AuthorizationContext.GetAuthorizationInfo(Request).UserId;
var item = await _collectionManager.CreateCollection(new CollectionCreationOptions var item = await _collectionManager.CreateCollection(new CollectionCreationOptions
{ {
IsLocked = request.IsLocked, IsLocked = request.IsLocked,
Name = request.Name, Name = request.Name,
ParentId = request.ParentId, ParentId = request.ParentId,
ItemIdList = (request.Ids ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => new Guid(i)).ToList() ItemIdList = (request.Ids ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => new Guid(i)).ToList(),
UserIds = new List<Guid> { new Guid(userId) }
}).ConfigureAwait(false); }).ConfigureAwait(false);

View File

@ -1426,6 +1426,46 @@ namespace MediaBrowser.Controller.Providers
return null; return null;
} }
protected Share GetShare(XmlReader reader)
{
reader.MoveToContent();
var item = new Share();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "UserId":
{
item.UserId = reader.ReadElementContentAsString();
break;
}
case "CanEdit":
{
item.CanEdit = string.Equals(reader.ReadElementContentAsString(), "true", StringComparison.OrdinalIgnoreCase);
break;
}
default:
reader.Skip();
break;
}
}
}
// This is valid
if (!string.IsNullOrWhiteSpace(item.UserId))
{
return item;
}
return null;
}
/// <summary> /// <summary>
/// Used to split names of comma or pipe delimeted genres and people /// Used to split names of comma or pipe delimeted genres and people

View File

@ -50,6 +50,14 @@ namespace MediaBrowser.LocalMetadata.Parsers
} }
break; break;
case "Shares":
using (var subReader = reader.ReadSubtree())
{
FetchFromSharesNode(subReader, item);
}
break;
default: default:
base.FetchDataFromXmlNode(reader, item); base.FetchDataFromXmlNode(reader, item);
break; break;
@ -92,5 +100,42 @@ namespace MediaBrowser.LocalMetadata.Parsers
item.LinkedChildren = list; item.LinkedChildren = list;
} }
private void FetchFromSharesNode(XmlReader reader, Playlist item)
{
reader.MoveToContent();
var list = new List<Share>();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "Share":
{
using (var subReader = reader.ReadSubtree())
{
var child = GetShare(subReader);
if (child != null)
{
list.Add(child);
}
}
break;
}
default:
reader.Skip();
break;
}
}
}
item.Shares = list;
}
} }
} }

View File

@ -38,10 +38,6 @@ namespace MediaBrowser.Providers.BoxSets
list.AddRange(target.LinkedChildren.Where(i => i.Type == LinkedChildType.Manual)); list.AddRange(target.LinkedChildren.Where(i => i.Type == LinkedChildType.Manual));
target.LinkedChildren = list; target.LinkedChildren = list;
}
if (replaceData || target.Shares.Count == 0)
{
target.Shares = source.Shares; target.Shares = source.Shares;
} }
} }

View File

@ -33,14 +33,10 @@ namespace MediaBrowser.Providers.Playlists
target.PlaylistMediaType = source.PlaylistMediaType; target.PlaylistMediaType = source.PlaylistMediaType;
} }
if (replaceData || target.Shares.Count == 0)
{
target.Shares = source.Shares;
}
if (mergeMetadataSettings) if (mergeMetadataSettings)
{ {
target.LinkedChildren = source.LinkedChildren; target.LinkedChildren = source.LinkedChildren;
target.Shares = source.Shares;
} }
} }
} }

View File

@ -81,7 +81,8 @@ namespace MediaBrowser.Server.Implementations.Collections
ProviderIds = options.ProviderIds, ProviderIds = options.ProviderIds,
Shares = options.UserIds.Select(i => new Share Shares = options.UserIds.Select(i => new Share
{ {
UserId = i.ToString("N") UserId = i.ToString("N"),
CanEdit = true
}).ToList() }).ToList()
}; };

View File

@ -803,6 +803,7 @@
"LabelMaxBitrateHelp": "Specify a max bitrate in bandwidth constrained environments, or if the device imposes it's own limit.", "LabelMaxBitrateHelp": "Specify a max bitrate in bandwidth constrained environments, or if the device imposes it's own limit.",
"LabelMaxStreamingBitrate": "Max streaming bitrate:", "LabelMaxStreamingBitrate": "Max streaming bitrate:",
"LabelMaxStreamingBitrateHelp": "Specify a max bitrate when streaming.", "LabelMaxStreamingBitrateHelp": "Specify a max bitrate when streaming.",
"LabelMaxChromecastBitrate": "Max Chromecast bitrate:",
"LabelMaxStaticBitrate": "Max sync bitrate:", "LabelMaxStaticBitrate": "Max sync bitrate:",
"LabelMaxStaticBitrateHelp": "Specify a max bitrate when syncing content at high quality.", "LabelMaxStaticBitrateHelp": "Specify a max bitrate when syncing content at high quality.",
"LabelMusicStaticBitrate": "Music sync bitrate:", "LabelMusicStaticBitrate": "Music sync bitrate:",

View File

@ -18,7 +18,7 @@ using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.UserViews namespace MediaBrowser.Server.Implementations.UserViews
{ {
public class DynamicImageProvider : BaseDynamicImageProvider<UserView>, IPreRefreshProvider public class DynamicImageProvider : BaseDynamicImageProvider<UserView>
{ {
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;