Access last element by index where possible

pull/4478/head
Bond_009 4 years ago
parent 9041389f65
commit c4bb32f259
No known key found for this signature in database
GPG Key ID: 63AB4E6262A96A87

@ -83,7 +83,7 @@ namespace Emby.Dlna.Eventing
if (!string.IsNullOrEmpty(header)) if (!string.IsNullOrEmpty(header))
{ {
// Starts with SECOND- // Starts with SECOND-
header = header.Split('-').Last(); header = header.Split('-')[^1];
if (int.TryParse(header, NumberStyles.Integer, _usCulture, out var val)) if (int.TryParse(header, NumberStyles.Integer, _usCulture, out var val))
{ {

@ -182,7 +182,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
if (string.IsNullOrEmpty(currentFile)) if (string.IsNullOrEmpty(currentFile))
{ {
return (files.Last(), true); return (files[^1], true);
} }
var nextIndex = files.FindIndex(i => string.Equals(i, currentFile, StringComparison.OrdinalIgnoreCase)) + 1; var nextIndex = files.FindIndex(i => string.Equals(i, currentFile, StringComparison.OrdinalIgnoreCase)) + 1;

@ -163,7 +163,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
private string GetChannelNumber(string extInf, Dictionary<string, string> attributes, string mediaUrl) private string GetChannelNumber(string extInf, Dictionary<string, string> attributes, string mediaUrl)
{ {
var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var nameParts = extInf.Split(',', StringSplitOptions.RemoveEmptyEntries);
var nameInExtInf = nameParts.Length > 1 ? nameParts[^1].AsSpan().Trim() : ReadOnlySpan<char>.Empty; var nameInExtInf = nameParts.Length > 1 ? nameParts[^1].AsSpan().Trim() : ReadOnlySpan<char>.Empty;
string numberString = null; string numberString = null;
@ -273,8 +273,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
private static string GetChannelName(string extInf, Dictionary<string, string> attributes) private static string GetChannelName(string extInf, Dictionary<string, string> attributes)
{ {
var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var nameParts = extInf.Split(',', StringSplitOptions.RemoveEmptyEntries);
var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null; var nameInExtInf = nameParts.Length > 1 ? nameParts[^1].Trim() : null;
// Check for channel number with the format from SatIp // Check for channel number with the format from SatIp
// #EXTINF:0,84. VOX Schweiz // #EXTINF:0,84. VOX Schweiz

@ -249,7 +249,7 @@ namespace Jellyfin.Api.Controllers
{ {
var httpClient = _httpClientFactory.CreateClient(NamedClient.Default); var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
using var response = await httpClient.GetAsync(url).ConfigureAwait(false); using var response = await httpClient.GetAsync(url).ConfigureAwait(false);
var ext = response.Content.Headers.ContentType.MediaType.Split('/').Last(); var ext = response.Content.Headers.ContentType.MediaType.Split('/')[^1];
var fullCachePath = GetFullCachePath(urlHash + "." + ext); var fullCachePath = GetFullCachePath(urlHash + "." + ext);
Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath)); Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));

@ -84,7 +84,7 @@ namespace Jellyfin.Api.Helpers
streamingRequest.StreamOptions = ParseStreamOptions(httpRequest.Query); streamingRequest.StreamOptions = ParseStreamOptions(httpRequest.Query);
var url = httpRequest.Path.Value.Split('.').Last(); var url = httpRequest.Path.Value.Split('.')[^1];
if (string.IsNullOrEmpty(streamingRequest.AudioCodec)) if (string.IsNullOrEmpty(streamingRequest.AudioCodec))
{ {

@ -352,7 +352,7 @@ namespace MediaBrowser.Providers.Subtitles
var parts = id.Split('_', 2); var parts = id.Split('_', 2);
var provider = GetProvider(parts[0]); var provider = GetProvider(parts[0]);
id = parts[1]; id = parts[^1];
return provider.GetSubtitles(id, cancellationToken); return provider.GetSubtitles(id, cancellationToken);
} }

Loading…
Cancel
Save