@ -162,9 +162,9 @@ namespace MediaBrowser.Server.Implementations.Channels
var channelGuid = new Guid ( item . ChannelId ) ;
var channel = _channelEntities . First ( i = > i . Id = = channelGuid ) ;
var internalChannel = _channels . First ( i = > string . Equals ( i . Name , channel . OriginalChannelName , StringComparison . OrdinalIgnoreCase ) ) ;
var channelPlugin = GetChannelProvider ( channel ) ;
var requiresCallback = internalChannel as IRequiresMediaInfoCallback ;
var requiresCallback = channelPlugin as IRequiresMediaInfoCallback ;
if ( requiresCallback ! = null )
{
@ -264,7 +264,9 @@ namespace MediaBrowser.Server.Implementations.Channels
var channelId = channel . Id . ToString ( "N" ) ;
var tasks = items . Select ( i = > GetChannelItemEntity ( i , channelId , cancellationToken ) ) ;
var channelPlugin = GetChannelProvider ( channel ) ;
var tasks = items . Select ( i = > GetChannelItemEntity ( i , channelPlugin , channelId , cancellationToken ) ) ;
return await Task . WhenAll ( tasks ) . ConfigureAwait ( false ) ;
} ) ;
@ -363,7 +365,9 @@ namespace MediaBrowser.Server.Implementations.Channels
var categoryKey = string . IsNullOrWhiteSpace ( categoryId ) ? "root" : categoryId . GetMD5 ( ) . ToString ( "N" ) ;
return Path . Combine ( _config . ApplicationPaths . CachePath , "channels" , channelId , categoryKey , user . Id . ToString ( "N" ) + ".json" ) ;
var version = string . IsNullOrWhiteSpace ( channel . DataVersion ) ? "0" : channel . DataVersion ;
return Path . Combine ( _config . ApplicationPaths . CachePath , "channels" , channelId , version , categoryKey , user . Id . ToString ( "N" ) + ".json" ) ;
}
private async Task < QueryResult < BaseItemDto > > GetReturnItems ( IEnumerable < BaseItem > items , User user , ChannelItemQuery query , CancellationToken cancellationToken )
@ -401,13 +405,14 @@ namespace MediaBrowser.Server.Implementations.Channels
} ;
}
private string GetIdToHash ( string externalId )
private string GetIdToHash ( string externalId , IChannel channelProvider )
{
// Increment this as needed to force new downloads
return externalId + "8" ;
// Incorporate Name because it's being used to convert channel entity to provider
return externalId + ( channelProvider . DataVersion ? ? string . Empty ) + ( channelProvider . Name ? ? string . Empty ) + "11" ;
}
private async Task < BaseItem > GetChannelItemEntity ( ChannelItemInfo info , string internalChannnelId , CancellationToken cancellationToken )
private async Task < BaseItem > GetChannelItemEntity ( ChannelItemInfo info , IChannel channelProvider , string internalChannnelId , CancellationToken cancellationToken )
{
if ( string . IsNullOrEmpty ( internalChannnelId ) )
{
@ -418,9 +423,11 @@ namespace MediaBrowser.Server.Implementations.Channels
Guid id ;
var isNew = false ;
var idToHash = GetIdToHash ( info . Id , channelProvider ) ;
if ( info . Type = = ChannelItemType . Category )
{
id = GetIdToHash( info . Id ) . GetMBId ( typeof ( ChannelCategoryItem ) ) ;
id = idToHash . GetMBId ( typeof ( ChannelCategoryItem ) ) ;
item = _libraryManager . GetItemById ( id ) as ChannelCategoryItem ;
@ -432,7 +439,7 @@ namespace MediaBrowser.Server.Implementations.Channels
}
else if ( info . MediaType = = ChannelMediaType . Audio )
{
id = GetIdToHash( info . Id ) . GetMBId ( typeof ( ChannelCategoryItem ) ) ;
id = idToHash . GetMBId ( typeof ( ChannelCategoryItem ) ) ;
item = _libraryManager . GetItemById ( id ) as ChannelAudioItem ;
@ -444,7 +451,7 @@ namespace MediaBrowser.Server.Implementations.Channels
}
else
{
id = GetIdToHash( info . Id ) . GetMBId ( typeof ( ChannelVideoItem ) ) ;
id = idToHash . GetMBId ( typeof ( ChannelVideoItem ) ) ;
item = _libraryManager . GetItemById ( id ) as ChannelVideoItem ;