Implement various suggestions
This commit is contained in:
parent
e1958e3902
commit
81b4a4c54c
|
@ -484,9 +484,9 @@ namespace MediaBrowser.Api
|
|||
/// <returns>Task.</returns>
|
||||
internal Task KillTranscodingJobs(string deviceId, string playSessionId, Func<string, bool> deleteFiles)
|
||||
{
|
||||
return KillTranscodingJobs(j => !string.IsNullOrWhiteSpace(playSessionId)
|
||||
? string.Equals(playSessionId, j.PlaySessionId, StringComparison.OrdinalIgnoreCase)
|
||||
: string.Equals(deviceId, j.DeviceId, StringComparison.OrdinalIgnoreCase), deleteFiles);
|
||||
return KillTranscodingJobs(j => string.IsNullOrWhiteSpace(playSessionId)
|
||||
? string.Equals(deviceId, j.DeviceId, StringComparison.OrdinalIgnoreCase)
|
||||
: string.Equals(playSessionId, j.PlaySessionId, StringComparison.OrdinalIgnoreCase), deleteFiles);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -117,8 +117,8 @@ namespace MediaBrowser.Api
|
|||
var val = Filters;
|
||||
|
||||
return string.IsNullOrEmpty(val)
|
||||
? new ItemFilter[] { }
|
||||
: val.Split(',').Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true));
|
||||
? Array.Empty<ItemFilter>()
|
||||
: val.Split(',').Select(v => Enum.Parse<ItemFilter>(v, true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -170,11 +170,9 @@ namespace MediaBrowser.Api
|
|||
/// <returns>IEnumerable{ItemFilter}.</returns>
|
||||
public IEnumerable<ItemFilter> GetFilters()
|
||||
{
|
||||
var val = Filters;
|
||||
|
||||
return string.IsNullOrEmpty(val)
|
||||
? new ItemFilter[] { }
|
||||
: val.Split(',').Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true));
|
||||
return string.IsNullOrEmpty(Filters)
|
||||
? Array.Empty<ItemFilter>()
|
||||
: Filters.Split(',').Select(v => Enum.Parse<ItemFilter>(v, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -306,7 +306,8 @@ namespace MediaBrowser.Api
|
|||
Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));
|
||||
using (var stream = result.Content)
|
||||
{
|
||||
using var fileStream = new FileStream(fullCachePath,
|
||||
using var fileStream = new FileStream(
|
||||
fullCachePath,
|
||||
FileMode.Create,
|
||||
FileAccess.Write,
|
||||
FileShare.Read,
|
||||
|
|
|
@ -393,6 +393,7 @@ namespace MediaBrowser.Api.Library
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (string.Equals(type, "Season", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(type, "Episode", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(type, "MusicVideo", StringComparison.OrdinalIgnoreCase))
|
||||
|
|
|
@ -137,7 +137,9 @@ namespace MediaBrowser.Api.Playback
|
|||
var ext = outputFileExtension.ToLowerInvariant();
|
||||
var folder = ServerConfigurationManager.GetTranscodePath();
|
||||
|
||||
return EnableOutputInSubFolder ? Path.Combine(folder, filename, filename + ext) : Path.Combine(folder, filename + ext);
|
||||
return EnableOutputInSubFolder
|
||||
? Path.Combine(folder, filename, filename + ext)
|
||||
: Path.Combine(folder, filename + ext);
|
||||
}
|
||||
|
||||
protected virtual string GetDefaultEncoderPreset()
|
||||
|
@ -393,44 +395,36 @@ namespace MediaBrowser.Api.Playback
|
|||
request.Static = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.VideoCodec = val;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
request.AudioCodec = val;
|
||||
break;
|
||||
case 6:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.AudioStreamIndex = int.Parse(val, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.SubtitleStreamIndex = int.Parse(val, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.VideoBitRate = int.Parse(val, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 9:
|
||||
request.AudioBitRate = int.Parse(val, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
|
@ -438,71 +432,57 @@ namespace MediaBrowser.Api.Playback
|
|||
request.MaxAudioChannels = int.Parse(val, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case 11:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.MaxFramerate = float.Parse(val, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.MaxWidth = int.Parse(val, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 13:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.MaxHeight = int.Parse(val, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 14:
|
||||
request.StartTimeTicks = long.Parse(val, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case 15:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.Level = val;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.MaxRefFrames = int.Parse(val, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 17:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.MaxVideoBitDepth = int.Parse(val, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 18:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.Profile = val;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 19:
|
||||
// cabac no longer used
|
||||
break;
|
||||
|
@ -519,16 +499,13 @@ namespace MediaBrowser.Api.Playback
|
|||
// Duplicating ItemId because of MediaMonkey
|
||||
break;
|
||||
case 24:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.CopyTimestamps = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 25:
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(val) && videoRequest != null)
|
||||
{
|
||||
if (Enum.TryParse(val, out SubtitleDeliveryMethod method))
|
||||
|
@ -538,52 +515,43 @@ namespace MediaBrowser.Api.Playback
|
|||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 26:
|
||||
request.TranscodingMaxAudioChannels = int.Parse(val, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case 27:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.EnableSubtitlesInManifest = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 28:
|
||||
request.Tag = val;
|
||||
break;
|
||||
case 29:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.RequireAvc = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 30:
|
||||
request.SubtitleCodec = val;
|
||||
break;
|
||||
case 31:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.RequireNonAnamorphic = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 32:
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.DeInterlace = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 33:
|
||||
request.TranscodeReasons = val;
|
||||
break;
|
||||
|
@ -860,14 +828,11 @@ namespace MediaBrowser.Api.Playback
|
|||
{
|
||||
state.DeviceProfile = DlnaManager.GetProfile(state.Request.DeviceProfileId);
|
||||
}
|
||||
else
|
||||
else if (!string.IsNullOrWhiteSpace(state.Request.DeviceId))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(state.Request.DeviceId))
|
||||
{
|
||||
var caps = DeviceManager.GetCapabilities(state.Request.DeviceId);
|
||||
var caps = DeviceManager.GetCapabilities(state.Request.DeviceId);
|
||||
|
||||
state.DeviceProfile = caps != null ? caps.DeviceProfile : DlnaManager.GetProfile(headers);
|
||||
}
|
||||
state.DeviceProfile = caps == null ? DlnaManager.GetProfile(headers) : caps.DeviceProfile;
|
||||
}
|
||||
|
||||
var profile = state.DeviceProfile;
|
||||
|
|
|
@ -240,7 +240,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
|
||||
protected Stream GetPlaylistFileStream(string path)
|
||||
{
|
||||
return new FileStream(path,
|
||||
return new FileStream(
|
||||
path,
|
||||
FileMode.Open,
|
||||
FileAccess.Read,
|
||||
FileShare.ReadWrite,
|
||||
|
|
|
@ -243,14 +243,12 @@ namespace MediaBrowser.Api
|
|||
result.StartDate = program.StartDate;
|
||||
break;
|
||||
case Series series:
|
||||
{
|
||||
if (series.Status.HasValue)
|
||||
{
|
||||
result.Status = series.Status.Value.ToString();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case MusicAlbum album:
|
||||
result.Artists = album.Artists;
|
||||
result.AlbumArtist = album.AlbumArtist;
|
||||
|
|
|
@ -399,7 +399,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
return string.IsNullOrEmpty(VideoTypes)
|
||||
? Array.Empty<VideoType>()
|
||||
: VideoTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true)).ToArray();
|
||||
.Select(v => Enum.Parse<VideoType>(v, true)).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -411,9 +411,9 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
var val = Filters;
|
||||
|
||||
return string.IsNullOrEmpty(val)
|
||||
? new ItemFilter[] { }
|
||||
? Array.Empty<ItemFilter>()
|
||||
: val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).
|
||||
Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)).ToArray();
|
||||
Select(v => Enum.Parse<ItemFilter>(v, true)).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -426,7 +426,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
|
||||
return string.IsNullOrEmpty(val)
|
||||
? new ImageType[] { }
|
||||
: val.Split(',').Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToArray();
|
||||
: val.Split(',').Select(v => Enum.Parse<ImageType>(v, true)).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -462,7 +462,9 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
var sortOrderIndex = sortOrders.Length > i ? i : 0;
|
||||
|
||||
var sortOrderValue = sortOrders.Length > sortOrderIndex ? sortOrders[sortOrderIndex] : null;
|
||||
var sortOrder = string.Equals(sortOrderValue, "Descending", StringComparison.OrdinalIgnoreCase) ? MediaBrowser.Model.Entities.SortOrder.Descending : MediaBrowser.Model.Entities.SortOrder.Ascending;
|
||||
var sortOrder = string.Equals(sortOrderValue, "Descending", StringComparison.OrdinalIgnoreCase)
|
||||
? MediaBrowser.Model.Entities.SortOrder.Descending
|
||||
: MediaBrowser.Model.Entities.SortOrder.Ascending;
|
||||
|
||||
result[i] = new ValueTuple<string, SortOrder>(vals[i], sortOrder);
|
||||
}
|
||||
|
|
|
@ -138,15 +138,23 @@ namespace MediaBrowser.Api
|
|||
var videosWithVersions = items.Where(i => i.MediaSourceCount > 1)
|
||||
.ToList();
|
||||
|
||||
var primaryVersion = videosWithVersions.FirstOrDefault() ?? items.OrderBy(i
|
||||
=> (i.Video3DFormat.HasValue || i.VideoType != Model.Entities.VideoType.VideoFile) ? 1 : 0)
|
||||
.ThenByDescending(i =>
|
||||
{
|
||||
var stream = i.GetDefaultVideoStream();
|
||||
var primaryVersion = videosWithVersions.FirstOrDefault();
|
||||
if (primaryVersion == null)
|
||||
{
|
||||
primaryVersion = items.OrderBy(i =>
|
||||
{
|
||||
if (i.Video3DFormat.HasValue || i.VideoType != Model.Entities.VideoType.VideoFile)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return stream?.Width ?? 0;
|
||||
|
||||
}).First();
|
||||
return 0;
|
||||
})
|
||||
.ThenByDescending(i =>
|
||||
{
|
||||
return i.GetDefaultVideoStream()?.Width ?? 0;
|
||||
}).First();
|
||||
}
|
||||
|
||||
var list = primaryVersion.LinkedAlternateVersions.ToList();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user