channel fixes

This commit is contained in:
Luke Pulverenti
2014-05-18 15:58:42 -04:00
parent ca5989cb17
commit 3ccecd3ca3
39 changed files with 287 additions and 1121 deletions

View File

@@ -98,7 +98,7 @@ namespace MediaBrowser.Server.Implementations.Channels
{
all = all.Take(query.Limit.Value).ToList();
}
// Get everything
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
@@ -156,6 +156,23 @@ namespace MediaBrowser.Server.Implementations.Channels
progress.Report(100);
}
public Task<IEnumerable<ChannelMediaInfo>> GetChannelItemMediaSources(string id, CancellationToken cancellationToken)
{
var item = (IChannelMediaItem)_libraryManager.GetItemById(id);
var channelGuid = new Guid(item.ChannelId);
var channel = _channelEntities.First(i => i.Id == channelGuid);
var requiresCallback = channel as IRequiresMediaInfoCallback;
if (requiresCallback != null)
{
return requiresCallback.GetChannelItemMediaInfo(item.ExternalId, cancellationToken);
}
return Task.FromResult<IEnumerable<ChannelMediaInfo>>(item.ChannelMediaSources);
}
private async Task<Channel> GetChannel(IChannel channelInfo, CancellationToken cancellationToken)
{
var path = Path.Combine(_config.ApplicationPaths.ItemsByNamePath, "channels", _fileSystem.GetValidFilename(channelInfo.Name));
@@ -303,10 +320,16 @@ namespace MediaBrowser.Server.Implementations.Channels
var query = new InternalChannelItemQuery
{
User = user,
CategoryId = categoryId
User = user
};
if (!string.IsNullOrWhiteSpace(categoryId))
{
var categoryItem = (IChannelItem)_libraryManager.GetItemById(new Guid(categoryId));
query.CategoryId = categoryItem.ExternalId;
}
var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false);
CacheResponse(result, cachePath);
@@ -380,7 +403,7 @@ namespace MediaBrowser.Server.Implementations.Channels
private string GetIdToHash(string externalId)
{
// Increment this as needed to force new downloads
return externalId + "4";
return externalId + "7";
}
private async Task<BaseItem> GetChannelItemEntity(ChannelItemInfo info, string internalChannnelId, CancellationToken cancellationToken)
@@ -434,10 +457,6 @@ namespace MediaBrowser.Server.Implementations.Channels
item.Id = id;
item.RunTimeTicks = info.RunTimeTicks;
var mediaSource = info.MediaSources.FirstOrDefault();
item.Path = mediaSource == null ? null : mediaSource.Path;
if (isNew)
{
item.Name = info.Name;
@@ -464,12 +483,22 @@ namespace MediaBrowser.Server.Implementations.Channels
channelItem.ChannelId = internalChannnelId;
channelItem.ChannelItemType = info.Type;
if (isNew)
{
channelItem.Tags = info.Tags;
}
var channelMediaItem = item as IChannelMediaItem;
if (channelMediaItem != null)
{
channelMediaItem.IsInfiniteStream = info.IsInfiniteStream;
channelMediaItem.ContentType = info.ContentType;
channelMediaItem.ChannelMediaSources = info.MediaSources;
var mediaSource = info.MediaSources.FirstOrDefault();
item.Path = mediaSource == null ? null : mediaSource.Path;
}
if (isNew)