Fix code quality scanning issue #146
@@ -203,12 +203,8 @@ public class XtreamController : ControllerBase
|
||||
[HttpGet("LiveTv")]
|
||||
public async Task<ActionResult<IEnumerable<StreamInfo>>> GetLiveTvChannels(CancellationToken cancellationToken)
|
||||
{
|
||||
List<ChannelResponse> channels = new List<ChannelResponse>();
|
||||
await foreach (StreamInfo stream in Plugin.Instance.StreamService.GetLiveStreams(cancellationToken))
|
||||
{
|
||||
channels.Add(CreateChannelResponse(stream));
|
||||
}
|
||||
|
||||
IEnumerable<StreamInfo> streams = await Plugin.Instance.StreamService.GetLiveStreams(cancellationToken).ConfigureAwait(false);
|
||||
var channels = streams.Select(CreateChannelResponse).ToList();
|
||||
return Ok(channels);
|
||||
}
|
||||
}
|
||||
|
@@ -129,7 +129,7 @@ public class CatchupChannel : IChannel
|
||||
{
|
||||
Plugin plugin = Plugin.Instance;
|
||||
List<ChannelItemInfo> items = new List<ChannelItemInfo>();
|
||||
await foreach (StreamInfo channel in plugin.StreamService.GetLiveStreamsWithOverrides(cancellationToken))
|
||||
foreach (StreamInfo channel in await plugin.StreamService.GetLiveStreamsWithOverrides(cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
if (!channel.TvArchive)
|
||||
{
|
||||
|
@@ -68,7 +68,7 @@ public class LiveTvService : ILiveTvService, ISupportsDirectStreamProvider
|
||||
{
|
||||
Plugin plugin = Plugin.Instance;
|
||||
List<ChannelInfo> items = new List<ChannelInfo>();
|
||||
await foreach (StreamInfo channel in plugin.StreamService.GetLiveStreamsWithOverrides(cancellationToken))
|
||||
foreach (StreamInfo channel in await plugin.StreamService.GetLiveStreamsWithOverrides(cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
ParsedName parsed = StreamService.ParseName(channel.Name);
|
||||
items.Add(new ChannelInfo()
|
||||
|
@@ -169,24 +169,18 @@ public class StreamService
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>IAsyncEnumerable{StreamInfo}.</returns>
|
||||
public async IAsyncEnumerable<StreamInfo> GetLiveStreams([EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
public async Task<IEnumerable<StreamInfo>> GetLiveStreams(CancellationToken cancellationToken)
|
||||
{
|
||||
PluginConfiguration config = plugin.Configuration;
|
||||
using (XtreamClient client = new XtreamClient())
|
||||
{
|
||||
foreach (var entry in config.LiveTv)
|
||||
{
|
||||
int categoryId = entry.Key;
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
using XtreamClient client = new XtreamClient();
|
||||
|
||||
IEnumerable<StreamInfo> channels = await client.GetLiveStreamsByCategoryAsync(plugin.Creds, categoryId, cancellationToken).ConfigureAwait(false);
|
||||
foreach (StreamInfo channel in channels.Where((StreamInfo channel) => IsConfigured(config.LiveTv, categoryId, channel.StreamId)))
|
||||
{
|
||||
// If the set is empty, include all channels for the category.
|
||||
yield return channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
IEnumerable<Task<IEnumerable<StreamInfo>>> tasks = config.LiveTv.Select(async (entry) =>
|
||||
{
|
||||
int categoryId = entry.Key;
|
||||
var streams = await client.GetLiveStreamsByCategoryAsync(plugin.Creds, categoryId, cancellationToken).ConfigureAwait(false);
|
||||
return streams.Where((StreamInfo channel) => IsConfigured(config.LiveTv, categoryId, channel.StreamId));
|
||||
});
|
||||
return (await Task.WhenAll(tasks).ConfigureAwait(false)).SelectMany(i => i);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -194,10 +188,11 @@ public class StreamService
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>IAsyncEnumerable{StreamInfo}.</returns>
|
||||
public async IAsyncEnumerable<StreamInfo> GetLiveStreamsWithOverrides([EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
public async Task<IEnumerable<StreamInfo>> GetLiveStreamsWithOverrides(CancellationToken cancellationToken)
|
||||
{
|
||||
PluginConfiguration config = Plugin.Instance.Configuration;
|
||||
await foreach (StreamInfo stream in GetLiveStreams(cancellationToken))
|
||||
IEnumerable<StreamInfo> streams = await GetLiveStreams(cancellationToken).ConfigureAwait(false);
|
||||
return streams.Select((StreamInfo stream) =>
|
||||
{
|
||||
if (config.LiveTvOverrides.TryGetValue(stream.StreamId, out ChannelOverrides? overrides))
|
||||
{
|
||||
@@ -206,8 +201,8 @@ public class StreamService
|
||||
stream.StreamIcon = overrides.LogoUrl ?? stream.StreamIcon;
|
||||
}
|
||||
|
||||
yield return stream;
|
||||
}
|
||||
return stream;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user