rename channel category to channel folder

This commit is contained in:
Luke Pulverenti 2014-05-23 10:09:58 -04:00
parent 28e754767a
commit 40836f194b
15 changed files with 49 additions and 30 deletions

View File

@ -41,7 +41,7 @@ namespace MediaBrowser.Api
{ {
public string Id { get; set; } public string Id { get; set; }
public string CategoryId { get; set; } public string FolderId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the user id. /// Gets or sets the user id.
@ -120,7 +120,7 @@ namespace MediaBrowser.Api
StartIndex = request.StartIndex, StartIndex = request.StartIndex,
UserId = request.UserId, UserId = request.UserId,
ChannelId = request.Id, ChannelId = request.Id,
CategoryId = request.CategoryId, FolderId = request.FolderId,
SortOrder = request.SortOrder, SortOrder = request.SortOrder,
SortBy = (request.SortBy ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(), SortBy = (request.SortBy ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(),
Filters = request.GetFilters().ToArray() Filters = request.GetFilters().ToArray()

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using ServiceStack; using ServiceStack;

View File

@ -53,5 +53,10 @@ namespace MediaBrowser.Controller.Channels
return base.LocationType; return base.LocationType;
} }
} }
public override string GetClientTypeName()
{
return "audio.channelItem";
}
} }
} }

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace MediaBrowser.Controller.Channels namespace MediaBrowser.Controller.Channels
{ {
public class ChannelCategoryItem : Folder, IChannelItem public class ChannelFolderItem : Folder, IChannelItem
{ {
public string ExternalId { get; set; } public string ExternalId { get; set; }
@ -29,9 +29,14 @@ namespace MediaBrowser.Controller.Channels
} }
} }
public ChannelCategoryItem() public ChannelFolderItem()
{ {
Tags = new List<string>(); Tags = new List<string>();
} }
public override string GetClientTypeName()
{
return "folder.channelItem";
}
} }
} }

View File

@ -4,6 +4,6 @@
{ {
Media = 0, Media = 0,
Category = 1 Folder = 1
} }
} }

View File

@ -77,5 +77,10 @@ namespace MediaBrowser.Controller.Channels
return base.LocationType; return base.LocationType;
} }
} }
public override string GetClientTypeName()
{
return "video.channelItem";
}
} }
} }

View File

@ -4,7 +4,7 @@ namespace MediaBrowser.Controller.Channels
{ {
public class InternalChannelItemQuery public class InternalChannelItemQuery
{ {
public string CategoryId { get; set; } public string FolderId { get; set; }
public User User { get; set; } public User User { get; set; }

View File

@ -68,7 +68,7 @@
<Compile Include="..\SharedVersion.cs"> <Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link> <Link>Properties\SharedVersion.cs</Link>
</Compile> </Compile>
<Compile Include="Channels\ChannelCategoryItem.cs" /> <Compile Include="Channels\ChannelFolderItem.cs" />
<Compile Include="Channels\ChannelItemInfo.cs" /> <Compile Include="Channels\ChannelItemInfo.cs" />
<Compile Include="Channels\ChannelItemResult.cs" /> <Compile Include="Channels\ChannelItemResult.cs" />
<Compile Include="Channels\ChannelItemType.cs" /> <Compile Include="Channels\ChannelItemType.cs" />

View File

@ -15,7 +15,7 @@ namespace MediaBrowser.Model.Channels
/// Gets or sets the category identifier. /// Gets or sets the category identifier.
/// </summary> /// </summary>
/// <value>The category identifier.</value> /// <value>The category identifier.</value>
public string CategoryId { get; set; } public string FolderId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the user identifier. /// Gets or sets the user identifier.

View File

@ -4,6 +4,8 @@
{ {
Audio = 0, Audio = 0,
Video = 1 Video = 1,
Photo = 2
} }
} }

View File

@ -278,7 +278,7 @@ namespace MediaBrowser.Server.Implementations.Channels
? null ? null
: _userManager.GetUserById(new Guid(query.UserId)); : _userManager.GetUserById(new Guid(query.UserId));
var itemsResult = await GetChannelItems(channelProvider, user, query.CategoryId, providerStartIndex, providerLimit, cancellationToken) var itemsResult = await GetChannelItems(channelProvider, user, query.FolderId, providerStartIndex, providerLimit, cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false);
var providerTotalRecordCount = providerLimit.HasValue ? itemsResult.TotalRecordCount : null; var providerTotalRecordCount = providerLimit.HasValue ? itemsResult.TotalRecordCount : null;
@ -301,9 +301,9 @@ namespace MediaBrowser.Server.Implementations.Channels
} }
private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1); private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1);
private async Task<ChannelItemResult> GetChannelItems(IChannel channel, User user, string categoryId, int? startIndex, int? limit, CancellationToken cancellationToken) private async Task<ChannelItemResult> GetChannelItems(IChannel channel, User user, string folderId, int? startIndex, int? limit, CancellationToken cancellationToken)
{ {
var cachePath = GetChannelDataCachePath(channel, user, categoryId); var cachePath = GetChannelDataCachePath(channel, user, folderId);
try try
{ {
@ -358,11 +358,11 @@ namespace MediaBrowser.Server.Implementations.Channels
Limit = limit Limit = limit
}; };
if (!string.IsNullOrWhiteSpace(categoryId)) if (!string.IsNullOrWhiteSpace(folderId))
{ {
var categoryItem = (IChannelItem)_libraryManager.GetItemById(new Guid(categoryId)); var categoryItem = (IChannelItem)_libraryManager.GetItemById(new Guid(folderId));
query.CategoryId = categoryItem.ExternalId; query.FolderId = categoryItem.ExternalId;
} }
var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false); var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false);
@ -394,15 +394,15 @@ namespace MediaBrowser.Server.Implementations.Channels
} }
} }
private string GetChannelDataCachePath(IChannel channel, User user, string categoryId) private string GetChannelDataCachePath(IChannel channel, User user, string folderId)
{ {
var channelId = GetInternalChannelId(channel.Name).ToString("N"); var channelId = GetInternalChannelId(channel.Name).ToString("N");
var categoryKey = string.IsNullOrWhiteSpace(categoryId) ? "root" : categoryId.GetMD5().ToString("N"); var folderKey = string.IsNullOrWhiteSpace(folderId) ? "root" : folderId.GetMD5().ToString("N");
var version = string.IsNullOrWhiteSpace(channel.DataVersion) ? "0" : channel.DataVersion; var version = string.IsNullOrWhiteSpace(channel.DataVersion) ? "0" : channel.DataVersion;
return Path.Combine(_config.ApplicationPaths.CachePath, "channels", channelId, version, categoryKey, user.Id.ToString("N") + ".json"); return Path.Combine(_config.ApplicationPaths.CachePath, "channels", channelId, version, folderKey, user.Id.ToString("N") + ".json");
} }
private async Task<QueryResult<BaseItemDto>> GetReturnItems(IEnumerable<BaseItem> items, int? totalCountFromProvider, User user, ChannelItemQuery query, CancellationToken cancellationToken) private async Task<QueryResult<BaseItemDto>> GetReturnItems(IEnumerable<BaseItem> items, int? totalCountFromProvider, User user, ChannelItemQuery query, CancellationToken cancellationToken)
@ -448,7 +448,7 @@ namespace MediaBrowser.Server.Implementations.Channels
{ {
// Increment this as needed to force new downloads // Increment this as needed to force new downloads
// Incorporate Name because it's being used to convert channel entity to provider // Incorporate Name because it's being used to convert channel entity to provider
return externalId + (channelProvider.DataVersion ?? string.Empty) + (channelProvider.Name ?? string.Empty) + "11"; return externalId + (channelProvider.DataVersion ?? string.Empty) + (channelProvider.Name ?? string.Empty) + "12";
} }
private async Task<BaseItem> GetChannelItemEntity(ChannelItemInfo info, IChannel channelProvider, Channel internalChannel, CancellationToken cancellationToken) private async Task<BaseItem> GetChannelItemEntity(ChannelItemInfo info, IChannel channelProvider, Channel internalChannel, CancellationToken cancellationToken)
@ -459,21 +459,21 @@ namespace MediaBrowser.Server.Implementations.Channels
var idToHash = GetIdToHash(info.Id, channelProvider); var idToHash = GetIdToHash(info.Id, channelProvider);
if (info.Type == ChannelItemType.Category) if (info.Type == ChannelItemType.Folder)
{ {
id = idToHash.GetMBId(typeof(ChannelCategoryItem)); id = idToHash.GetMBId(typeof(ChannelFolderItem));
item = _libraryManager.GetItemById(id) as ChannelCategoryItem; item = _libraryManager.GetItemById(id) as ChannelFolderItem;
if (item == null) if (item == null)
{ {
isNew = true; isNew = true;
item = new ChannelCategoryItem(); item = new ChannelFolderItem();
} }
} }
else if (info.MediaType == ChannelMediaType.Audio) else if (info.MediaType == ChannelMediaType.Audio)
{ {
id = idToHash.GetMBId(typeof(ChannelCategoryItem)); id = idToHash.GetMBId(typeof(ChannelFolderItem));
item = _libraryManager.GetItemById(id) as ChannelAudioItem; item = _libraryManager.GetItemById(id) as ChannelAudioItem;

View File

@ -172,6 +172,9 @@
<Content Include="dashboard-ui\css\images\items\folders\edit.png"> <Content Include="dashboard-ui\css\images\items\folders\edit.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="dashboard-ui\css\images\items\folders\home.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\css\images\items\folders\report.png"> <Content Include="dashboard-ui\css\images\items\folders\report.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common.Internal</id> <id>MediaBrowser.Common.Internal</id>
<version>3.0.372</version> <version>3.0.374</version>
<title>MediaBrowser.Common.Internal</title> <title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors> <authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners> <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> <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> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.372" /> <dependency id="MediaBrowser.Common" version="3.0.374" />
<dependency id="NLog" version="2.1.0" /> <dependency id="NLog" version="2.1.0" />
<dependency id="SimpleInjector" version="2.5.0" /> <dependency id="SimpleInjector" version="2.5.0" />
<dependency id="sharpcompress" version="0.10.2" /> <dependency id="sharpcompress" version="0.10.2" />

View File

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

View File

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