update tag saving
This commit is contained in:
parent
85c508bcd1
commit
ae168bc563
|
@ -80,7 +80,7 @@ namespace MediaBrowser.Api
|
||||||
.OrderBy(i => i)
|
.OrderBy(i => i)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
result.Tags = items.OfType<IHasTags>()
|
result.Tags = items
|
||||||
.SelectMany(i => i.Tags)
|
.SelectMany(i => i.Tags)
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
.OrderBy(i => i)
|
.OrderBy(i => i)
|
||||||
|
|
|
@ -280,11 +280,7 @@ namespace MediaBrowser.Api
|
||||||
episode.AbsoluteEpisodeNumber = request.AbsoluteEpisodeNumber;
|
episode.AbsoluteEpisodeNumber = request.AbsoluteEpisodeNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasTags = item as IHasTags;
|
item.Tags = request.Tags;
|
||||||
if (hasTags != null)
|
|
||||||
{
|
|
||||||
hasTags.Tags = request.Tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
var hasTaglines = item as IHasTaglines;
|
var hasTaglines = item as IHasTaglines;
|
||||||
if (hasTaglines != null)
|
if (hasTaglines != null)
|
||||||
|
|
|
@ -116,13 +116,7 @@ namespace MediaBrowser.Api
|
||||||
|
|
||||||
private static IEnumerable<string> GetTags(BaseItem item)
|
private static IEnumerable<string> GetTags(BaseItem item)
|
||||||
{
|
{
|
||||||
var hasTags = item as IHasTags;
|
return item.Tags;
|
||||||
if (hasTags != null)
|
|
||||||
{
|
|
||||||
return hasTags.Tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new List<string>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<string> GetKeywords(BaseItem item)
|
private static IEnumerable<string> GetKeywords(BaseItem item)
|
||||||
|
|
|
@ -333,12 +333,7 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
var tags = request.GetTags();
|
var tags = request.GetTags();
|
||||||
if (tags.Length > 0)
|
if (tags.Length > 0)
|
||||||
{
|
{
|
||||||
var hasTags = i as IHasTags;
|
if (!tags.Any(v => i.Tags.Contains(v, StringComparer.OrdinalIgnoreCase)))
|
||||||
if (hasTags == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!tags.Any(v => hasTags.Tags.Contains(v, StringComparer.OrdinalIgnoreCase)))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||||
IHasArtist,
|
IHasArtist,
|
||||||
IHasMusicGenres,
|
IHasMusicGenres,
|
||||||
IHasLookupInfo<SongInfo>,
|
IHasLookupInfo<SongInfo>,
|
||||||
IHasTags,
|
|
||||||
IHasMediaSources,
|
IHasMediaSources,
|
||||||
IThemeMedia,
|
IThemeMedia,
|
||||||
IArchivable
|
IArchivable
|
||||||
|
|
|
@ -1397,15 +1397,10 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
private bool IsVisibleViaTags(User user)
|
private bool IsVisibleViaTags(User user)
|
||||||
{
|
{
|
||||||
var hasTags = this as IHasTags;
|
var policy = user.Policy;
|
||||||
|
if (policy.BlockedTags.Any(i => Tags.Contains(i, StringComparer.OrdinalIgnoreCase)))
|
||||||
if (hasTags != null)
|
|
||||||
{
|
{
|
||||||
var policy = user.Policy;
|
return false;
|
||||||
if (policy.BlockedTags.Any(i => hasTags.Tags.Contains(i, StringComparer.OrdinalIgnoreCase)))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -6,7 +6,7 @@ using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
public class Book : BaseItem, IHasTags, IHasLookupInfo<BookInfo>, IHasSeries
|
public class Book : BaseItem, IHasLookupInfo<BookInfo>, IHasSeries
|
||||||
{
|
{
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public override string MediaType
|
public override string MediaType
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class Folder
|
/// Class Folder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Folder : BaseItem, IHasThemeMedia, IHasTags
|
public class Folder : BaseItem, IHasThemeMedia
|
||||||
{
|
{
|
||||||
public static IUserManager UserManager { get; set; }
|
public static IUserManager UserManager { get; set; }
|
||||||
public static IUserViewManager UserViewManager { get; set; }
|
public static IUserViewManager UserViewManager { get; set; }
|
||||||
|
|
|
@ -7,7 +7,7 @@ using System.Linq;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
public class Game : BaseItem, IHasTrailers, IHasThemeMedia, IHasTags, IHasScreenshots, ISupportsPlaceHolders, IHasLookupInfo<GameInfo>
|
public class Game : BaseItem, IHasTrailers, IHasThemeMedia, IHasScreenshots, ISupportsPlaceHolders, IHasLookupInfo<GameInfo>
|
||||||
{
|
{
|
||||||
public List<Guid> ThemeSongIds { get; set; }
|
public List<Guid> ThemeSongIds { get; set; }
|
||||||
public List<Guid> ThemeVideoIds { get; set; }
|
public List<Guid> ThemeVideoIds { get; set; }
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
public class Photo : BaseItem, IHasTags, IHasTaglines
|
public class Photo : BaseItem, IHasTaglines
|
||||||
{
|
{
|
||||||
public List<string> Taglines { get; set; }
|
public List<string> Taglines { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class Studio
|
/// Class Studio
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Studio : BaseItem, IItemByName, IHasTags
|
public class Studio : BaseItem, IItemByName
|
||||||
{
|
{
|
||||||
public override List<string> GetUserDataKeys()
|
public override List<string> GetUserDataKeys()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,24 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Interface IHasTags
|
|
||||||
/// </summary>
|
|
||||||
public interface IHasTags
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the tags.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The tags.</value>
|
|
||||||
List<string> Tags { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TagExtensions
|
public static class TagExtensions
|
||||||
{
|
{
|
||||||
public static void AddTag(this IHasTags item, string name)
|
public static void AddTag(this BaseItem item, string name)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
{
|
{
|
|
@ -1646,12 +1646,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
var tags = query.Tags;
|
var tags = query.Tags;
|
||||||
if (tags.Length > 0)
|
if (tags.Length > 0)
|
||||||
{
|
{
|
||||||
var hasTags = item as IHasTags;
|
if (!tags.Any(v => item.Tags.Contains(v, StringComparer.OrdinalIgnoreCase)))
|
||||||
if (hasTags == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!tags.Any(v => hasTags.Tags.Contains(v, StringComparer.OrdinalIgnoreCase)))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Video : BaseItem,
|
public class Video : BaseItem,
|
||||||
IHasAspectRatio,
|
IHasAspectRatio,
|
||||||
IHasTags,
|
|
||||||
ISupportsPlaceHolders,
|
ISupportsPlaceHolders,
|
||||||
IHasMediaSources,
|
IHasMediaSources,
|
||||||
IHasShortOverview,
|
IHasShortOverview,
|
||||||
|
|
|
@ -154,7 +154,6 @@
|
||||||
<Compile Include="Entities\IHasSpecialFeatures.cs" />
|
<Compile Include="Entities\IHasSpecialFeatures.cs" />
|
||||||
<Compile Include="Entities\IHasStartDate.cs" />
|
<Compile Include="Entities\IHasStartDate.cs" />
|
||||||
<Compile Include="Entities\IHasTaglines.cs" />
|
<Compile Include="Entities\IHasTaglines.cs" />
|
||||||
<Compile Include="Entities\IHasTags.cs" />
|
|
||||||
<Compile Include="Entities\IHasThemeMedia.cs" />
|
<Compile Include="Entities\IHasThemeMedia.cs" />
|
||||||
<Compile Include="Entities\IHasTrailers.cs" />
|
<Compile Include="Entities\IHasTrailers.cs" />
|
||||||
<Compile Include="Entities\IHasUserData.cs" />
|
<Compile Include="Entities\IHasUserData.cs" />
|
||||||
|
@ -177,6 +176,7 @@
|
||||||
<Compile Include="Entities\PhotoAlbum.cs" />
|
<Compile Include="Entities\PhotoAlbum.cs" />
|
||||||
<Compile Include="Entities\Share.cs" />
|
<Compile Include="Entities\Share.cs" />
|
||||||
<Compile Include="Entities\SourceType.cs" />
|
<Compile Include="Entities\SourceType.cs" />
|
||||||
|
<Compile Include="Entities\TagExtensions.cs" />
|
||||||
<Compile Include="Entities\UserView.cs" />
|
<Compile Include="Entities\UserView.cs" />
|
||||||
<Compile Include="Entities\UserViewBuilder.cs" />
|
<Compile Include="Entities\UserViewBuilder.cs" />
|
||||||
<Compile Include="FileOrganization\IFileOrganizationService.cs" />
|
<Compile Include="FileOrganization\IFileOrganizationService.cs" />
|
||||||
|
|
|
@ -803,11 +803,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
{
|
{
|
||||||
using (var subtree = reader.ReadSubtree())
|
using (var subtree = reader.ReadSubtree())
|
||||||
{
|
{
|
||||||
var hasTags = item as IHasTags;
|
FetchFromTagsNode(subtree, item);
|
||||||
if (hasTags != null)
|
|
||||||
{
|
|
||||||
FetchFromTagsNode(subtree, hasTags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1066,7 +1062,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FetchFromTagsNode(XmlReader reader, IHasTags item)
|
private void FetchFromTagsNode(XmlReader reader, BaseItem item)
|
||||||
{
|
{
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
|
||||||
|
|
|
@ -593,20 +593,16 @@ namespace MediaBrowser.LocalMetadata.Savers
|
||||||
builder.Append("</Studios>");
|
builder.Append("</Studios>");
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasTags = item as IHasTags;
|
if (item.Tags.Count > 0)
|
||||||
if (hasTags != null)
|
|
||||||
{
|
{
|
||||||
if (hasTags.Tags.Count > 0)
|
builder.Append("<Tags>");
|
||||||
|
|
||||||
|
foreach (var tag in item.Tags)
|
||||||
{
|
{
|
||||||
builder.Append("<Tags>");
|
builder.Append("<Tag>" + SecurityElement.Escape(tag) + "</Tag>");
|
||||||
|
|
||||||
foreach (var tag in hasTags.Tags)
|
|
||||||
{
|
|
||||||
builder.Append("<Tag>" + SecurityElement.Escape(tag) + "</Tag>");
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.Append("</Tags>");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
builder.Append("</Tags>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Keywords.Count > 0)
|
if (item.Keywords.Count > 0)
|
||||||
|
|
|
@ -151,15 +151,9 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
if (!lockedFields.Contains(MetadataFields.Tags))
|
if (!lockedFields.Contains(MetadataFields.Tags))
|
||||||
{
|
{
|
||||||
var sourceHasTags = source as IHasTags;
|
if (replaceData || target.Tags.Count == 0)
|
||||||
var targetHasTags = target as IHasTags;
|
|
||||||
|
|
||||||
if (sourceHasTags != null && targetHasTags != null)
|
|
||||||
{
|
{
|
||||||
if (replaceData || targetHasTags.Tags.Count == 0)
|
target.Tags = source.Tags;
|
||||||
{
|
|
||||||
targetHasTags.Tags = sourceHasTags.Tags;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -969,16 +969,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
|
|
||||||
if (fields.Contains(ItemFields.Tags))
|
if (fields.Contains(ItemFields.Tags))
|
||||||
{
|
{
|
||||||
var hasTags = item as IHasTags;
|
dto.Tags = item.Tags;
|
||||||
if (hasTags != null)
|
|
||||||
{
|
|
||||||
dto.Tags = hasTags.Tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dto.Tags == null)
|
|
||||||
{
|
|
||||||
dto.Tags = new List<string>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields.Contains(ItemFields.Keywords))
|
if (fields.Contains(ItemFields.Keywords))
|
||||||
|
|
|
@ -919,11 +919,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
||||||
var val = reader.ReadElementContentAsString();
|
var val = reader.ReadElementContentAsString();
|
||||||
if (!string.IsNullOrWhiteSpace(val))
|
if (!string.IsNullOrWhiteSpace(val))
|
||||||
{
|
{
|
||||||
var hasTags = item as IHasTags;
|
item.AddTag(val);
|
||||||
if (hasTags != null)
|
|
||||||
{
|
|
||||||
hasTags.AddTag(val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -736,19 +736,15 @@ namespace MediaBrowser.XbmcMetadata.Savers
|
||||||
writer.WriteElementString("studio", studio);
|
writer.WriteElementString("studio", studio);
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasTags = item as IHasTags;
|
foreach (var tag in item.Tags)
|
||||||
if (hasTags != null)
|
|
||||||
{
|
{
|
||||||
foreach (var tag in hasTags.Tags)
|
if (item is MusicAlbum || item is MusicArtist)
|
||||||
{
|
{
|
||||||
if (item is MusicAlbum || item is MusicArtist)
|
writer.WriteElementString("style", tag);
|
||||||
{
|
}
|
||||||
writer.WriteElementString("style", tag);
|
else
|
||||||
}
|
{
|
||||||
else
|
writer.WriteElementString("tag", tag);
|
||||||
{
|
|
||||||
writer.WriteElementString("tag", tag);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user