Skip to content

Commit

Permalink
Solve most code style warnings
Browse files Browse the repository at this point in the history
Skipped "Member ... does not access instance data and can be marked as static" when future non-static use is expected.
Skipped some switch statements which will be filled in.
  • Loading branch information
Kevinjil committed Jan 9, 2025
1 parent efd50cb commit fe01107
Show file tree
Hide file tree
Showing 17 changed files with 306 additions and 557 deletions.
85 changes: 31 additions & 54 deletions Jellyfin.Xtream/Api/XtreamController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,15 @@ namespace Jellyfin.Xtream.Api;
[Produces(MediaTypeNames.Application.Json)]
public class XtreamController : ControllerBase
{
private readonly ILogger<XtreamController> logger;

/// <summary>
/// Initializes a new instance of the <see cref="XtreamController"/> class.
/// </summary>
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
public XtreamController(ILogger<XtreamController> logger)
{
this.logger = logger;
}

private static CategoryResponse CreateCategoryResponse(Category category) =>
new CategoryResponse()
new()
{
Id = category.CategoryId,
Name = category.CategoryName,
};

private static ItemResponse CreateItemResponse(StreamInfo stream) =>
new ItemResponse()
new()
{
Id = stream.StreamId,
Name = stream.Name,
Expand All @@ -63,7 +52,7 @@ private static ItemResponse CreateItemResponse(StreamInfo stream) =>
};

private static ItemResponse CreateItemResponse(Series series) =>
new ItemResponse()
new()
{
Id = series.SeriesId,
Name = series.Name,
Expand All @@ -72,7 +61,7 @@ private static ItemResponse CreateItemResponse(Series series) =>
};

private static ChannelResponse CreateChannelResponse(StreamInfo stream) =>
new ChannelResponse()
new()
{
Id = stream.StreamId,
LogoUrl = stream.StreamIcon,
Expand All @@ -90,11 +79,9 @@ private static ChannelResponse CreateChannelResponse(StreamInfo stream) =>
public async Task<ActionResult<IEnumerable<CategoryResponse>>> GetLiveCategories(CancellationToken cancellationToken)
{
Plugin plugin = Plugin.Instance;
using (XtreamClient client = new XtreamClient())
{
List<Category> categories = await client.GetLiveCategoryAsync(plugin.Creds, cancellationToken).ConfigureAwait(false);
return Ok(categories.Select((Category c) => CreateCategoryResponse(c)));
}
using XtreamClient client = new XtreamClient();
List<Category> categories = await client.GetLiveCategoryAsync(plugin.Creds, cancellationToken).ConfigureAwait(false);
return Ok(categories.Select(CreateCategoryResponse));
}

/// <summary>
Expand All @@ -108,14 +95,12 @@ public async Task<ActionResult<IEnumerable<CategoryResponse>>> GetLiveCategories
public async Task<ActionResult<IEnumerable<StreamInfo>>> GetLiveStreams(int categoryId, CancellationToken cancellationToken)
{
Plugin plugin = Plugin.Instance;
using (XtreamClient client = new XtreamClient())
{
List<StreamInfo> streams = await client.GetLiveStreamsByCategoryAsync(
plugin.Creds,
categoryId,
cancellationToken).ConfigureAwait(false);
return Ok(streams.Select((StreamInfo s) => CreateItemResponse(s)));
}
using XtreamClient client = new XtreamClient();
List<StreamInfo> streams = await client.GetLiveStreamsByCategoryAsync(
plugin.Creds,
categoryId,
cancellationToken).ConfigureAwait(false);
return Ok(streams.Select(CreateItemResponse));
}

/// <summary>
Expand All @@ -128,11 +113,9 @@ public async Task<ActionResult<IEnumerable<StreamInfo>>> GetLiveStreams(int cate
public async Task<ActionResult<IEnumerable<CategoryResponse>>> GetVodCategories(CancellationToken cancellationToken)
{
Plugin plugin = Plugin.Instance;
using (XtreamClient client = new XtreamClient())
{
List<Category> categories = await client.GetVodCategoryAsync(plugin.Creds, cancellationToken).ConfigureAwait(false);
return Ok(categories.Select((Category c) => CreateCategoryResponse(c)));
}
using XtreamClient client = new XtreamClient();
List<Category> categories = await client.GetVodCategoryAsync(plugin.Creds, cancellationToken).ConfigureAwait(false);
return Ok(categories.Select(CreateCategoryResponse));
}

/// <summary>
Expand All @@ -146,14 +129,12 @@ public async Task<ActionResult<IEnumerable<CategoryResponse>>> GetVodCategories(
public async Task<ActionResult<IEnumerable<StreamInfo>>> GetVodStreams(int categoryId, CancellationToken cancellationToken)
{
Plugin plugin = Plugin.Instance;
using (XtreamClient client = new XtreamClient())
{
List<StreamInfo> streams = await client.GetVodStreamsByCategoryAsync(
plugin.Creds,
categoryId,
cancellationToken).ConfigureAwait(false);
return Ok(streams.Select((StreamInfo s) => CreateItemResponse(s)));
}
using XtreamClient client = new XtreamClient();
List<StreamInfo> streams = await client.GetVodStreamsByCategoryAsync(
plugin.Creds,
categoryId,
cancellationToken).ConfigureAwait(false);
return Ok(streams.Select(CreateItemResponse));
}

/// <summary>
Expand All @@ -166,11 +147,9 @@ public async Task<ActionResult<IEnumerable<StreamInfo>>> GetVodStreams(int categ
public async Task<ActionResult<IEnumerable<CategoryResponse>>> GetSeriesCategories(CancellationToken cancellationToken)
{
Plugin plugin = Plugin.Instance;
using (XtreamClient client = new XtreamClient())
{
List<Category> categories = await client.GetSeriesCategoryAsync(plugin.Creds, cancellationToken).ConfigureAwait(false);
return Ok(categories.Select((Category c) => CreateCategoryResponse(c)));
}
using XtreamClient client = new XtreamClient();
List<Category> categories = await client.GetSeriesCategoryAsync(plugin.Creds, cancellationToken).ConfigureAwait(false);
return Ok(categories.Select(CreateCategoryResponse));
}

/// <summary>
Expand All @@ -184,14 +163,12 @@ public async Task<ActionResult<IEnumerable<CategoryResponse>>> GetSeriesCategori
public async Task<ActionResult<IEnumerable<StreamInfo>>> GetSeriesStreams(int categoryId, CancellationToken cancellationToken)
{
Plugin plugin = Plugin.Instance;
using (XtreamClient client = new XtreamClient())
{
List<Series> series = await client.GetSeriesByCategoryAsync(
plugin.Creds,
categoryId,
cancellationToken).ConfigureAwait(false);
return Ok(series.Select((Series s) => CreateItemResponse(s)));
}
using XtreamClient client = new XtreamClient();
List<Series> series = await client.GetSeriesByCategoryAsync(
plugin.Creds,
categoryId,
cancellationToken).ConfigureAwait(false);
return Ok(series.Select(CreateItemResponse));
}

/// <summary>
Expand Down
Loading

0 comments on commit fe01107

Please sign in to comment.