aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile2
-rw-r--r--Emby.Dlna/ContentDirectory/ControlHandler.cs11
-rw-r--r--Emby.Dlna/Didl/DidlBuilder.cs9
-rw-r--r--Emby.Notifications/Notifications.cs37
-rw-r--r--Emby.Photos/PhotoProvider.cs4
-rw-r--r--Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs149
-rw-r--r--Emby.Server.Implementations/Activity/ActivityRepository.cs2
-rw-r--r--Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs8
-rw-r--r--Emby.Server.Implementations/Data/SqliteItemRepository.cs16
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs113
-rw-r--r--Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs17
-rw-r--r--Emby.Server.Implementations/Library/LibraryManager.cs5
-rw-r--r--Emby.Server.Implementations/Library/UserViewManager.cs30
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs29
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveTvManager.cs18
-rw-r--r--Emby.Server.Implementations/MediaEncoder/EncodingManager.cs2
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs (renamed from Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodingTempTask.cs)9
-rw-r--r--Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs13
-rw-r--r--Emby.Server.Implementations/Services/ResponseHelper.cs2
-rw-r--r--Emby.Server.Implementations/Services/ServiceExec.cs39
-rw-r--r--Emby.Server.Implementations/Services/UrlExtensions.cs14
-rw-r--r--Emby.Server.Implementations/Sorting/ArtistComparer.cs24
-rw-r--r--MediaBrowser.Api/LiveTv/LiveTvService.cs2
-rw-r--r--MediaBrowser.Api/Movies/MoviesService.cs2
-rw-r--r--MediaBrowser.Api/Music/AlbumsService.cs11
-rw-r--r--MediaBrowser.Api/PlaylistService.cs6
-rw-r--r--MediaBrowser.Api/SuggestionsService.cs5
-rw-r--r--MediaBrowser.Api/TvShowsService.cs6
-rw-r--r--MediaBrowser.Api/UserLibrary/ItemsService.cs5
-rw-r--r--MediaBrowser.Api/UserLibrary/UserLibraryService.cs17
-rw-r--r--MediaBrowser.Api/UserService.cs10
-rw-r--r--MediaBrowser.Common/Extensions/CollectionExtensions.cs17
-rw-r--r--MediaBrowser.Common/Net/CustomHeaderNames.cs2
-rw-r--r--MediaBrowser.Controller/Dto/IDtoService.cs2
-rw-r--r--MediaBrowser.Controller/Entities/Audio/Audio.cs37
-rw-r--r--MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs27
-rw-r--r--MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs38
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs8
-rw-r--r--MediaBrowser.Controller/Entities/Extensions.cs9
-rw-r--r--MediaBrowser.Controller/Entities/Folder.cs18
-rw-r--r--MediaBrowser.Controller/Entities/IHasTrailers.cs70
-rw-r--r--MediaBrowser.Controller/Entities/Movies/BoxSet.cs10
-rw-r--r--MediaBrowser.Controller/Entities/Movies/Movie.cs7
-rw-r--r--MediaBrowser.Controller/Entities/MusicVideo.cs7
-rw-r--r--MediaBrowser.Controller/Entities/TV/Episode.cs7
-rw-r--r--MediaBrowser.Controller/Entities/TV/Series.cs7
-rw-r--r--MediaBrowser.Controller/LiveTv/ILiveTvManager.cs4
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs792
-rw-r--r--MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs17
-rw-r--r--MediaBrowser.Controller/Providers/AlbumInfo.cs2
-rw-r--r--MediaBrowser.Controller/Providers/MusicVideoInfo.cs4
-rw-r--r--MediaBrowser.Controller/Providers/SongInfo.cs7
-rw-r--r--MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs2
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs2
-rw-r--r--MediaBrowser.Model/Dto/BaseItemDto.cs4
-rw-r--r--MediaBrowser.Model/Dto/RecommendationDto.cs3
-rw-r--r--MediaBrowser.Model/Net/MimeTypes.cs1
-rw-r--r--MediaBrowser.Model/Querying/QueryResult.cs7
-rw-r--r--MediaBrowser.Model/Search/SearchHint.cs4
-rw-r--r--MediaBrowser.Providers/Books/AudioBookMetadataService.cs25
-rw-r--r--MediaBrowser.Providers/Manager/ProviderManager.cs3
-rw-r--r--MediaBrowser.Providers/Manager/ProviderUtils.cs46
-rw-r--r--MediaBrowser.Providers/MediaBrowser.Providers.csproj2
-rw-r--r--MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs2
-rw-r--r--MediaBrowser.Providers/Music/AlbumMetadataService.cs42
-rw-r--r--MediaBrowser.Providers/Music/AudioMetadataService.cs18
-rw-r--r--MediaBrowser.Providers/Music/MusicVideoMetadataService.cs25
-rw-r--r--MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs10
-rw-r--r--MediaBrowser.XbmcMetadata/EntryPoint.cs16
-rw-r--r--MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs39
-rw-r--r--MediaBrowser.sln8
71 files changed, 1145 insertions, 823 deletions
diff --git a/Dockerfile b/Dockerfile
index d8f7ab314..ec64398b2 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,5 @@
ARG DOTNET_VERSION=2.2
+ARG FFMPEG_VERSION=latest
FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNET_VERSION} as builder
WORKDIR /repo
@@ -7,7 +8,6 @@ ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
RUN bash -c "source deployment/common.build.sh && \
build_jellyfin Jellyfin.Server Release linux-x64 /jellyfin"
-ARG FFMPEG_VERSION=latest
FROM jellyfin/ffmpeg:${FFMPEG_VERSION} as ffmpeg
FROM mcr.microsoft.com/dotnet/core/runtime:${DOTNET_VERSION}
# libfontconfig1 is required for Skia
diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs
index 4f8c89e48..d22fc2177 100644
--- a/Emby.Dlna/ContentDirectory/ControlHandler.cs
+++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs
@@ -289,7 +289,7 @@ namespace Emby.Dlna.ContentDirectory
var childrenResult = GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requestedCount);
totalCount = childrenResult.TotalRecordCount;
- provided = childrenResult.Items.Length;
+ provided = childrenResult.Items.Count;
foreach (var i in childrenResult.Items)
{
@@ -309,6 +309,7 @@ namespace Emby.Dlna.ContentDirectory
}
}
}
+
writer.WriteFullEndElement();
//writer.WriteEndDocument();
}
@@ -386,7 +387,7 @@ namespace Emby.Dlna.ContentDirectory
totalCount = childrenResult.TotalRecordCount;
- provided = childrenResult.Items.Length;
+ provided = childrenResult.Items.Count;
var dlnaOptions = _config.GetDlnaConfiguration();
@@ -677,7 +678,7 @@ namespace Emby.Dlna.ContentDirectory
return new QueryResult<ServerItem>
{
- Items = list.ToArray(),
+ Items = list,
TotalRecordCount = list.Count
};
}
@@ -755,7 +756,7 @@ namespace Emby.Dlna.ContentDirectory
return new QueryResult<ServerItem>
{
- Items = list.ToArray(),
+ Items = list,
TotalRecordCount = list.Count
};
}
@@ -860,7 +861,7 @@ namespace Emby.Dlna.ContentDirectory
return new QueryResult<ServerItem>
{
- Items = list.ToArray(),
+ Items = list,
TotalRecordCount = list.Count
};
}
diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs
index 26adfde83..85ef9d482 100644
--- a/Emby.Dlna/Didl/DidlBuilder.cs
+++ b/Emby.Dlna/Didl/DidlBuilder.cs
@@ -158,7 +158,7 @@ namespace Emby.Dlna.Didl
AddGeneralProperties(item, null, context, writer, filter);
- AddSamsungBookmarkInfo(item, user, writer);
+ AddSamsungBookmarkInfo(item, user, writer, streamInfo);
// refID?
// storeAttribute(itemNode, object, ClassProperties.REF_ID, false);
@@ -581,7 +581,7 @@ namespace Emby.Dlna.Didl
writer.WriteFullEndElement();
}
- private void AddSamsungBookmarkInfo(BaseItem item, User user, XmlWriter writer)
+ private void AddSamsungBookmarkInfo(BaseItem item, User user, XmlWriter writer, StreamInfo streamInfo)
{
if (!item.SupportsPositionTicksResume || item is Folder)
{
@@ -605,10 +605,11 @@ namespace Emby.Dlna.Didl
}
var userdata = _userDataManager.GetUserData(user, item);
+ var playbackPositionTicks = (streamInfo != null && streamInfo.StartPositionTicks > 0) ? streamInfo.StartPositionTicks : userdata.PlaybackPositionTicks;
- if (userdata.PlaybackPositionTicks > 0)
+ if (playbackPositionTicks > 0)
{
- var elementValue = string.Format("BM={0}", Convert.ToInt32(TimeSpan.FromTicks(userdata.PlaybackPositionTicks).TotalSeconds).ToString(_usCulture));
+ var elementValue = string.Format("BM={0}", Convert.ToInt32(TimeSpan.FromTicks(playbackPositionTicks).TotalSeconds).ToString(_usCulture));
AddValue(writer, "sec", "dcmInfo", elementValue, secAttribute.Value);
}
}
diff --git a/Emby.Notifications/Notifications.cs b/Emby.Notifications/Notifications.cs
index ec08fd193..7aa1e7ae8 100644
--- a/Emby.Notifications/Notifications.cs
+++ b/Emby.Notifications/Notifications.cs
@@ -209,47 +209,48 @@ namespace Emby.Notifications
public static string GetItemName(BaseItem item)
{
var name = item.Name;
- var episode = item as Episode;
- if (episode != null)
+ if (item is Episode episode)
{
if (episode.IndexNumber.HasValue)
{
- name = string.Format("Ep{0} - {1}", episode.IndexNumber.Value.ToString(CultureInfo.InvariantCulture), name);
+ name = string.Format(
+ CultureInfo.InvariantCulture,
+ "Ep{0} - {1}",
+ episode.IndexNumber.Value,
+ name);
}
if (episode.ParentIndexNumber.HasValue)
{
- name = string.Format("S{0}, {1}", episode.ParentIndexNumber.Value.ToString(CultureInfo.InvariantCulture), name);
+ name = string.Format(
+ CultureInfo.InvariantCulture,
+ "S{0}, {1}",
+ episode.ParentIndexNumber.Value,
+ name);
}
}
- var hasSeries = item as IHasSeries;
- if (hasSeries != null)
+ if (item is IHasSeries hasSeries)
{
name = hasSeries.SeriesName + " - " + name;
}
- var hasAlbumArtist = item as IHasAlbumArtist;
- if (hasAlbumArtist != null)
+ if (item is IHasAlbumArtist hasAlbumArtist)
{
var artists = hasAlbumArtist.AlbumArtists;
- if (artists.Length > 0)
+ if (artists.Count > 0)
{
name = artists[0] + " - " + name;
}
}
- else
+ else if (item is IHasArtist hasArtist)
{
- var hasArtist = item as IHasArtist;
- if (hasArtist != null)
- {
- var artists = hasArtist.Artists;
+ var artists = hasArtist.Artists;
- if (artists.Length > 0)
- {
- name = artists[0] + " - " + name;
- }
+ if (artists.Count > 0)
+ {
+ name = artists[0] + " - " + name;
}
}
diff --git a/Emby.Photos/PhotoProvider.cs b/Emby.Photos/PhotoProvider.cs
index 99a635e60..1591609ab 100644
--- a/Emby.Photos/PhotoProvider.cs
+++ b/Emby.Photos/PhotoProvider.cs
@@ -170,8 +170,8 @@ namespace Emby.Photos
}
}
- const ItemUpdateType result = ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataImport;
- return Task.FromResult(result);
+ const ItemUpdateType Result = ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataImport;
+ return Task.FromResult(Result);
}
}
}
diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
index fb4ffd74b..1514402d6 100644
--- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
+++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs
@@ -96,7 +96,10 @@ namespace Emby.Server.Implementations.Activity
{
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("CameraImageUploadedFrom"), e.Argument.Device.Name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("CameraImageUploadedFrom"),
+ e.Argument.Device.Name),
Type = NotificationType.CameraImageUploaded.ToString()
});
}
@@ -105,7 +108,10 @@ namespace Emby.Server.Implementations.Activity
{
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("UserLockedOutWithName"), e.Argument.Name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("UserLockedOutWithName"),
+ e.Argument.Name),
Type = NotificationType.UserLockedOut.ToString(),
UserId = e.Argument.Id
});
@@ -115,7 +121,11 @@ namespace Emby.Server.Implementations.Activity
{
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("SubtitleDownloadFailureFromForItem"), e.Provider, Notifications.Notifications.GetItemName(e.Item)),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("SubtitleDownloadFailureFromForItem"),
+ e.Provider,
+ Notifications.Notifications.GetItemName(e.Item)),
Type = "SubtitleDownloadFailure",
ItemId = e.Item.Id.ToString("N", CultureInfo.InvariantCulture),
ShortOverview = e.Exception.Message
@@ -178,7 +188,12 @@ namespace Emby.Server.Implementations.Activity
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("UserStartedPlayingItemWithValues"), user.Name, GetItemName(item), e.DeviceName),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("UserStartedPlayingItemWithValues"),
+ user.Name,
+ GetItemName(item),
+ e.DeviceName),
Type = GetPlaybackNotificationType(item.MediaType),
UserId = user.Id
});
@@ -193,7 +208,7 @@ namespace Emby.Server.Implementations.Activity
name = item.SeriesName + " - " + name;
}
- if (item.Artists != null && item.Artists.Length > 0)
+ if (item.Artists != null && item.Artists.Count > 0)
{
name = item.Artists[0] + " - " + name;
}
@@ -238,21 +253,31 @@ namespace Emby.Server.Implementations.Activity
if (string.IsNullOrEmpty(session.UserName))
{
- name = string.Format(_localization.GetLocalizedString("DeviceOfflineWithName"), session.DeviceName);
+ name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("DeviceOfflineWithName"),
+ session.DeviceName);
// Causing too much spam for now
return;
}
else
{
- name = string.Format(_localization.GetLocalizedString("UserOfflineFromDevice"), session.UserName, session.DeviceName);
+ name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("UserOfflineFromDevice"),
+ session.UserName,
+ session.DeviceName);
}
CreateLogEntry(new ActivityLogEntry
{
Name = name,
Type = "SessionEnded",
- ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint),
+ ShortOverview = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("LabelIpAddressValue"),
+ session.RemoteEndPoint),
UserId = session.UserId
});
}
@@ -263,9 +288,15 @@ namespace Emby.Server.Implementations.Activity
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("AuthenticationSucceededWithUserName"), user.Name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("AuthenticationSucceededWithUserName"),
+ user.Name),
Type = "AuthenticationSucceeded",
- ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), e.Argument.SessionInfo.RemoteEndPoint),
+ ShortOverview = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("LabelIpAddressValue"),
+ e.Argument.SessionInfo.RemoteEndPoint),
UserId = user.Id
});
}
@@ -274,9 +305,15 @@ namespace Emby.Server.Implementations.Activity
{
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("FailedLoginAttemptWithUserName"), e.Argument.Username),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("FailedLoginAttemptWithUserName"),
+ e.Argument.Username),
Type = "AuthenticationFailed",
- ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), e.Argument.RemoteEndPoint),
+ ShortOverview = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("LabelIpAddressValue"),
+ e.Argument.RemoteEndPoint),
Severity = LogLevel.Error
});
}
@@ -285,7 +322,10 @@ namespace Emby.Server.Implementations.Activity
{
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("UserPolicyUpdatedWithName"), e.Argument.Name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("UserPolicyUpdatedWithName"),
+ e.Argument.Name),
Type = "UserPolicyUpdated",
UserId = e.Argument.Id
});
@@ -295,7 +335,10 @@ namespace Emby.Server.Implementations.Activity
{
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("UserDeletedWithName"), e.Argument.Name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("UserDeletedWithName"),
+ e.Argument.Name),
Type = "UserDeleted"
});
}
@@ -304,7 +347,10 @@ namespace Emby.Server.Implementations.Activity
{
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("UserPasswordChangedWithName"), e.Argument.Name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("UserPasswordChangedWithName"),
+ e.Argument.Name),
Type = "UserPasswordChanged",
UserId = e.Argument.Id
});
@@ -314,7 +360,10 @@ namespace Emby.Server.Implementations.Activity
{
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("UserCreatedWithName"), e.Argument.Name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("UserCreatedWithName"),
+ e.Argument.Name),
Type = "UserCreated",
UserId = e.Argument.Id
});
@@ -327,21 +376,31 @@ namespace Emby.Server.Implementations.Activity
if (string.IsNullOrEmpty(session.UserName))
{
- name = string.Format(_localization.GetLocalizedString("DeviceOnlineWithName"), session.DeviceName);
+ name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("DeviceOnlineWithName"),
+ session.DeviceName);
// Causing too much spam for now
return;
}
else
{
- name = string.Format(_localization.GetLocalizedString("UserOnlineFromDevice"), session.UserName, session.DeviceName);
+ name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("UserOnlineFromDevice"),
+ session.UserName,
+ session.DeviceName);
}
CreateLogEntry(new ActivityLogEntry
{
Name = name,
Type = "SessionStarted",
- ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint),
+ ShortOverview = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("LabelIpAddressValue"),
+ session.RemoteEndPoint),
UserId = session.UserId
});
}
@@ -350,9 +409,15 @@ namespace Emby.Server.Implementations.Activity
{
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("PluginUpdatedWithName"), e.Argument.Item1.Name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("PluginUpdatedWithName"),
+ e.Argument.Item1.Name),
Type = NotificationType.PluginUpdateInstalled.ToString(),
- ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), e.Argument.Item2.versionStr),
+ ShortOverview = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("VersionNumber"),
+ e.Argument.Item2.versionStr),
Overview = e.Argument.Item2.description
});
}
@@ -361,7 +426,10 @@ namespace Emby.Server.Implementations.Activity
{
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("PluginUninstalledWithName"), e.Argument.Name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("PluginUninstalledWithName"),
+ e.Argument.Name),
Type = NotificationType.PluginUninstalled.ToString()
});
}
@@ -370,9 +438,15 @@ namespace Emby.Server.Implementations.Activity
{
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("PluginInstalledWithName"), e.Argument.name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("PluginInstalledWithName"),
+ e.Argument.name),
Type = NotificationType.PluginInstalled.ToString(),
- ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), e.Argument.versionStr)
+ ShortOverview = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("VersionNumber"),
+ e.Argument.versionStr)
});
}
@@ -382,9 +456,15 @@ namespace Emby.Server.Implementations.Activity
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("NameInstallFailed"), installationInfo.Name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("NameInstallFailed"),
+ installationInfo.Name),
Type = NotificationType.InstallationFailed.ToString(),
- ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), installationInfo.Version),
+ ShortOverview = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("VersionNumber"),
+ installationInfo.Version),
Overview = e.Exception.Message
});
}
@@ -401,7 +481,10 @@ namespace Emby.Server.Implementations.Activity
}
var time = result.EndTimeUtc - result.StartTimeUtc;
- var runningTime = string.Format(_localization.GetLocalizedString("LabelRunningTimeValue"), ToUserFriendlyString(time));
+ var runningTime = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("LabelRunningTimeValue"),
+ ToUserFriendlyString(time));
if (result.Status == TaskCompletionStatus.Failed)
{
@@ -419,7 +502,10 @@ namespace Emby.Server.Implementations.Activity
CreateLogEntry(new ActivityLogEntry
{
- Name = string.Format(_localization.GetLocalizedString("ScheduledTaskFailedWithName"), task.Name),
+ Name = string.Format(
+ CultureInfo.InvariantCulture,
+ _localization.GetLocalizedString("ScheduledTaskFailedWithName"),
+ task.Name),
Type = NotificationType.TaskFailed.ToString(),
Overview = string.Join(Environment.NewLine, vals),
ShortOverview = runningTime,
@@ -534,8 +620,11 @@ namespace Emby.Server.Implementations.Activity
/// <param name="description">The name of this item (singular form)</param>
private static string CreateValueString(int value, string description)
{
- return string.Format("{0:#,##0} {1}",
- value, value == 1 ? description : string.Format("{0}s", description));
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0:#,##0} {1}",
+ value,
+ value == 1 ? description : string.Format(CultureInfo.InvariantCulture, "{0}s", description));
}
}
}
diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs
index 541b23afd..ffaeaa541 100644
--- a/Emby.Server.Implementations/Activity/ActivityRepository.cs
+++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs
@@ -247,7 +247,7 @@ namespace Emby.Server.Implementations.Activity
ReadTransactionMode);
}
- result.Items = list.ToArray();
+ result.Items = list;
return result;
}
diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
index c4fa68cac..c7f92b80b 100644
--- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
+++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
@@ -66,7 +66,7 @@ namespace Emby.Server.Implementations.Configuration
{
base.AddParts(factories);
- UpdateTranscodingTempPath();
+ UpdateTranscodePath();
}
/// <summary>
@@ -87,13 +87,13 @@ namespace Emby.Server.Implementations.Configuration
/// <summary>
/// Updates the transcoding temporary path.
/// </summary>
- private void UpdateTranscodingTempPath()
+ private void UpdateTranscodePath()
{
var encodingConfig = this.GetConfiguration<EncodingOptions>("encoding");
((ServerApplicationPaths)ApplicationPaths).TranscodingTempPath = string.IsNullOrEmpty(encodingConfig.TranscodingTempPath) ?
null :
- Path.Combine(encodingConfig.TranscodingTempPath, "transcoding-temp");
+ Path.Combine(encodingConfig.TranscodingTempPath, "transcodes");
}
protected override void OnNamedConfigurationUpdated(string key, object configuration)
@@ -102,7 +102,7 @@ namespace Emby.Server.Implementations.Configuration
if (string.Equals(key, "encoding", StringComparison.OrdinalIgnoreCase))
{
- UpdateTranscodingTempPath();
+ UpdateTranscodePath();
}
}
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
index 9d983307f..2f083dda4 100644
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
@@ -979,7 +979,7 @@ namespace Emby.Server.Implementations.Data
}
string artists = null;
- if (item is IHasArtist hasArtists && hasArtists.Artists.Length > 0)
+ if (item is IHasArtist hasArtists && hasArtists.Artists.Count > 0)
{
artists = string.Join("|", hasArtists.Artists);
}
@@ -987,7 +987,7 @@ namespace Emby.Server.Implementations.Data
string albumArtists = null;
if (item is IHasAlbumArtist hasAlbumArtists
- && hasAlbumArtists.AlbumArtists.Length > 0)
+ && hasAlbumArtists.AlbumArtists.Count > 0)
{
albumArtists = string.Join("|", hasAlbumArtists.AlbumArtists);
}
@@ -2746,7 +2746,7 @@ namespace Emby.Server.Implementations.Data
var returnList = GetItemList(query);
return new QueryResult<BaseItem>
{
- Items = returnList.ToArray(),
+ Items = returnList,
TotalRecordCount = returnList.Count
};
}
@@ -2883,7 +2883,7 @@ namespace Emby.Server.Implementations.Data
}
LogQueryTime("GetItems", commandText, now);
- result.Items = list.ToArray();
+ result.Items = list;
return result;
}
@@ -3161,7 +3161,7 @@ namespace Emby.Server.Implementations.Data
var returnList = GetItemIdsList(query);
return new QueryResult<Guid>
{
- Items = returnList.ToArray(),
+ Items = returnList,
TotalRecordCount = returnList.Count
};
}
@@ -3281,7 +3281,7 @@ namespace Emby.Server.Implementations.Data
LogQueryTime("GetItemIds", commandText, now);
- result.Items = list.ToArray();
+ result.Items = list;
return result;
}
@@ -5520,7 +5520,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
result.TotalRecordCount = list.Count;
}
- result.Items = list.ToArray();
+ result.Items = list;
return result;
}
@@ -5731,7 +5731,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
{
if (isSubsequentRow)
{
- insertText.Append(",");
+ insertText.Append(',');
}
insertText.AppendFormat("(@ItemId, @Name{0}, @Role{0}, @PersonType{0}, @SortOrder{0}, @ListOrder{0})", i.ToString(CultureInfo.InvariantCulture));
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index 97ddfff53..75192a8f1 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -80,27 +80,25 @@ namespace Emby.Server.Implementations.Dto
return GetBaseItemDto(item, options, user, owner);
}
- public BaseItemDto[] GetBaseItemDtos(IReadOnlyList<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null)
- => GetBaseItemDtos(items, items.Count, options, user, owner);
-
- public BaseItemDto[] GetBaseItemDtos(IEnumerable<BaseItem> items, int itemCount, DtoOptions options, User user = null, BaseItem owner = null)
+ /// <inheritdoc />
+ public IReadOnlyList<BaseItemDto> GetBaseItemDtos(IReadOnlyList<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null)
{
- var returnItems = new BaseItemDto[itemCount];
- var programTuples = new List<Tuple<BaseItem, BaseItemDto>>();
- var channelTuples = new List<Tuple<BaseItemDto, LiveTvChannel>>();
+ var returnItems = new BaseItemDto[items.Count];
+ var programTuples = new List<(BaseItem, BaseItemDto)>();
+ var channelTuples = new List<(BaseItemDto, LiveTvChannel)>();
- var index = 0;
- foreach (var item in items)
+ for (int index = 0; index < items.Count; index++)
{
+ var item = items[index];
var dto = GetBaseItemDtoInternal(item, options, user, owner);
if (item is LiveTvChannel tvChannel)
{
- channelTuples.Add(new Tuple<BaseItemDto, LiveTvChannel>(dto, tvChannel));
+ channelTuples.Add((dto, tvChannel));
}
else if (item is LiveTvProgram)
{
- programTuples.Add(new Tuple<BaseItem, BaseItemDto>(item, dto));
+ programTuples.Add((item, dto));
}
if (item is IItemByName byName)
@@ -121,7 +119,6 @@ namespace Emby.Server.Implementations.Dto
}
returnItems[index] = dto;
- index++;
}
if (programTuples.Count > 0)
@@ -140,33 +137,32 @@ namespace Emby.Server.Implementations.Dto
public BaseItemDto GetBaseItemDto(BaseItem item, DtoOptions options, User user = null, BaseItem owner = null)
{
var dto = GetBaseItemDtoInternal(item, options, user, owner);
- var tvChannel = item as LiveTvChannel;
- if (tvChannel != null)
+ if (item is LiveTvChannel tvChannel)
{
- var list = new List<Tuple<BaseItemDto, LiveTvChannel>> { new Tuple<BaseItemDto, LiveTvChannel>(dto, tvChannel) };
+ var list = new List<(BaseItemDto, LiveTvChannel)>(1) { (dto, tvChannel) };
_livetvManager().AddChannelInfo(list, options, user);
}
else if (item is LiveTvProgram)
{
- var list = new List<Tuple<BaseItem, BaseItemDto>> { new Tuple<BaseItem, BaseItemDto>(item, dto) };
+ var list = new List<(BaseItem, BaseItemDto)>(1) { (item, dto) };
var task = _livetvManager().AddInfoToProgramDto(list, options.Fields, user);
Task.WaitAll(task);
}
- var byName = item as IItemByName;
-
- if (byName != null)
+ if (item is IItemByName itemByName
+ && options.ContainsField(ItemFields.ItemCounts))
{
- if (options.ContainsField(ItemFields.ItemCounts))
- {
- SetItemByNameInfo(item, dto, GetTaggedItems(byName, user, new DtoOptions(false)
- {
- EnableImages = false
-
- }), user);
- }
-
- return dto;
+ SetItemByNameInfo(
+ item,
+ dto,
+ GetTaggedItems(
+ itemByName,
+ user,
+ new DtoOptions(false)
+ {
+ EnableImages = false
+ }),
+ user);
}
return dto;
@@ -174,12 +170,12 @@ namespace Emby.Server.Implementations.Dto
private static IList<BaseItem> GetTaggedItems(IItemByName byName, User user, DtoOptions options)
{
- return byName.GetTaggedItems(new InternalItemsQuery(user)
- {
- Recursive = true,
- DtoOptions = options
-
- });
+ return byName.GetTaggedItems(
+ new InternalItemsQuery(user)
+ {
+ Recursive = true,
+ DtoOptions = options
+ });
}
private BaseItemDto GetBaseItemDtoInternal(BaseItem item, DtoOptions options, User user = null, BaseItem owner = null)
@@ -222,8 +218,7 @@ namespace Emby.Server.Implementations.Dto
AttachUserSpecificInfo(dto, item, user, options);
}
- var hasMediaSources = item as IHasMediaSources;
- if (hasMediaSources != null)
+ if (item is IHasMediaSources hasMediaSources)
{
if (options.ContainsField(ItemFields.MediaSources))
{
@@ -769,14 +764,12 @@ namespace Emby.Server.Implementations.Dto
dto.CriticRating = item.CriticRating;
- var hasDisplayOrder = item as IHasDisplayOrder;
- if (hasDisplayOrder != null)
+ if (item is IHasDisplayOrder hasDisplayOrder)
{
dto.DisplayOrder = hasDisplayOrder.DisplayOrder;
}
- var hasCollectionType = item as IHasCollectionType;
- if (hasCollectionType != null)
+ if (item is IHasCollectionType hasCollectionType)
{
dto.CollectionType = hasCollectionType.CollectionType;
}
@@ -886,8 +879,7 @@ namespace Emby.Server.Implementations.Dto
//}
}
- var hasArtist = item as IHasArtist;
- if (hasArtist != null)
+ if (item is IHasArtist hasArtist)
{
dto.Artists = hasArtist.Artists;
@@ -1074,17 +1066,24 @@ namespace Emby.Server.Implementations.Dto
if (options.ContainsField(ItemFields.LocalTrailerCount))
{
+ int trailerCount = 0;
if (allExtras == null)
{
allExtras = item.GetExtras().ToArray();
}
- dto.LocalTrailerCount = allExtras.Count(i => i.ExtraType.HasValue && i.ExtraType.Value == ExtraType.Trailer) + item.GetTrailers().Count();
+ trailerCount += allExtras.Count(i => i.ExtraType.HasValue && i.ExtraType.Value == ExtraType.Trailer);
+
+ if (item is IHasTrailers hasTrailers)
+ {
+ trailerCount += hasTrailers.GetTrailerCount();
+ }
+
+ dto.LocalTrailerCount = trailerCount;
}
// Add EpisodeInfo
- var episode = item as Episode;
- if (episode != null)
+ if (item is Episode episode)
{
dto.IndexNumberEnd = episode.IndexNumberEnd;
dto.SeriesName = episode.SeriesName;
@@ -1102,7 +1101,7 @@ namespace Emby.Server.Implementations.Dto
Series episodeSeries = null;
- //if (options.ContainsField(ItemFields.SeriesPrimaryImage))
+ if (options.ContainsField(ItemFields.SeriesPrimaryImage))
{
episodeSeries = episodeSeries ?? episode.Series;
if (episodeSeries != null)
@@ -1122,8 +1121,7 @@ namespace Emby.Server.Implementations.Dto
}
// Add SeriesInfo
- var series = item as Series;
- if (series != null)
+ if (item is Series series)
{
dto.AirDays = series.AirDays;
dto.AirTime = series.AirTime;
@@ -1131,8 +1129,7 @@ namespace Emby.Server.Implementations.Dto
}
// Add SeasonInfo
- var season = item as Season;
- if (season != null)
+ if (item is Season season)
{
dto.SeriesName = season.SeriesName;
dto.SeriesId = season.SeriesId;
@@ -1148,7 +1145,7 @@ namespace Emby.Server.Implementations.Dto
}
}
- //if (options.ContainsField(ItemFields.SeriesPrimaryImage))
+ if (options.ContainsField(ItemFields.SeriesPrimaryImage))
{
series = series ?? season.Series;
if (series != null)
@@ -1158,14 +1155,12 @@ namespace Emby.Server.Implementations.Dto
}
}
- var musicVideo = item as MusicVideo;
- if (musicVideo != null)
+ if (item is MusicVideo musicVideo)
{
SetMusicVideoProperties(dto, musicVideo);
}
- var book = item as Book;
- if (book != null)
+ if (item is Book book)
{
SetBookProperties(dto, book);
}
@@ -1205,8 +1200,7 @@ namespace Emby.Server.Implementations.Dto
}
}
- var photo = item as Photo;
- if (photo != null)
+ if (item is Photo photo)
{
SetPhotoProperties(dto, photo);
}
@@ -1225,8 +1219,7 @@ namespace Emby.Server.Implementations.Dto
private BaseItem GetImageDisplayParent(BaseItem currentItem, BaseItem originalItem)
{
- var musicAlbum = currentItem as MusicAlbum;
- if (musicAlbum != null)
+ if (currentItem is MusicAlbum musicAlbum)
{
var artist = musicAlbum.GetMusicArtist(new DtoOptions(false));
if (artist != null)
diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
index 276312a30..457448604 100644
--- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
+++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Security;
@@ -89,7 +90,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
AccessToken = token
});
- var tokenInfo = result.Items.Length > 0 ? result.Items[0] : null;
+ var tokenInfo = result.Items.Count > 0 ? result.Items[0] : null;
if (tokenInfo != null)
{
@@ -190,17 +191,23 @@ namespace Emby.Server.Implementations.HttpServer.Security
/// <returns>Dictionary{System.StringSystem.String}.</returns>
private Dictionary<string, string> GetAuthorization(string authorizationHeader)
{
- if (authorizationHeader == null) return null;
+ if (authorizationHeader == null)
+ {
+ return null;
+ }
var parts = authorizationHeader.Split(new[] { ' ' }, 2);
// There should be at least to parts
- if (parts.Length != 2) return null;
+ if (parts.Length != 2)
+ {
+ return null;
+ }
var acceptedNames = new[] { "MediaBrowser", "Emby" };
// It has to be a digest request
- if (!acceptedNames.Contains(parts[0] ?? string.Empty, StringComparer.OrdinalIgnoreCase))
+ if (!acceptedNames.Contains(parts[0], StringComparer.OrdinalIgnoreCase))
{
return null;
}
@@ -232,7 +239,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
return value;
}
- return System.Net.WebUtility.HtmlEncode(value);
+ return WebUtility.HtmlEncode(value);
}
}
}
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index 30ff855cc..36934f65f 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -1441,7 +1441,7 @@ namespace Emby.Server.Implementations.Library
return new QueryResult<BaseItem>
{
- Items = list.ToArray()
+ Items = list
};
}
@@ -1977,8 +1977,7 @@ namespace Emby.Server.Implementations.Library
public LibraryOptions GetLibraryOptions(BaseItem item)
{
- var collectionFolder = item as CollectionFolder;
- if (collectionFolder == null)
+ if (!(item is CollectionFolder collectionFolder))
{
collectionFolder = GetCollectionFolders(item)
.OfType<CollectionFolder>()
diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs
index 71f16ac3e..4d79cae13 100644
--- a/Emby.Server.Implementations/Library/UserViewManager.cs
+++ b/Emby.Server.Implementations/Library/UserViewManager.cs
@@ -224,7 +224,7 @@ namespace Emby.Server.Implementations.Library
return list;
}
- private List<BaseItem> GetItemsForLatestItems(User user, LatestItemsQuery request, DtoOptions options)
+ private IReadOnlyList<BaseItem> GetItemsForLatestItems(User user, LatestItemsQuery request, DtoOptions options)
{
var parentId = request.ParentId;
@@ -236,24 +236,22 @@ namespace Emby.Server.Implementations.Library
if (!parentId.Equals(Guid.Empty))
{
var parentItem = _libraryManager.GetItemById(parentId);
- var parentItemChannel = parentItem as Channel;
- if (parentItemChannel != null)
+ if (parentItem is Channel parentItemChannel)
{
- return _channelManager.GetLatestChannelItemsInternal(new InternalItemsQuery(user)
- {
- ChannelIds = new[] { parentId },
- IsPlayed = request.IsPlayed,
- StartIndex = request.StartIndex,
- Limit = request.Limit,
- IncludeItemTypes = request.IncludeItemTypes,
- EnableTotalRecordCount = false
-
-
- }, CancellationToken.None).Result.Items.ToList();
+ return _channelManager.GetLatestChannelItemsInternal(
+ new InternalItemsQuery(user)
+ {
+ ChannelIds = new[] { parentId },
+ IsPlayed = request.IsPlayed,
+ StartIndex = request.StartIndex,
+ Limit = request.Limit,
+ IncludeItemTypes = request.IncludeItemTypes,
+ EnableTotalRecordCount = false
+ },
+ CancellationToken.None).Result.Items;
}
- var parent = parentItem as Folder;
- if (parent != null)
+ if (parentItem is Folder parent)
{
parents.Add(parent);
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
index 75efa7ec8..3cc0541e7 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
@@ -87,8 +87,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
CreateNoWindow = true,
UseShellExecute = false,
- // Must consume both stdout and stderr or deadlocks may occur
- //RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true,
@@ -120,9 +118,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
cancellationToken.Register(Stop);
- // MUST read both stdout and stderr asynchronously or a deadlock may occurr
- //process.BeginOutputReadLine();
-
onStarted();
// Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback
@@ -138,11 +133,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
string videoArgs;
if (EncodeVideo(mediaSource))
{
- var maxBitrate = 25000000;
+ const int MaxBitrate = 25000000;
videoArgs = string.Format(
- "-codec:v:0 libx264 -force_key_frames \"expr:gte(t,n_forced*5)\" {0} -pix_fmt yuv420p -preset superfast -crf 23 -b:v {1} -maxrate {1} -bufsize ({1}*2) -vsync -1 -profile:v high -level 41",
- GetOutputSizeParam(),
- maxBitrate.ToString(CultureInfo.InvariantCulture));
+ CultureInfo.InvariantCulture,
+ "-codec:v:0 libx264 -force_key_frames \"expr:gte(t,n_forced*5)\" {0} -pix_fmt yuv420p -preset superfast -crf 23 -b:v {1} -maxrate {1} -bufsize ({1}*2) -vsync -1 -profile:v high -level 41",
+ GetOutputSizeParam(),
+ MaxBitrate);
}
else
{
@@ -151,18 +147,17 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
videoArgs += " -fflags +genpts";
- var durationParam = " -t " + _mediaEncoder.GetTimeParameter(duration.Ticks);
- durationParam = string.Empty;
-
var flags = new List<string>();
if (mediaSource.IgnoreDts)
{
flags.Add("+igndts");
}
+
if (mediaSource.IgnoreIndex)
{
flags.Add("+ignidx");
}
+
if (mediaSource.GenPtsInput)
{
flags.Add("+genpts");
@@ -172,11 +167,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
if (flags.Count > 0)
{
- inputModifier += " -fflags " + string.Join("", flags.ToArray());
+ inputModifier += " -fflags " + string.Join(string.Empty, flags);
}
- var videoStream = mediaSource.VideoStream;
-
if (mediaSource.ReadAtNativeFramerate)
{
inputModifier += " -re";
@@ -200,13 +193,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var outputParam = string.Empty;
- var commandLineArgs = string.Format("-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"",
+ var commandLineArgs = string.Format(
+ CultureInfo.InvariantCulture,
+ "-i \"{0}\" {2} -map_metadata -1 -threads 0 {3}{4}{5} -y \"{1}\"",
inputTempFile,
targetFile,
videoArgs,
GetAudioArgs(mediaSource),
subtitleArgs,
- durationParam,
outputParam);
return inputModifier + " " + commandLineArgs;
@@ -257,7 +251,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
_logger.LogInformation("Stopping ffmpeg recording process for {path}", _targetPath);
- //process.Kill();
_process.StandardInput.WriteLine("q");
}
catch (Exception ex)
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
index 1e5198dd6..ee975e19a 100644
--- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -881,7 +881,7 @@ namespace Emby.Server.Implementations.LiveTv
}
var programList = _libraryManager.QueryItems(internalQuery).Items;
- var totalCount = programList.Length;
+ var totalCount = programList.Count;
var orderedPrograms = programList.Cast<LiveTvProgram>().OrderBy(i => i.StartDate.Date);
@@ -969,8 +969,8 @@ namespace Emby.Server.Implementations.LiveTv
var timers = new Dictionary<string, List<TimerInfo>>();
var seriesTimers = new Dictionary<string, List<SeriesTimerInfo>>();
- TimerInfo[] timerList = null;
- SeriesTimerInfo[] seriesTimerList = null;
+ IReadOnlyList<TimerInfo> timerList = null;
+ IReadOnlyList<SeriesTimerInfo> seriesTimerList = null;
foreach (var programTuple in programs)
{
@@ -1296,6 +1296,7 @@ namespace Emby.Server.Implementations.LiveTv
}
private const int MaxGuideDays = 14;
+
private double GetGuideDays()
{
var config = GetConfiguration();
@@ -1340,6 +1341,7 @@ namespace Emby.Server.Implementations.LiveTv
excludeItemTypes.Add(typeof(Movie).Name);
}
}
+
if (query.IsSeries.HasValue)
{
if (query.IsSeries.Value)
@@ -1351,10 +1353,12 @@ namespace Emby.Server.Implementations.LiveTv
excludeItemTypes.Add(typeof(Episode).Name);
}
}
+
if (query.IsSports ?? false)
{
genres.Add("Sports");
}
+
if (query.IsKids ?? false)
{
genres.Add("Kids");
@@ -1400,20 +1404,20 @@ namespace Emby.Server.Implementations.LiveTv
if (query.IsInProgress ?? false)
{
- //TODO Fix The co-variant conversion between Video[] and BaseItem[], this can generate runtime issues.
+ // TODO: Fix The co-variant conversion between Video[] and BaseItem[], this can generate runtime issues.
result.Items = result
.Items
.OfType<Video>()
.Where(i => !i.IsCompleteMedia)
.ToArray();
- result.TotalRecordCount = result.Items.Length;
+ result.TotalRecordCount = result.Items.Count;
}
return result;
}
- public Task AddInfoToProgramDto(List<Tuple<BaseItem, BaseItemDto>> tuples, ItemFields[] fields, User user = null)
+ public Task AddInfoToProgramDto(IReadOnlyCollection<(BaseItem, BaseItemDto)> tuples, ItemFields[] fields, User user = null)
{
var programTuples = new List<Tuple<BaseItemDto, string, string>>();
var hasChannelImage = fields.Contains(ItemFields.ChannelImage);
@@ -1877,7 +1881,7 @@ namespace Emby.Server.Implementations.LiveTv
return _libraryManager.GetItemById(internalChannelId);
}
- public void AddChannelInfo(List<Tuple<BaseItemDto, LiveTvChannel>> tuples, DtoOptions options, User user)
+ public void AddChannelInfo(IReadOnlyCollection<(BaseItemDto, LiveTvChannel)> tuples, DtoOptions options, User user)
{
var now = DateTime.UtcNow;
diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
index 52d07d784..840aca7a6 100644
--- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
+++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
@@ -139,7 +139,7 @@ namespace Emby.Server.Implementations.MediaEncoder
var protocol = MediaProtocol.File;
- var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, Array.Empty<string>());
+ var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, null, Array.Empty<string>());
Directory.CreateDirectory(Path.GetDirectoryName(path));
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodingTempTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs
index ad9b56535..c343a7d48 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodingTempTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs
@@ -13,23 +13,22 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// <summary>
/// Deletes all transcoding temp files
/// </summary>
- public class DeleteTranscodingTempTask : IScheduledTask, IConfigurableScheduledTask
+ public class DeleteTranscodeFileTask : IScheduledTask, IConfigurableScheduledTask
{
/// <summary>
/// Gets or sets the application paths.
/// </summary>
/// <value>The application paths.</value>
- protected ServerApplicationPaths ApplicationPaths { get; set; }
-
+ private ServerApplicationPaths ApplicationPaths { get; set; }
private readonly ILogger _logger;
private readonly IFileSystem _fileSystem;
/// <summary>
- /// Initializes a new instance of the <see cref="DeleteTranscodingTempTask" /> class.
+ /// Initializes a new instance of the <see cref="DeleteTranscodeFileTask" /> class.
/// </summary>
- public DeleteTranscodingTempTask(ServerApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem)
+ public DeleteTranscodeFileTask(ServerApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem)
{
ApplicationPaths = appPaths;
_logger = logger;
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs
index 1a3d85ad7..3e6d251c9 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs
@@ -10,7 +10,7 @@ using MediaBrowser.Model.Tasks;
namespace Emby.Server.Implementations.ScheduledTasks
{
/// <summary>
- /// Class RefreshMediaLibraryTask
+ /// Class RefreshMediaLibraryTask.
/// </summary>
public class RefreshMediaLibraryTask : IScheduledTask
{
@@ -31,15 +31,14 @@ namespace Emby.Server.Implementations.ScheduledTasks
}
/// <summary>
- /// Creates the triggers that define when the task will run
+ /// Creates the triggers that define when the task will run.
/// </summary>
/// <returns>IEnumerable{BaseTaskTrigger}.</returns>
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
- return new[] {
-
- // Every so often
- new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(12).Ticks}
+ yield return new TaskTriggerInfo
+ {
+ Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(12).Ticks
};
}
@@ -60,7 +59,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
public string Name => "Scan media library";
- public string Description => "Scans your media library and refreshes metatata based on configuration.";
+ public string Description => "Scans your media library for new files and refreshes metadata.";
public string Category => "Library";
diff --git a/Emby.Server.Implementations/Services/ResponseHelper.cs b/Emby.Server.Implementations/Services/ResponseHelper.cs
index ca2b22fe0..a566b18dd 100644
--- a/Emby.Server.Implementations/Services/ResponseHelper.cs
+++ b/Emby.Server.Implementations/Services/ResponseHelper.cs
@@ -6,8 +6,8 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Emby.Server.Implementations.HttpServer;
-using Microsoft.AspNetCore.Http;
using MediaBrowser.Model.Services;
+using Microsoft.AspNetCore.Http;
namespace Emby.Server.Implementations.Services
{
diff --git a/Emby.Server.Implementations/Services/ServiceExec.cs b/Emby.Server.Implementations/Services/ServiceExec.cs
index 9124b9c14..9f5f97028 100644
--- a/Emby.Server.Implementations/Services/ServiceExec.cs
+++ b/Emby.Server.Implementations/Services/ServiceExec.cs
@@ -87,8 +87,7 @@ namespace Emby.Server.Implementations.Services
var response = actionContext.ServiceAction(instance, requestDto);
- var taskResponse = response as Task;
- if (taskResponse != null)
+ if (response is Task taskResponse)
{
return GetTaskResult(taskResponse);
}
@@ -104,8 +103,7 @@ namespace Emby.Server.Implementations.Services
{
try
{
- var taskObject = task as Task<object>;
- if (taskObject != null)
+ if (task is Task<object> taskObject)
{
return await taskObject.ConfigureAwait(false);
}
@@ -136,7 +134,7 @@ namespace Emby.Server.Implementations.Services
}
catch (TypeAccessException)
{
- return null; //return null for void Task's
+ return null; // return null for void Task's
}
}
@@ -155,29 +153,22 @@ namespace Emby.Server.Implementations.Services
Id = ServiceMethod.Key(serviceType, actionName, requestType.GetMethodName())
};
- try
- {
- actionCtx.ServiceAction = CreateExecFn(serviceType, requestType, mi);
- }
- catch
- {
- //Potential problems with MONO, using reflection for fallback
- actionCtx.ServiceAction = (service, request) =>
- mi.Invoke(service, new[] { request });
- }
+ actionCtx.ServiceAction = CreateExecFn(serviceType, requestType, mi);
var reqFilters = new List<IHasRequestFilter>();
foreach (var attr in mi.GetCustomAttributes(true))
{
- var hasReqFilter = attr as IHasRequestFilter;
-
- if (hasReqFilter != null)
+ if (attr is IHasRequestFilter hasReqFilter)
+ {
reqFilters.Add(hasReqFilter);
+ }
}
if (reqFilters.Count > 0)
+ {
actionCtx.RequestFilters = reqFilters.OrderBy(i => i.Priority).ToArray();
+ }
actions.Add(actionCtx);
}
@@ -198,15 +189,19 @@ namespace Emby.Server.Implementations.Services
if (mi.ReturnType != typeof(void))
{
- var executeFunc = Expression.Lambda<ActionInvokerFn>
- (callExecute, serviceParam, requestDtoParam).Compile();
+ var executeFunc = Expression.Lambda<ActionInvokerFn>(
+ callExecute,
+ serviceParam,
+ requestDtoParam).Compile();
return executeFunc;
}
else
{
- var executeFunc = Expression.Lambda<VoidActionInvokerFn>
- (callExecute, serviceParam, requestDtoParam).Compile();
+ var executeFunc = Expression.Lambda<VoidActionInvokerFn>(
+ callExecute,
+ serviceParam,
+ requestDtoParam).Compile();
return (service, request) =>
{
diff --git a/Emby.Server.Implementations/Services/UrlExtensions.cs b/Emby.Server.Implementations/Services/UrlExtensions.cs
index 8899fbfa3..5d4407f3b 100644
--- a/Emby.Server.Implementations/Services/UrlExtensions.cs
+++ b/Emby.Server.Implementations/Services/UrlExtensions.cs
@@ -12,10 +12,10 @@ namespace Emby.Server.Implementations.Services
{
public static string GetMethodName(this Type type)
{
- var typeName = type.FullName != null //can be null, e.g. generic types
- ? LeftPart(type.FullName, "[[") //Generic Fullname
- .Replace(type.Namespace + ".", "") //Trim Namespaces
- .Replace("+", ".") //Convert nested into normal type
+ var typeName = type.FullName != null // can be null, e.g. generic types
+ ? LeftPart(type.FullName, "[[") // Generic Fullname
+ .Replace(type.Namespace + ".", string.Empty) // Trim Namespaces
+ .Replace("+", ".") // Convert nested into normal type
: type.Name;
return type.IsGenericParameter ? "'" + typeName : typeName;
@@ -23,7 +23,11 @@ namespace Emby.Server.Implementations.Services
private static string LeftPart(string strVal, string needle)
{
- if (strVal == null) return null;
+ if (strVal == null)
+ {
+ return null;
+ }
+
var pos = strVal.IndexOf(needle, StringComparison.OrdinalIgnoreCase);
return pos == -1
? strVal
diff --git a/Emby.Server.Implementations/Sorting/ArtistComparer.cs b/Emby.Server.Implementations/Sorting/ArtistComparer.cs
index 9d5befc9a..756d3c5b6 100644
--- a/Emby.Server.Implementations/Sorting/ArtistComparer.cs
+++ b/Emby.Server.Implementations/Sorting/ArtistComparer.cs
@@ -7,16 +7,14 @@ using MediaBrowser.Model.Querying;
namespace Emby.Server.Implementations.Sorting
{
/// <summary>
- /// Class ArtistComparer
+ /// Class ArtistComparer.
/// </summary>
public class ArtistComparer : IBaseItemComparer
{
- /// <summary>
- /// Compares the specified x.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <param name="y">The y.</param>
- /// <returns>System.Int32.</returns>
+ /// <inheritdoc />
+ public string Name => ItemSortBy.Artist;
+
+ /// <inheritdoc />
public int Compare(BaseItem x, BaseItem y)
{
return string.Compare(GetValue(x), GetValue(y), StringComparison.CurrentCultureIgnoreCase);
@@ -29,20 +27,12 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.String.</returns>
private static string GetValue(BaseItem x)
{
- var audio = x as Audio;
-
- if (audio == null)
+ if (!(x is Audio audio))
{
return string.Empty;
}
- return audio.Artists.Length == 0 ? null : audio.Artists[0];
+ return audio.Artists.Count == 0 ? null : audio.Artists[0];
}
-
- /// <summary>
- /// Gets the name.
- /// </summary>
- /// <value>The name.</value>
- public string Name => ItemSortBy.Artist;
}
}
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs
index 8a4d6e216..3a15c3776 100644
--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs
+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs
@@ -741,7 +741,7 @@ namespace MediaBrowser.Api.LiveTv
var result = new QueryResult<BaseItemDto>
{
Items = returnArray,
- TotalRecordCount = returnArray.Length
+ TotalRecordCount = returnArray.Count
};
return ToOptimizedResult(result);
diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs
index d601fb500..c1c6ffc2e 100644
--- a/MediaBrowser.Api/Movies/MoviesService.cs
+++ b/MediaBrowser.Api/Movies/MoviesService.cs
@@ -243,7 +243,7 @@ namespace MediaBrowser.Api.Movies
}
}
- return categories.OrderBy(i => i.RecommendationType).ThenBy(i => Guid.NewGuid());
+ return categories.OrderBy(i => i.RecommendationType);
}
private IEnumerable<RecommendationDto> GetWithDirector(User user, IEnumerable<string> names, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
diff --git a/MediaBrowser.Api/Music/AlbumsService.cs b/MediaBrowser.Api/Music/AlbumsService.cs
index c48bcde5c..2cd3a1003 100644
--- a/MediaBrowser.Api/Music/AlbumsService.cs
+++ b/MediaBrowser.Api/Music/AlbumsService.cs
@@ -104,16 +104,15 @@ namespace MediaBrowser.Api.Music
var album2 = (MusicAlbum)item2;
var artists1 = album1
- .AllArtists
+ .GetAllArtists()
.DistinctNames()
.ToList();
- var artists2 = album2
- .AllArtists
- .DistinctNames()
- .ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
+ var artists2 = new HashSet<string>(
+ album2.GetAllArtists().DistinctNames(),
+ StringComparer.OrdinalIgnoreCase);
- return points + artists1.Where(artists2.ContainsKey).Sum(i => 5);
+ return points + artists1.Where(artists2.Contains).Sum(i => 5);
}
}
}
diff --git a/MediaBrowser.Api/PlaylistService.cs b/MediaBrowser.Api/PlaylistService.cs
index 482c1a2a8..483bf98fb 100644
--- a/MediaBrowser.Api/PlaylistService.cs
+++ b/MediaBrowser.Api/PlaylistService.cs
@@ -189,11 +189,9 @@ namespace MediaBrowser.Api
var dtos = _dtoService.GetBaseItemDtos(items.Select(i => i.Item2).ToList(), dtoOptions, user);
- var index = 0;
- foreach (var item in dtos)
+ for (int index = 0; index < dtos.Count; index++)
{
- item.PlaylistItemId = items[index].Item1.Id;
- index++;
+ dtos[index].PlaylistItemId = items[index].Item1.Id;
}
var result = new QueryResult<BaseItemDto>
diff --git a/MediaBrowser.Api/SuggestionsService.cs b/MediaBrowser.Api/SuggestionsService.cs
index 72fdae365..4e857eafc 100644
--- a/MediaBrowser.Api/SuggestionsService.cs
+++ b/MediaBrowser.Api/SuggestionsService.cs
@@ -61,11 +61,6 @@ namespace MediaBrowser.Api
var dtoList = _dtoService.GetBaseItemDtos(result.Items, dtoOptions, user);
- if (dtoList == null)
- {
- throw new InvalidOperationException("GetBaseItemDtos returned null");
- }
-
return new QueryResult<BaseItemDto>
{
TotalRecordCount = result.TotalRecordCount,
diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs
index 2951fa6b4..1340bd8ef 100644
--- a/MediaBrowser.Api/TvShowsService.cs
+++ b/MediaBrowser.Api/TvShowsService.cs
@@ -382,13 +382,13 @@ namespace MediaBrowser.Api
throw new ResourceNotFoundException("Series not found");
}
- var seasons = (series.GetItemList(new InternalItemsQuery(user)
+ var seasons = series.GetItemList(new InternalItemsQuery(user)
{
IsMissing = request.IsMissing,
IsSpecialSeason = request.IsSpecialSeason,
AdjacentTo = request.AdjacentTo
- }));
+ });
var dtoOptions = GetDtoOptions(_authContext, request);
@@ -396,7 +396,7 @@ namespace MediaBrowser.Api
return new QueryResult<BaseItemDto>
{
- TotalRecordCount = returnItems.Length,
+ TotalRecordCount = returnItems.Count,
Items = returnItems
};
}
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index a1e976bed..ada540ba6 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -175,11 +175,6 @@ namespace MediaBrowser.Api.UserLibrary
var dtoList = _dtoService.GetBaseItemDtos(result.Items, dtoOptions, user);
- if (dtoList == null)
- {
- throw new InvalidOperationException("GetBaseItemDtos returned null");
- }
-
return new QueryResult<BaseItemDto>
{
TotalRecordCount = result.TotalRecordCount,
diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
index 6eaa1b692..45694a678 100644
--- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
+++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
@@ -2,6 +2,7 @@ using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
@@ -367,12 +368,20 @@ namespace MediaBrowser.Api.UserLibrary
var dtoOptions = GetDtoOptions(_authContext, request);
var dtosExtras = item.GetExtras(new[] { ExtraType.Trailer })
- .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
+ .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item))
+ .ToArray();
- var dtosTrailers = item.GetTrailers()
- .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
+ if (item is IHasTrailers hasTrailers)
+ {
+ var trailers = hasTrailers.GetTrailers();
+ var dtosTrailers = _dtoService.GetBaseItemDtos(trailers, dtoOptions, user, item);
+ var allTrailers = new BaseItemDto[dtosExtras.Length + dtosTrailers.Count];
+ dtosExtras.CopyTo(allTrailers, 0);
+ dtosTrailers.CopyTo(allTrailers, dtosExtras.Length);
+ return ToOptimizedResult(allTrailers);
+ }
- return ToOptimizedResult(dtosExtras.Concat(dtosTrailers).ToArray());
+ return ToOptimizedResult(dtosExtras);
}
/// <summary>
diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs
index 0192805b8..2c0a0b443 100644
--- a/MediaBrowser.Api/UserService.cs
+++ b/MediaBrowser.Api/UserService.cs
@@ -248,9 +248,14 @@ namespace MediaBrowser.Api
private readonly INetworkManager _networkManager;
private readonly IDeviceManager _deviceManager;
private readonly IAuthorizationContext _authContext;
- private readonly ILogger _logger;
- public UserService(IUserManager userManager, ISessionManager sessionMananger, IServerConfigurationManager config, INetworkManager networkManager, IDeviceManager deviceManager, IAuthorizationContext authContext, ILoggerFactory loggerFactory)
+ public UserService(
+ IUserManager userManager,
+ ISessionManager sessionMananger,
+ IServerConfigurationManager config,
+ INetworkManager networkManager,
+ IDeviceManager deviceManager,
+ IAuthorizationContext authContext)
{
_userManager = userManager;
_sessionMananger = sessionMananger;
@@ -258,7 +263,6 @@ namespace MediaBrowser.Api
_networkManager = networkManager;
_deviceManager = deviceManager;
_authContext = authContext;
- _logger = loggerFactory.CreateLogger(nameof(UserService));
}
public object Get(GetPublicUsers request)
diff --git a/MediaBrowser.Common/Extensions/CollectionExtensions.cs b/MediaBrowser.Common/Extensions/CollectionExtensions.cs
index f7c0e3cf0..3bc0295a0 100644
--- a/MediaBrowser.Common/Extensions/CollectionExtensions.cs
+++ b/MediaBrowser.Common/Extensions/CollectionExtensions.cs
@@ -10,5 +10,22 @@ namespace MediaBrowser.Common.Extensions
dictionary.TryGetValue(key, out var ret);
return ret;
}
+
+ // REVIEW: Inline?
+ /// <summary>
+ /// Copies all the elements of the current collection to the specified list
+ /// starting at the specified destination array index. The index is specified as a 32-bit integer.
+ /// </summary>
+ /// <param name="source">The current collection that is the source of the elements.</param>
+ /// <param name="destination">The list that is the destination of the elements copied from the current collection.</param>
+ /// <param name="index">A 32-bit integer that represents the index in <c>destination</c> at which copying begins.</param>
+ /// <typeparam name="T"></typeparam>
+ public static void CopyTo<T>(this IReadOnlyCollection<T> source, IList<T> destination, int index = 0)
+ {
+ foreach (T item in source)
+ {
+ destination[index++] = item;
+ }
+ }
}
}
diff --git a/MediaBrowser.Common/Net/CustomHeaderNames.cs b/MediaBrowser.Common/Net/CustomHeaderNames.cs
index ff148dc80..bda897ed9 100644
--- a/MediaBrowser.Common/Net/CustomHeaderNames.cs
+++ b/MediaBrowser.Common/Net/CustomHeaderNames.cs
@@ -8,4 +8,4 @@ namespace MediaBrowser.Common.Net
public const string XForwardedProto = "X-Forwarded-Proto";
public const string XRealIP = "X-Real-IP";
}
-} \ No newline at end of file
+}
diff --git a/MediaBrowser.Controller/Dto/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.cs
index 4b6fd58fe..ba693a065 100644
--- a/MediaBrowser.Controller/Dto/IDtoService.cs
+++ b/MediaBrowser.Controller/Dto/IDtoService.cs
@@ -57,7 +57,7 @@ namespace MediaBrowser.Controller.Dto
/// <param name="options">The options.</param>
/// <param name="user">The user.</param>
/// <param name="owner">The owner.</param>
- BaseItemDto[] GetBaseItemDtos(IReadOnlyList<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null);
+ IReadOnlyList<BaseItemDto> GetBaseItemDtos(IReadOnlyList<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null);
/// <summary>
/// Gets the item by name dto.
diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs
index 13a6fe44a..67b21068a 100644
--- a/MediaBrowser.Controller/Entities/Audio/Audio.cs
+++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
@@ -19,15 +20,13 @@ namespace MediaBrowser.Controller.Entities.Audio
IHasLookupInfo<SongInfo>,
IHasMediaSources
{
- /// <summary>
- /// Gets or sets the artist.
- /// </summary>
- /// <value>The artist.</value>
+ /// <inheritdoc />
[IgnoreDataMember]
- public string[] Artists { get; set; }
+ public IReadOnlyList<string> Artists { get; set; }
+ /// <inheritdoc />
[IgnoreDataMember]
- public string[] AlbumArtists { get; set; }
+ public IReadOnlyList<string> AlbumArtists { get; set; }
public Audio()
{
@@ -64,30 +63,6 @@ namespace MediaBrowser.Controller.Entities.Audio
}
[IgnoreDataMember]
- public string[] AllArtists
- {
- get
- {
- var list = new string[AlbumArtists.Length + Artists.Length];
-
- var index = 0;
- foreach (var artist in AlbumArtists)
- {
- list[index] = artist;
- index++;
- }
- foreach (var artist in Artists)
- {
- list[index] = artist;
- index++;
- }
-
- return list;
-
- }
- }
-
- [IgnoreDataMember]
public MusicAlbum AlbumEntity => FindParent<MusicAlbum>();
/// <summary>
@@ -125,7 +100,7 @@ namespace MediaBrowser.Controller.Entities.Audio
songKey = Album + "-" + songKey;
}
- var albumArtist = AlbumArtists.Length == 0 ? null : AlbumArtists[0];
+ var albumArtist = AlbumArtists.FirstOrDefault();
if (!string.IsNullOrEmpty(albumArtist))
{
songKey = albumArtist + "-" + songKey;
diff --git a/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs b/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs
index a269b3486..056f31f78 100644
--- a/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs
+++ b/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs
@@ -1,14 +1,35 @@
+using System.Collections.Generic;
+
namespace MediaBrowser.Controller.Entities.Audio
{
public interface IHasAlbumArtist
{
- string[] AlbumArtists { get; set; }
+ IReadOnlyList<string> AlbumArtists { get; set; }
}
public interface IHasArtist
{
- string[] AllArtists { get; }
+ /// <summary>
+ /// Gets or sets the artists.
+ /// </summary>
+ /// <value>The artists.</value>
+ IReadOnlyList<string> Artists { get; set; }
+ }
+
+ public static class Extentions
+ {
+ public static IEnumerable<string> GetAllArtists<T>(this T item)
+ where T : IHasArtist, IHasAlbumArtist
+ {
+ foreach (var i in item.AlbumArtists)
+ {
+ yield return i;
+ }
- string[] Artists { get; set; }
+ foreach (var i in item.Artists)
+ {
+ yield return i;
+ }
+ }
}
}
diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
index 5b2939b75..edf6ffa21 100644
--- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
+++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs
@@ -18,8 +18,11 @@ namespace MediaBrowser.Controller.Entities.Audio
/// </summary>
public class MusicAlbum : Folder, IHasAlbumArtist, IHasArtist, IHasMusicGenres, IHasLookupInfo<AlbumInfo>, IMetadataContainer
{
- public string[] AlbumArtists { get; set; }
- public string[] Artists { get; set; }
+ /// <inheritdoc />
+ public IReadOnlyList<string> AlbumArtists { get; set; }
+
+ /// <inheritdoc />
+ public IReadOnlyList<string> Artists { get; set; }
public MusicAlbum()
{
@@ -41,8 +44,7 @@ namespace MediaBrowser.Controller.Entities.Audio
var parents = GetParents();
foreach (var parent in parents)
{
- var artist = parent as MusicArtist;
- if (artist != null)
+ if (parent is MusicArtist artist)
{
return artist;
}
@@ -63,30 +65,7 @@ namespace MediaBrowser.Controller.Entities.Audio
public override bool SupportsCumulativeRunTimeTicks => true;
[IgnoreDataMember]
- public string[] AllArtists
- {
- get
- {
- var list = new string[AlbumArtists.Length + Artists.Length];
-
- var index = 0;
- foreach (var artist in AlbumArtists)
- {
- list[index] = artist;
- index++;
- }
- foreach (var artist in Artists)
- {
- list[index] = artist;
- index++;
- }
-
- return list;
- }
- }
-
- [IgnoreDataMember]
- public string AlbumArtist => AlbumArtists.Length == 0 ? null : AlbumArtists[0];
+ public string AlbumArtist => AlbumArtists.FirstOrDefault();
[IgnoreDataMember]
public override bool SupportsPeople => false;
@@ -216,8 +195,7 @@ namespace MediaBrowser.Controller.Entities.Audio
private async Task RefreshArtists(MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
{
- var all = AllArtists;
- foreach (var i in all)
+ foreach (var i in this.GetAllArtists())
{
// This should not be necessary but we're seeing some cases of it
if (string.IsNullOrEmpty(i))
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 38e4db3cf..0e9f7ee44 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -2871,16 +2871,16 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the remote trailers.
/// </summary>
/// <value>The remote trailers.</value>
- public MediaUrl[] RemoteTrailers { get; set; }
+ public IReadOnlyList<MediaUrl> RemoteTrailers { get; set; }
public IEnumerable<BaseItem> GetExtras()
{
return ExtraIds.Select(LibraryManager.GetItemById).Where(i => i != null).OrderBy(i => i.SortName);
}
- public IEnumerable<BaseItem> GetExtras(ExtraType[] extraTypes)
+ public IEnumerable<BaseItem> GetExtras(IReadOnlyCollection<ExtraType> extraTypes)
{
- return ExtraIds.Select(LibraryManager.GetItemById).Where(i => i != null && extraTypes.Contains(i.ExtraType.Value)).OrderBy(i => i.SortName);
+ return ExtraIds.Select(LibraryManager.GetItemById).Where(i => i != null && extraTypes.Contains(i.ExtraType.Value));
}
public IEnumerable<BaseItem> GetTrailers()
@@ -2908,7 +2908,7 @@ namespace MediaBrowser.Controller.Entities
}
// Possible types of extra videos
- public static ExtraType[] DisplayExtraTypes = new[] { Model.Entities.ExtraType.BehindTheScenes, Model.Entities.ExtraType.Clip, Model.Entities.ExtraType.DeletedScene, Model.Entities.ExtraType.Interview, Model.Entities.ExtraType.Sample, Model.Entities.ExtraType.Scene };
+ public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new[] { Model.Entities.ExtraType.BehindTheScenes, Model.Entities.ExtraType.Clip, Model.Entities.ExtraType.DeletedScene, Model.Entities.ExtraType.Interview, Model.Entities.ExtraType.Sample, Model.Entities.ExtraType.Scene };
public virtual bool SupportsExternalTransfer => false;
}
diff --git a/MediaBrowser.Controller/Entities/Extensions.cs b/MediaBrowser.Controller/Entities/Extensions.cs
index f3bddd29c..d2ca11740 100644
--- a/MediaBrowser.Controller/Entities/Extensions.cs
+++ b/MediaBrowser.Controller/Entities/Extensions.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Entities
@@ -28,13 +29,17 @@ namespace MediaBrowser.Controller.Entities
Url = url
};
- if (item.RemoteTrailers.Length == 0)
+ if (item.RemoteTrailers.Count == 0)
{
item.RemoteTrailers = new[] { mediaUrl };
}
else
{
- item.RemoteTrailers = item.RemoteTrailers.Concat(new[] { mediaUrl }).ToArray();
+ var oldIds = item.RemoteTrailers;
+ var newIds = new MediaUrl[oldIds.Count + 1];
+ oldIds.CopyTo(newIds);
+ newIds[oldIds.Count] = mediaUrl;
+ item.RemoteTrailers = newIds;
}
}
}
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs
index d841b7ef8..d61a07066 100644
--- a/MediaBrowser.Controller/Entities/Folder.cs
+++ b/MediaBrowser.Controller/Entities/Folder.cs
@@ -666,36 +666,36 @@ namespace MediaBrowser.Controller.Entities
query.StartIndex = null;
query.Limit = null;
- var itemsList = LibraryManager.GetItemList(query);
+ IEnumerable<BaseItem> itemsList = LibraryManager.GetItemList(query);
var user = query.User;
if (user != null)
{
// needed for boxsets
- itemsList = itemsList.Where(i => i.IsVisibleStandalone(query.User)).ToList();
+ itemsList = itemsList.Where(i => i.IsVisibleStandalone(query.User));
}
- BaseItem[] returnItems;
+ IEnumerable<BaseItem> returnItems;
int totalCount = 0;
if (query.EnableTotalRecordCount)
{
- var itemsArray = itemsList.ToArray();
- totalCount = itemsArray.Length;
- returnItems = itemsArray;
+ var itemArray = itemsList.ToArray();
+ totalCount = itemArray.Length;
+ returnItems = itemArray;
}
else
{
- returnItems = itemsList.ToArray();
+ returnItems = itemsList;
}
if (limit.HasValue)
{
- returnItems = returnItems.Skip(startIndex ?? 0).Take(limit.Value).ToArray();
+ returnItems = returnItems.Skip(startIndex ?? 0).Take(limit.Value);
}
else if (startIndex.HasValue)
{
- returnItems = returnItems.Skip(startIndex.Value).ToArray();
+ returnItems = returnItems.Skip(startIndex.Value);
}
return new QueryResult<BaseItem>
diff --git a/MediaBrowser.Controller/Entities/IHasTrailers.cs b/MediaBrowser.Controller/Entities/IHasTrailers.cs
index 3bdb9b64a..dd8e3c45f 100644
--- a/MediaBrowser.Controller/Entities/IHasTrailers.cs
+++ b/MediaBrowser.Controller/Entities/IHasTrailers.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Entities
@@ -11,29 +10,82 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the remote trailers.
/// </summary>
/// <value>The remote trailers.</value>
- MediaUrl[] RemoteTrailers { get; set; }
+ IReadOnlyList<MediaUrl> RemoteTrailers { get; set; }
/// <summary>
/// Gets or sets the local trailer ids.
/// </summary>
/// <value>The local trailer ids.</value>
- Guid[] LocalTrailerIds { get; set; }
- Guid[] RemoteTrailerIds { get; set; }
+ IReadOnlyList<Guid> LocalTrailerIds { get; set; }
+
+ /// <summary>
+ /// Gets or sets the remote trailer ids.
+ /// </summary>
+ /// <value>The remote trailer ids.</value>
+ IReadOnlyList<Guid> RemoteTrailerIds { get; set; }
+
Guid Id { get; set; }
}
+ /// <summary>
+ /// Class providing extension methods for working with <see cref="IHasTrailers" />.
+ /// </summary>
public static class HasTrailerExtensions
{
/// <summary>
+ /// Gets the trailer count.
+ /// </summary>
+ /// <returns><see cref="IReadOnlyList{Guid}" />.</returns>
+ public static int GetTrailerCount(this IHasTrailers item)
+ => item.LocalTrailerIds.Count + item.RemoteTrailerIds.Count;
+
+ /// <summary>
/// Gets the trailer ids.
/// </summary>
- /// <returns>List&lt;Guid&gt;.</returns>
- public static List<Guid> GetTrailerIds(this IHasTrailers item)
+ /// <returns><see cref="IReadOnlyList{Guid}" />.</returns>
+ public static IReadOnlyList<Guid> GetTrailerIds(this IHasTrailers item)
{
- var list = item.LocalTrailerIds.ToList();
- list.AddRange(item.RemoteTrailerIds);
- return list;
+ var localIds = item.LocalTrailerIds;
+ var remoteIds = item.RemoteTrailerIds;
+
+ var all = new Guid[localIds.Count + remoteIds.Count];
+ var index = 0;
+ foreach (var id in localIds)
+ {
+ all[index++] = id;
+ }
+
+ foreach (var id in remoteIds)
+ {
+ all[index++] = id;
+ }
+
+ return all;
}
+ /// <summary>
+ /// Gets the trailers.
+ /// </summary>
+ /// <returns><see cref="IReadOnlyList{BaseItem}" />.</returns>
+ public static IReadOnlyList<BaseItem> GetTrailers(this IHasTrailers item)
+ {
+ var localIds = item.LocalTrailerIds;
+ var remoteIds = item.RemoteTrailerIds;
+ var libraryManager = BaseItem.LibraryManager;
+
+ var all = new BaseItem[localIds.Count + remoteIds.Count];
+ var index = 0;
+ foreach (var id in localIds)
+ {
+ all[index++] = libraryManager.GetItemById(id);
+ }
+
+ foreach (var id in remoteIds)
+ {
+ all[index++] = libraryManager.GetItemById(id);
+ }
+
+ return all;
+ }
}
}
diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
index a532b5ee9..e7ac2a05c 100644
--- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
+++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
@@ -33,8 +33,11 @@ namespace MediaBrowser.Controller.Entities.Movies
[IgnoreDataMember]
public override bool SupportsPeople => true;
- public Guid[] LocalTrailerIds { get; set; }
- public Guid[] RemoteTrailerIds { get; set; }
+ /// <inheritdoc />
+ public IReadOnlyList<Guid> LocalTrailerIds { get; set; }
+
+ /// <inheritdoc />
+ public IReadOnlyList<Guid> RemoteTrailerIds { get; set; }
/// <summary>
/// Gets or sets the display order.
@@ -61,7 +64,8 @@ namespace MediaBrowser.Controller.Entities.Movies
{
return base.GetNonCachedChildren(directoryService);
}
- return new List<BaseItem>();
+
+ return Enumerable.Empty<BaseItem>();
}
protected override List<BaseItem> LoadChildren()
diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs
index 20c5b3521..184528fdc 100644
--- a/MediaBrowser.Controller/Entities/Movies/Movie.cs
+++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs
@@ -27,8 +27,11 @@ namespace MediaBrowser.Controller.Entities.Movies
RemoteTrailerIds = Array.Empty<Guid>();
}
- public Guid[] LocalTrailerIds { get; set; }
- public Guid[] RemoteTrailerIds { get; set; }
+ /// <inheritdoc />
+ public IReadOnlyList<Guid> LocalTrailerIds { get; set; }
+
+ /// <inheritdoc />
+ public IReadOnlyList<Guid> RemoteTrailerIds { get; set; }
/// <summary>
/// Gets or sets the name of the TMDB collection.
diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs
index 5bf082b7e..94fe11e9d 100644
--- a/MediaBrowser.Controller/Entities/MusicVideo.cs
+++ b/MediaBrowser.Controller/Entities/MusicVideo.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
@@ -8,17 +9,15 @@ namespace MediaBrowser.Controller.Entities
{
public class MusicVideo : Video, IHasArtist, IHasMusicGenres, IHasLookupInfo<MusicVideoInfo>
{
+ /// <inheritdoc />
[IgnoreDataMember]
- public string[] Artists { get; set; }
+ public IReadOnlyList<string> Artists { get; set; }
public MusicVideo()
{
Artists = Array.Empty<string>();
}
- [IgnoreDataMember]
- public string[] AllArtists => Artists;
-
public override UnratedItem GetBlockUnratedType()
{
return UnratedItem.Music;
diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs
index fb29c07b0..e67c00fed 100644
--- a/MediaBrowser.Controller/Entities/TV/Episode.cs
+++ b/MediaBrowser.Controller/Entities/TV/Episode.cs
@@ -23,8 +23,11 @@ namespace MediaBrowser.Controller.Entities.TV
RemoteTrailerIds = Array.Empty<Guid>();
}
- public Guid[] LocalTrailerIds { get; set; }
- public Guid[] RemoteTrailerIds { get; set; }
+ /// <inheritdoc />
+ public IReadOnlyList<Guid> LocalTrailerIds { get; set; }
+
+ /// <inheritdoc />
+ public IReadOnlyList<Guid> RemoteTrailerIds { get; set; }
/// <summary>
/// Gets the season in which it aired.
diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs
index 1aacc13c9..a50da9b0a 100644
--- a/MediaBrowser.Controller/Entities/TV/Series.cs
+++ b/MediaBrowser.Controller/Entities/TV/Series.cs
@@ -46,8 +46,11 @@ namespace MediaBrowser.Controller.Entities.TV
[IgnoreDataMember]
public override bool SupportsPeople => true;
- public Guid[] LocalTrailerIds { get; set; }
- public Guid[] RemoteTrailerIds { get; set; }
+ /// <inheritdoc />
+ public IReadOnlyList<Guid> LocalTrailerIds { get; set; }
+
+ /// <inheritdoc />
+ public IReadOnlyList<Guid> RemoteTrailerIds { get; set; }
/// <summary>
/// airdate, dvd or absolute
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
index f99df6c7c..e02c387e4 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
@@ -221,7 +221,7 @@ namespace MediaBrowser.Controller.LiveTv
/// <param name="fields">The fields.</param>
/// <param name="user">The user.</param>
/// <returns>Task.</returns>
- Task AddInfoToProgramDto(List<Tuple<BaseItem, BaseItemDto>> programs, ItemFields[] fields, User user = null);
+ Task AddInfoToProgramDto(IReadOnlyCollection<(BaseItem, BaseItemDto)> programs, ItemFields[] fields, User user = null);
/// <summary>
/// Saves the tuner host.
@@ -258,7 +258,7 @@ namespace MediaBrowser.Controller.LiveTv
/// <param name="items">The items.</param>
/// <param name="options">The options.</param>
/// <param name="user">The user.</param>
- void AddChannelInfo(List<Tuple<BaseItemDto, LiveTvChannel>> items, DtoOptions options, User user);
+ void AddChannelInfo(IReadOnlyCollection<(BaseItemDto, LiveTvChannel)> items, DtoOptions options, User user);
Task<List<ChannelInfo>> GetChannelsForListingsProvider(string id, CancellationToken cancellationToken);
Task<List<ChannelInfo>> GetChannelsFromListingsProviderData(string id, CancellationToken cancellationToken);
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index 87874001a..963091673 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Text;
using System.Threading;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Configuration;
@@ -22,8 +23,17 @@ namespace MediaBrowser.Controller.MediaEncoding
private readonly IMediaEncoder _mediaEncoder;
private readonly IFileSystem _fileSystem;
private readonly ISubtitleEncoder _subtitleEncoder;
- // private readonly IApplicationPaths _appPaths;
- // private readonly IAssemblyInfo _assemblyInfo;
+
+ private static readonly string[] _videoProfiles = new[]
+ {
+ "ConstrainedBaseline",
+ "Baseline",
+ "Extended",
+ "Main",
+ "High",
+ "ProgressiveHigh",
+ "ConstrainedHigh"
+ };
public EncodingHelper(IMediaEncoder mediaEncoder, IFileSystem fileSystem, ISubtitleEncoder subtitleEncoder)
{
@@ -33,14 +43,10 @@ namespace MediaBrowser.Controller.MediaEncoding
}
public string GetH264Encoder(EncodingJobInfo state, EncodingOptions encodingOptions)
- {
- return GetH264OrH265Encoder("libx264", "h264", state, encodingOptions);
- }
+ => GetH264OrH265Encoder("libx264", "h264", state, encodingOptions);
public string GetH265Encoder(EncodingJobInfo state, EncodingOptions encodingOptions)
- {
- return GetH264OrH265Encoder("libx265", "hevc", state, encodingOptions);
- }
+ => GetH264OrH265Encoder("libx265", "hevc", state, encodingOptions);
private string GetH264OrH265Encoder(string defaultEncoder, string hwEncoder, EncodingJobInfo state, EncodingOptions encodingOptions)
{
@@ -64,19 +70,17 @@ namespace MediaBrowser.Controller.MediaEncoding
};
if (!string.IsNullOrEmpty(hwType)
- && encodingOptions.EnableHardwareEncoding && codecMap.ContainsKey(hwType))
+ && encodingOptions.EnableHardwareEncoding
+ && codecMap.ContainsKey(hwType)
+ && CheckVaapi(state, hwType, encodingOptions))
{
- if (CheckVaapi(state, hwType, encodingOptions))
- {
- var preferredEncoder = codecMap[hwType];
+ var preferredEncoder = codecMap[hwType];
- if (_mediaEncoder.SupportsEncoder(preferredEncoder))
- {
- return preferredEncoder;
- }
+ if (_mediaEncoder.SupportsEncoder(preferredEncoder))
+ {
+ return preferredEncoder;
}
}
-
}
// Avoid performing a second attempt when the first one
@@ -106,15 +110,13 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var videoStream = state.VideoStream;
- if (videoStream != null)
+ // vaapi will throw an error with this input
+ // [vaapi @ 0x7faed8000960] No VAAPI support for codec mpeg4 profile -99.
+ if (string.Equals(videoStream?.Codec, "mpeg4", StringComparison.OrdinalIgnoreCase))
{
- // vaapi will throw an error with this input
- // [vaapi @ 0x7faed8000960] No VAAPI support for codec mpeg4 profile -99.
- if (string.Equals(videoStream.Codec, "mpeg4", StringComparison.OrdinalIgnoreCase))
- {
- return false;
- }
+ return false;
}
+
return true;
}
@@ -127,23 +129,27 @@ namespace MediaBrowser.Controller.MediaEncoding
if (!string.IsNullOrEmpty(codec))
{
- if (string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase))
{
return GetH265Encoder(state, encodingOptions);
}
+
if (string.Equals(codec, "h264", StringComparison.OrdinalIgnoreCase))
{
return GetH264Encoder(state, encodingOptions);
}
+
if (string.Equals(codec, "vpx", StringComparison.OrdinalIgnoreCase))
{
return "libvpx";
}
+
if (string.Equals(codec, "wmv", StringComparison.OrdinalIgnoreCase))
{
return "wmv2";
}
+
if (string.Equals(codec, "theora", StringComparison.OrdinalIgnoreCase))
{
return "libtheora";
@@ -162,9 +168,7 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <returns>System.String.</returns>
public string GetUserAgentParam(EncodingJobInfo state)
{
- string useragent = null;
-
- state.RemoteHttpHeaders.TryGetValue("User-Agent", out useragent);
+ state.RemoteHttpHeaders.TryGetValue("User-Agent", out string useragent);
if (!string.IsNullOrEmpty(useragent))
{
@@ -193,50 +197,62 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return null;
}
+
if (string.Equals(container, "wmv", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(container, "mts", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(container, "vob", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(container, "mpg", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(container, "mpeg", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(container, "rec", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(container, "dvr-ms", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(container, "ogm", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(container, "divx", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(container, "tp", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(container, "rmvb", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(container, "rtp", StringComparison.OrdinalIgnoreCase))
{
return null;
@@ -264,10 +280,12 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return null;
}
+
if (string.Equals(codec, "aac_latm", StringComparison.OrdinalIgnoreCase))
{
return null;
}
+
if (string.Equals(codec, "eac3", StringComparison.OrdinalIgnoreCase))
{
return null;
@@ -292,30 +310,37 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return "mp3";
}
+
if (string.Equals(ext, ".aac", StringComparison.OrdinalIgnoreCase))
{
return "aac";
}
+
if (string.Equals(ext, ".wma", StringComparison.OrdinalIgnoreCase))
{
return "wma";
}
+
if (string.Equals(ext, ".ogg", StringComparison.OrdinalIgnoreCase))
{
return "vorbis";
}
+
if (string.Equals(ext, ".oga", StringComparison.OrdinalIgnoreCase))
{
return "vorbis";
}
+
if (string.Equals(ext, ".ogv", StringComparison.OrdinalIgnoreCase))
{
return "vorbis";
}
+
if (string.Equals(ext, ".webm", StringComparison.OrdinalIgnoreCase))
{
return "vorbis";
}
+
if (string.Equals(ext, ".webma", StringComparison.OrdinalIgnoreCase))
{
return "vorbis";
@@ -337,14 +362,17 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return "wmv";
}
+
if (string.Equals(ext, ".webm", StringComparison.OrdinalIgnoreCase))
{
return "vpx";
}
+
if (string.Equals(ext, ".ogg", StringComparison.OrdinalIgnoreCase) || string.Equals(ext, ".ogv", StringComparison.OrdinalIgnoreCase))
{
return "theora";
}
+
if (string.Equals(ext, ".m3u8", StringComparison.OrdinalIgnoreCase) || string.Equals(ext, ".ts", StringComparison.OrdinalIgnoreCase))
{
return "h264";
@@ -355,19 +383,9 @@ namespace MediaBrowser.Controller.MediaEncoding
public int GetVideoProfileScore(string profile)
{
- var list = new[]
- {
- "ConstrainedBaseline",
- "Baseline",
- "Extended",
- "Main",
- "High",
- "ProgressiveHigh",
- "ConstrainedHigh"
- };
-
// strip spaces because they may be stripped out on the query string
- return Array.FindIndex(list, t => string.Equals(t, profile.Replace(" ", ""), StringComparison.OrdinalIgnoreCase));
+ profile = profile.Replace(" ", "");
+ return Array.FindIndex(_videoProfiles, x => string.Equals(x, profile, StringComparison.OrdinalIgnoreCase));
}
public string GetInputPathArgument(EncodingJobInfo state)
@@ -375,14 +393,19 @@ namespace MediaBrowser.Controller.MediaEncoding
var protocol = state.InputProtocol;
var mediaPath = state.MediaPath ?? string.Empty;
- var inputPath = new[] { mediaPath };
-
- if (state.IsInputVideo)
+ string[] inputPath;
+ if (state.IsInputVideo
+ && !(state.VideoType == VideoType.Iso && state.IsoMount == null))
{
- if (!(state.VideoType == VideoType.Iso && state.IsoMount == null))
- {
- inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, mediaPath, state.InputProtocol, state.IsoMount, state.PlayableStreamFileNames);
- }
+ inputPath = MediaEncoderHelpers.GetInputArgument(
+ _fileSystem,
+ mediaPath,
+ state.IsoMount,
+ state.PlayableStreamFileNames);
+ }
+ else
+ {
+ inputPath = new[] { mediaPath };
}
return _mediaEncoder.GetInputArgument(inputPath, protocol);
@@ -401,18 +424,22 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return "aac -strict experimental";
}
+
if (string.Equals(codec, "mp3", StringComparison.OrdinalIgnoreCase))
{
return "libmp3lame";
}
+
if (string.Equals(codec, "vorbis", StringComparison.OrdinalIgnoreCase))
{
return "libvorbis";
}
+
if (string.Equals(codec, "wma", StringComparison.OrdinalIgnoreCase))
{
return "wmav2";
}
+
if (string.Equals(codec, "opus", StringComparison.OrdinalIgnoreCase))
{
return "libopus";
@@ -426,54 +453,59 @@ namespace MediaBrowser.Controller.MediaEncoding
/// </summary>
public string GetInputArgument(EncodingJobInfo state, EncodingOptions encodingOptions)
{
- var request = state.BaseRequest;
-
- var arg = string.Format("-i {0}", GetInputPathArgument(state));
+ var arg = new StringBuilder();
- if (state.SubtitleStream != null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)
+ if (state.IsVideoRequest
+ && string.Equals(encodingOptions.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase))
{
- if (state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)
+ var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
+ var hwOutputFormat = "vaapi";
+
+ if (hasGraphicalSubs)
{
- if (state.VideoStream != null && state.VideoStream.Width.HasValue)
- {
- // This is hacky but not sure how to get the exact subtitle resolution
- int height = Convert.ToInt32((double)state.VideoStream.Width.Value / 16.0 * 9.0);
+ hwOutputFormat = "yuv420p";
+ }
- arg += string.Format(" -canvas_size {0}:{1}", state.VideoStream.Width.Value.ToString(CultureInfo.InvariantCulture), height.ToString(CultureInfo.InvariantCulture));
- }
+ arg.Append("-hwaccel vaapi -hwaccel_output_format ")
+ .Append(hwOutputFormat)
+ .Append(" -vaapi_device ")
+ .Append(encodingOptions.VaapiDevice)
+ .Append(' ');
+ }
- var subtitlePath = state.SubtitleStream.Path;
+ arg.Append("-i ")
+ .Append(GetInputPathArgument(state));
- if (string.Equals(Path.GetExtension(subtitlePath), ".sub", StringComparison.OrdinalIgnoreCase))
- {
- var idxFile = Path.ChangeExtension(subtitlePath, ".idx");
- if (File.Exists(idxFile))
- {
- subtitlePath = idxFile;
- }
- }
+ if (state.SubtitleStream != null
+ && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode
+ && state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)
+ {
+ if (state.VideoStream != null && state.VideoStream.Width.HasValue)
+ {
+ // This is hacky but not sure how to get the exact subtitle resolution
+ int height = Convert.ToInt32(state.VideoStream.Width.Value / 16.0 * 9.0);
- arg += " -i \"" + subtitlePath + "\"";
+ arg.Append(" -canvas_size ")
+ .Append(state.VideoStream.Width.Value.ToString(CultureInfo.InvariantCulture))
+ .Append(':')
+ .Append(height.ToString(CultureInfo.InvariantCulture));
}
- }
- if (state.IsVideoRequest)
- {
- if (GetVideoEncoder(state, encodingOptions).IndexOf("vaapi", StringComparison.OrdinalIgnoreCase) != -1)
- {
- var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
- var hwOutputFormat = "vaapi";
+ var subtitlePath = state.SubtitleStream.Path;
- if (hasGraphicalSubs)
+ if (string.Equals(Path.GetExtension(subtitlePath), ".sub", StringComparison.OrdinalIgnoreCase))
+ {
+ var idxFile = Path.ChangeExtension(subtitlePath, ".idx");
+ if (File.Exists(idxFile))
{
- hwOutputFormat = "yuv420p";
+ subtitlePath = idxFile;
}
-
- arg = "-hwaccel vaapi -hwaccel_output_format " + hwOutputFormat + " -vaapi_device " + encodingOptions.VaapiDevice + " " + arg;
}
+
+ arg.Append(" -i \"").Append(subtitlePath).Append('\"');
}
- return arg.Trim();
+ return arg.ToString();
}
/// <summary>
@@ -485,16 +517,16 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var codec = stream.Codec ?? string.Empty;
- return codec.IndexOf("264", StringComparison.OrdinalIgnoreCase) != -1 ||
- codec.IndexOf("avc", StringComparison.OrdinalIgnoreCase) != -1;
+ return codec.IndexOf("264", StringComparison.OrdinalIgnoreCase) != -1
+ || codec.IndexOf("avc", StringComparison.OrdinalIgnoreCase) != -1;
}
public bool IsH265(MediaStream stream)
{
var codec = stream.Codec ?? string.Empty;
- return codec.IndexOf("265", StringComparison.OrdinalIgnoreCase) != -1 ||
- codec.IndexOf("hevc", StringComparison.OrdinalIgnoreCase) != -1;
+ return codec.IndexOf("265", StringComparison.OrdinalIgnoreCase) != -1
+ || codec.IndexOf("hevc", StringComparison.OrdinalIgnoreCase) != -1;
}
public string GetBitStreamArgs(MediaStream stream)
@@ -523,27 +555,38 @@ namespace MediaBrowser.Controller.MediaEncoding
{
// With vpx when crf is used, b:v becomes a max rate
// https://trac.ffmpeg.org/wiki/vpxEncodingGuide.
- return string.Format(" -maxrate:v {0} -bufsize:v {1} -b:v {0}", bitrate.Value.ToString(_usCulture), (bitrate.Value * 2).ToString(_usCulture));
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ " -maxrate:v {0} -bufsize:v {1} -b:v {0}",
+ bitrate.Value,
+ bitrate.Value * 2);
}
if (string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase))
{
- return string.Format(" -b:v {0}", bitrate.Value.ToString(_usCulture));
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ " -b:v {0}",
+ bitrate.Value);
}
if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase) ||
string.Equals(videoCodec, "libx265", StringComparison.OrdinalIgnoreCase))
{
// h264
- return string.Format(" -maxrate {0} -bufsize {1}",
- bitrate.Value.ToString(_usCulture),
- (bitrate.Value * 2).ToString(_usCulture));
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ " -maxrate {0} -bufsize {1}",
+ bitrate.Value,
+ bitrate.Value * 2);
}
// h264
- return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}",
- bitrate.Value.ToString(_usCulture),
- (bitrate.Value * 2).ToString(_usCulture));
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ " -b:v {0} -maxrate {0} -bufsize {1}",
+ bitrate.Value,
+ bitrate.Value * 2);
}
return string.Empty;
@@ -576,7 +619,7 @@ namespace MediaBrowser.Controller.MediaEncoding
// hls always copies timestamps
var setPtsParam = state.CopyTimestamps || state.TranscodingType != TranscodingJobType.Progressive
? string.Empty
- : string.Format(",setpts=PTS -{0}/TB", seconds.ToString(_usCulture));
+ : string.Format(CultureInfo.InvariantCulture, ",setpts=PTS -{0}/TB", seconds);
// TODO
// var fallbackFontPath = Path.Combine(_appPaths.ProgramDataPath, "fonts", "DroidSansFallback.ttf");
@@ -684,6 +727,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
encodeCrf = encodingOptions.H265Crf;
}
+
if (encodeCrf >= 0 && encodeCrf <= 51)
{
param += " -crf " + encodeCrf.ToString(CultureInfo.InvariantCulture);
@@ -695,12 +739,11 @@ namespace MediaBrowser.Controller.MediaEncoding
{
defaultCrf = "28";
}
+
param += " -crf " + defaultCrf;
}
}
-
- // h264 (h264_qsv)
- else if (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase))
+ else if (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase)) // h264 (h264_qsv)
{
string[] valid_h264_qsv = { "veryslow", "slower", "slow", "medium", "fast", "faster", "veryfast" };
@@ -716,10 +759,8 @@ namespace MediaBrowser.Controller.MediaEncoding
param += " -look_ahead 0";
}
-
- // h264 (h264_nvenc)
- else if (string.Equals(videoEncoder, "h264_nvenc", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(videoEncoder, "hevc_nvenc", StringComparison.OrdinalIgnoreCase))
+ else if (string.Equals(videoEncoder, "h264_nvenc", StringComparison.OrdinalIgnoreCase) // h264 (h264_nvenc)
+ || string.Equals(videoEncoder, "hevc_nvenc", StringComparison.OrdinalIgnoreCase))
{
switch (encodingOptions.EncoderPreset)
{
@@ -750,9 +791,7 @@ namespace MediaBrowser.Controller.MediaEncoding
break;
}
}
-
- // webm
- else if (string.Equals(videoEncoder, "libvpx", StringComparison.OrdinalIgnoreCase))
+ else if (string.Equals(videoEncoder, "libvpx", StringComparison.OrdinalIgnoreCase)) // webm
{
// Values 0-3, 0 being highest quality but slower
var profileScore = 0;
@@ -778,18 +817,14 @@ namespace MediaBrowser.Controller.MediaEncoding
qmin,
qmax);
}
-
else if (string.Equals(videoEncoder, "mpeg4", StringComparison.OrdinalIgnoreCase))
{
param += "-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -bf 2";
}
-
- // asf/wmv
- else if (string.Equals(videoEncoder, "wmv2", StringComparison.OrdinalIgnoreCase))
+ else if (string.Equals(videoEncoder, "wmv2", StringComparison.OrdinalIgnoreCase)) // asf/wmv
{
param += "-qmin 2";
}
-
else if (string.Equals(videoEncoder, "msmpeg4", StringComparison.OrdinalIgnoreCase))
{
param += "-mbd 2";
@@ -805,21 +840,21 @@ namespace MediaBrowser.Controller.MediaEncoding
var targetVideoCodec = state.ActualOutputVideoCodec;
- var request = state.BaseRequest;
var profile = state.GetRequestedProfiles(targetVideoCodec).FirstOrDefault();
// vaapi does not support Baseline profile, force Constrained Baseline in this case,
// which is compatible (and ugly)
- if (string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) &&
- profile != null && profile.ToLowerInvariant().Contains("baseline"))
+ if (string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase)
+ && profile != null
+ && profile.IndexOf("baseline", StringComparison.OrdinalIgnoreCase) != -1)
{
- profile = "constrained_baseline";
+ profile = "constrained_baseline";
}
if (!string.IsNullOrEmpty(profile))
{
- if (!string.Equals(videoEncoder, "h264_omx", StringComparison.OrdinalIgnoreCase) &&
- !string.Equals(videoEncoder, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase))
+ if (!string.Equals(videoEncoder, "h264_omx", StringComparison.OrdinalIgnoreCase)
+ && !string.Equals(videoEncoder, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase))
{
// not supported by h264_omx
param += " -profile:v " + profile;
@@ -834,9 +869,9 @@ namespace MediaBrowser.Controller.MediaEncoding
// h264_qsv and h264_nvenc expect levels to be expressed as a decimal. libx264 supports decimal and non-decimal format
// also needed for libx264 due to https://trac.ffmpeg.org/ticket/3307
- if (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(videoEncoder, "libx264", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(videoEncoder, "libx265", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(videoEncoder, "libx264", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(videoEncoder, "libx265", StringComparison.OrdinalIgnoreCase))
{
switch (level)
{
@@ -872,11 +907,11 @@ namespace MediaBrowser.Controller.MediaEncoding
break;
}
}
- // nvenc doesn't decode with param -level set ?!
- else if (string.Equals(videoEncoder, "h264_nvenc", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(videoEncoder, "hevc_nvenc", StringComparison.OrdinalIgnoreCase))
+ else if (string.Equals(videoEncoder, "h264_nvenc", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(videoEncoder, "hevc_nvenc", StringComparison.OrdinalIgnoreCase))
{
- // todo param += "";
+ // nvenc doesn't decode with param -level set ?!
+ // TODO:
}
else if (!string.Equals(videoEncoder, "h264_omx", StringComparison.OrdinalIgnoreCase))
{
@@ -894,10 +929,10 @@ namespace MediaBrowser.Controller.MediaEncoding
// todo
}
- if (!string.Equals(videoEncoder, "h264_omx", StringComparison.OrdinalIgnoreCase) &&
- !string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) &&
- !string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) &&
- !string.Equals(videoEncoder, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase))
+ if (!string.Equals(videoEncoder, "h264_omx", StringComparison.OrdinalIgnoreCase)
+ && !string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase)
+ && !string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase)
+ && !string.Equals(videoEncoder, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase))
{
param = "-pix_fmt yuv420p " + param;
}
@@ -919,12 +954,10 @@ namespace MediaBrowser.Controller.MediaEncoding
return false;
}
- if (videoStream.IsInterlaced)
+ if (videoStream.IsInterlaced
+ && state.DeInterlace(videoStream.Codec, false))
{
- if (state.DeInterlace(videoStream.Codec, false))
- {
- return false;
- }
+ return false;
}
if (videoStream.IsAnamorphic ?? false)
@@ -936,24 +969,23 @@ namespace MediaBrowser.Controller.MediaEncoding
}
// Can't stream copy if we're burning in subtitles
- if (request.SubtitleStreamIndex.HasValue)
+ if (request.SubtitleStreamIndex.HasValue
+ && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)
{
- if (state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)
- {
- return false;
- }
+ return false;
}
- if (string.Equals("h264", videoStream.Codec, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals("h264", videoStream.Codec, StringComparison.OrdinalIgnoreCase)
+ && videoStream.IsAVC.HasValue
+ && !videoStream.IsAVC.Value
+ && request.RequireAvc)
{
- if (videoStream.IsAVC.HasValue && !videoStream.IsAVC.Value && request.RequireAvc)
- {
- return false;
- }
+ return false;
}
// Source and target codecs must match
- if (string.IsNullOrEmpty(videoStream.Codec) || !state.SupportedVideoCodecs.Contains(videoStream.Codec, StringComparer.OrdinalIgnoreCase))
+ if (string.IsNullOrEmpty(videoStream.Codec)
+ || !state.SupportedVideoCodecs.Contains(videoStream.Codec, StringComparer.OrdinalIgnoreCase))
{
return false;
}
@@ -983,21 +1015,17 @@ namespace MediaBrowser.Controller.MediaEncoding
}
// Video width must fall within requested value
- if (request.MaxWidth.HasValue)
+ if (request.MaxWidth.HasValue
+ && (!videoStream.Width.HasValue || videoStream.Width.Value > request.MaxWidth.Value))
{
- if (!videoStream.Width.HasValue || videoStream.Width.Value > request.MaxWidth.Value)
- {
- return false;
- }
+ return false;
}
// Video height must fall within requested value
- if (request.MaxHeight.HasValue)
+ if (request.MaxHeight.HasValue
+ && (!videoStream.Height.HasValue || videoStream.Height.Value > request.MaxHeight.Value))
{
- if (!videoStream.Height.HasValue || videoStream.Height.Value > request.MaxHeight.Value)
- {
- return false;
- }
+ return false;
}
// Video framerate must fall within requested value
@@ -1013,12 +1041,10 @@ namespace MediaBrowser.Controller.MediaEncoding
}
// Video bitrate must fall within requested value
- if (request.VideoBitRate.HasValue)
+ if (request.VideoBitRate.HasValue
+ && (!videoStream.BitRate.HasValue || videoStream.BitRate.Value > request.VideoBitRate.Value))
{
- if (!videoStream.BitRate.HasValue || videoStream.BitRate.Value > request.VideoBitRate.Value)
- {
- return false;
- }
+ return false;
}
var maxBitDepth = state.GetRequestedVideoBitDepth(videoStream.Codec);
@@ -1031,35 +1057,31 @@ namespace MediaBrowser.Controller.MediaEncoding
}
var maxRefFrames = state.GetRequestedMaxRefFrames(videoStream.Codec);
- if (maxRefFrames.HasValue)
+ if (maxRefFrames.HasValue
+ && videoStream.RefFrames.HasValue && videoStream.RefFrames.Value > maxRefFrames.Value)
{
- if (videoStream.RefFrames.HasValue && videoStream.RefFrames.Value > maxRefFrames.Value)
- {
- return false;
- }
+ return false;
}
// If a specific level was requested, the source must match or be less than
var level = state.GetRequestedLevel(videoStream.Codec);
- if (!string.IsNullOrEmpty(level))
+ if (!string.IsNullOrEmpty(level)
+ && double.TryParse(level, NumberStyles.Any, _usCulture, out var requestLevel))
{
- if (double.TryParse(level, NumberStyles.Any, _usCulture, out var requestLevel))
+ if (!videoStream.Level.HasValue)
{
- if (!videoStream.Level.HasValue)
- {
- //return false;
- }
+ //return false;
+ }
- if (videoStream.Level.HasValue && videoStream.Level.Value > requestLevel)
- {
- return false;
- }
+ if (videoStream.Level.HasValue && videoStream.Level.Value > requestLevel)
+ {
+ return false;
}
}
- if (string.Equals(state.InputContainer, "avi", StringComparison.OrdinalIgnoreCase) &&
- string.Equals(videoStream.Codec, "h264", StringComparison.OrdinalIgnoreCase) &&
- !(videoStream.IsAVC ?? false))
+ if (string.Equals(state.InputContainer, "avi", StringComparison.OrdinalIgnoreCase)
+ && string.Equals(videoStream.Codec, "h264", StringComparison.OrdinalIgnoreCase)
+ && !(videoStream.IsAVC ?? false))
{
// see Coach S01E01 - Kelly and the Professor(0).avi
return false;
@@ -1068,7 +1090,7 @@ namespace MediaBrowser.Controller.MediaEncoding
return request.EnableAutoStreamCopy;
}
- public bool CanStreamCopyAudio(EncodingJobInfo state, MediaStream audioStream, string[] supportedAudioCodecs)
+ public bool CanStreamCopyAudio(EncodingJobInfo state, MediaStream audioStream, IEnumerable<string> supportedAudioCodecs)
{
var request = state.BaseRequest;
@@ -1078,16 +1100,16 @@ namespace MediaBrowser.Controller.MediaEncoding
}
var maxBitDepth = state.GetRequestedAudioBitDepth(audioStream.Codec);
- if (maxBitDepth.HasValue)
+ if (maxBitDepth.HasValue
+ && audioStream.BitDepth.HasValue
+ && audioStream.BitDepth.Value > maxBitDepth.Value)
{
- if (audioStream.BitDepth.HasValue && audioStream.BitDepth.Value > maxBitDepth.Value)
- {
- return false;
- }
+ return false;
}
// Source and target codecs must match
- if (string.IsNullOrEmpty(audioStream.Codec) || !supportedAudioCodecs.Contains(audioStream.Codec, StringComparer.OrdinalIgnoreCase))
+ if (string.IsNullOrEmpty(audioStream.Codec)
+ || !supportedAudioCodecs.Contains(audioStream.Codec, StringComparer.OrdinalIgnoreCase))
{
return false;
}
@@ -1100,6 +1122,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return false;
}
+
if (audioStream.Channels.Value > channels.Value)
{
return false;
@@ -1113,6 +1136,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return false;
}
+
if (audioStream.SampleRate.Value > request.AudioSampleRate.Value)
{
return false;
@@ -1126,6 +1150,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return false;
}
+
if (audioStream.BitRate.Value > request.AudioBitRate.Value)
{
return false;
@@ -1141,17 +1166,17 @@ namespace MediaBrowser.Controller.MediaEncoding
if (videoStream != null)
{
- var isUpscaling = request.Height.HasValue && videoStream.Height.HasValue &&
- request.Height.Value > videoStream.Height.Value && request.Width.HasValue && videoStream.Width.HasValue &&
- request.Width.Value > videoStream.Width.Value;
+ var isUpscaling = request.Height.HasValue
+ && videoStream.Height.HasValue
+ && request.Height.Value > videoStream.Height.Value
+ && request.Width.HasValue
+ && videoStream.Width.HasValue
+ && request.Width.Value > videoStream.Width.Value;
// Don't allow bitrate increases unless upscaling
- if (!isUpscaling)
+ if (!isUpscaling && bitrate.HasValue && videoStream.BitRate.HasValue)
{
- if (bitrate.HasValue && videoStream.BitRate.HasValue)
- {
- bitrate = GetMinBitrate(videoStream.BitRate.Value, bitrate.Value);
- }
+ bitrate = GetMinBitrate(videoStream.BitRate.Value, bitrate.Value);
}
}
@@ -1179,7 +1204,7 @@ namespace MediaBrowser.Controller.MediaEncoding
}
else if (sourceBitrate <= 3000000)
{
- sourceBitrate = Convert.ToInt32(sourceBitrate * 2);
+ sourceBitrate *= 2;
}
var bitrate = Math.Min(sourceBitrate, requestedBitrate);
@@ -1189,12 +1214,13 @@ namespace MediaBrowser.Controller.MediaEncoding
private static double GetVideoBitrateScaleFactor(string codec)
{
- if (StringHelper.EqualsIgnoreCase(codec, "h265") ||
- StringHelper.EqualsIgnoreCase(codec, "hevc") ||
- StringHelper.EqualsIgnoreCase(codec, "vp9"))
+ if (string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(codec, "vp9", StringComparison.OrdinalIgnoreCase))
{
return .5;
}
+
return 1;
}
@@ -1221,9 +1247,7 @@ namespace MediaBrowser.Controller.MediaEncoding
scaleFactor = Math.Max(scaleFactor, 2);
}
- var newBitrate = scaleFactor * bitrate;
-
- return Convert.ToInt32(newBitrate);
+ return Convert.ToInt32(scaleFactor * bitrate);
}
public int? GetAudioBitrateParam(BaseEncodingJobOptions request, MediaStream audioStream)
@@ -1235,7 +1259,6 @@ namespace MediaBrowser.Controller.MediaEncoding
// Don't encode any higher than this
return Math.Min(384000, request.AudioBitRate.Value);
- //return Math.Min(currentBitrate, request.AudioBitRate.Value);
}
return null;
@@ -1248,12 +1271,14 @@ namespace MediaBrowser.Controller.MediaEncoding
var filters = new List<string>();
// Boost volume to 200% when downsampling from 6ch to 2ch
- if (channels.HasValue && channels.Value <= 2)
+ if (channels.HasValue
+ && channels.Value <= 2
+ && state.AudioStream != null
+ && state.AudioStream.Channels.HasValue
+ && state.AudioStream.Channels.Value > 5
+ && !encodingOptions.DownMixAudioBoost.Equals(1))
{
- if (state.AudioStream != null && state.AudioStream.Channels.HasValue && state.AudioStream.Channels.Value > 5 && !encodingOptions.DownMixAudioBoost.Equals(1))
- {
- filters.Add("volume=" + encodingOptions.DownMixAudioBoost.ToString(_usCulture));
- }
+ filters.Add("volume=" + encodingOptions.DownMixAudioBoost.ToString(_usCulture));
}
var isCopyingTimestamps = state.CopyTimestamps || state.TranscodingType != TranscodingJobType.Progressive;
@@ -1261,12 +1286,16 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var seconds = TimeSpan.FromTicks(state.StartTimeTicks ?? 0).TotalSeconds;
- filters.Add(string.Format("asetpts=PTS-{0}/TB", Math.Round(seconds).ToString(_usCulture)));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "asetpts=PTS-{0}/TB",
+ Math.Round(seconds)));
}
if (filters.Count > 0)
{
- return "-af \"" + string.Join(",", filters.ToArray()) + "\"";
+ return "-af \"" + string.Join(",", filters) + "\"";
}
return string.Empty;
@@ -1283,18 +1312,17 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var request = state.BaseRequest;
- var inputChannels = audioStream == null
- ? null
- : audioStream.Channels;
+ var inputChannels = audioStream?.Channels;
if (inputChannels <= 0)
{
inputChannels = null;
}
- int? transcoderChannelLimit = null;
var codec = outputAudioCodec ?? string.Empty;
+
+ int? transcoderChannelLimit;
if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1)
{
// wmav2 currently only supports two channel output
@@ -1343,6 +1371,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return val2;
}
+
if (!val2.HasValue)
{
return val1;
@@ -1416,7 +1445,10 @@ namespace MediaBrowser.Controller.MediaEncoding
if (state.VideoStream != null)
{
- args += string.Format("-map 0:{0}", state.VideoStream.Index);
+ args += string.Format(
+ CultureInfo.InvariantCulture,
+ "-map 0:{0}",
+ state.VideoStream.Index);
}
else
{
@@ -1426,7 +1458,10 @@ namespace MediaBrowser.Controller.MediaEncoding
if (state.AudioStream != null)
{
- args += string.Format(" -map 0:{0}", state.AudioStream.Index);
+ args += string.Format(
+ CultureInfo.InvariantCulture,
+ " -map 0:{0}",
+ state.AudioStream.Index);
}
else
@@ -1441,7 +1476,10 @@ namespace MediaBrowser.Controller.MediaEncoding
}
else if (subtitleMethod == SubtitleDeliveryMethod.Embed)
{
- args += string.Format(" -map 0:{0}", state.SubtitleStream.Index);
+ args += string.Format(
+ CultureInfo.InvariantCulture,
+ " -map 0:{0}",
+ state.SubtitleStream.Index);
}
else if (state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)
{
@@ -1493,7 +1531,10 @@ namespace MediaBrowser.Controller.MediaEncoding
var request = state.BaseRequest;
// Add resolution params, if specified
- if (request.Width.HasValue || request.Height.HasValue || request.MaxHeight.HasValue || request.MaxWidth.HasValue)
+ if (request.Width.HasValue
+ || request.Height.HasValue
+ || request.MaxHeight.HasValue
+ || request.MaxWidth.HasValue)
{
outputSizeParam = GetOutputSizeParam(state, options, outputVideoCodec).TrimEnd('"');
@@ -1515,12 +1556,15 @@ namespace MediaBrowser.Controller.MediaEncoding
}
}
- if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase) && outputSizeParam.Length == 0)
+ if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)
+ && outputSizeParam.Length == 0)
{
outputSizeParam = ",format=nv12|vaapi,hwupload";
// Add parameters to use VAAPI with burn-in subttiles (GH issue #642)
- if (state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode) {
+ if (state.SubtitleStream != null
+ && state.SubtitleStream.IsTextSubtitleStream
+ && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode) {
outputSizeParam += ",hwmap=mode=read+write+direct";
}
}
@@ -1529,7 +1573,11 @@ namespace MediaBrowser.Controller.MediaEncoding
if (state.VideoStream != null && state.VideoStream.Width.HasValue && state.VideoStream.Height.HasValue)
{
- videoSizeParam = string.Format("scale={0}:{1}", state.VideoStream.Width.Value.ToString(_usCulture), state.VideoStream.Height.Value.ToString(_usCulture));
+ videoSizeParam = string.Format(
+ CultureInfo.InvariantCulture,
+ "scale={0}:{1}",
+ state.VideoStream.Width.Value,
+ state.VideoStream.Height.Value);
videoSizeParam += ":force_original_aspect_ratio=decrease";
}
@@ -1542,15 +1590,18 @@ namespace MediaBrowser.Controller.MediaEncoding
? 0
: state.SubtitleStream.Index;
- return string.Format(" -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\"",
- mapPrefix.ToString(_usCulture),
- subtitleStreamIndex.ToString(_usCulture),
- state.VideoStream.Index.ToString(_usCulture),
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\"",
+ mapPrefix,
+ subtitleStreamIndex,
+ state.VideoStream.Index,
outputSizeParam,
videoSizeParam);
}
- private ValueTuple<int?, int?> GetFixedOutputSize(int? videoWidth,
+ private (int? width, int? height) GetFixedOutputSize(
+ int? videoWidth,
int? videoHeight,
int? requestedWidth,
int? requestedHeight,
@@ -1559,11 +1610,11 @@ namespace MediaBrowser.Controller.MediaEncoding
{
if (!videoWidth.HasValue && !requestedWidth.HasValue)
{
- return new ValueTuple<int?, int?>(null, null);
+ return (null, null);
}
if (!videoHeight.HasValue && !requestedHeight.HasValue)
{
- return new ValueTuple<int?, int?>(null, null);
+ return (null, null);
}
decimal inputWidth = Convert.ToDecimal(videoWidth ?? requestedWidth);
@@ -1583,7 +1634,7 @@ namespace MediaBrowser.Controller.MediaEncoding
outputWidth = 2 * Math.Truncate(outputWidth / 2);
outputHeight = 2 * Math.Truncate(outputHeight / 2);
- return new ValueTuple<int?, int?>(Convert.ToInt32(outputWidth), Convert.ToInt32(outputHeight));
+ return (Convert.ToInt32(outputWidth), Convert.ToInt32(outputHeight));
}
public List<string> GetScalingFilters(int? videoWidth,
@@ -1597,9 +1648,17 @@ namespace MediaBrowser.Controller.MediaEncoding
int? requestedMaxHeight)
{
var filters = new List<string>();
- var fixedOutputSize = GetFixedOutputSize(videoWidth, videoHeight, requestedWidth, requestedHeight, requestedMaxWidth, requestedMaxHeight);
-
- if (string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) && fixedOutputSize.Item1.HasValue && fixedOutputSize.Item2.HasValue)
+ var (width, height) = GetFixedOutputSize(
+ videoWidth,
+ videoHeight,
+ requestedWidth,
+ requestedHeight,
+ requestedMaxWidth,
+ requestedMaxHeight);
+
+ if (string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase)
+ && width.HasValue
+ && height.HasValue)
{
// Work around vaapi's reduced scaling features
var scaler = "scale_vaapi";
@@ -1607,15 +1666,26 @@ namespace MediaBrowser.Controller.MediaEncoding
// Given the input dimensions (inputWidth, inputHeight), determine the output dimensions
// (outputWidth, outputHeight). The user may request precise output dimensions or maximum
// output dimensions. Output dimensions are guaranteed to be even.
- var outputWidth = fixedOutputSize.Item1.Value;
- var outputHeight = fixedOutputSize.Item2.Value;
+ var outputWidth = width.Value;
+ var outputHeight = height.Value;
- if (!videoWidth.HasValue || outputWidth != videoWidth.Value || !videoHeight.HasValue || outputHeight != videoHeight.Value)
+ if (!videoWidth.HasValue
+ || outputWidth != videoWidth.Value
+ || !videoHeight.HasValue
+ || outputHeight != videoHeight.Value)
{
- filters.Add(string.Format("{0}=w={1}:h={2}", scaler, outputWidth.ToString(_usCulture), outputHeight.ToString(_usCulture)));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "{0}=w={1}:h={2}",
+ scaler,
+ outputWidth,
+ outputHeight));
}
}
- else if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1 && fixedOutputSize.Item1.HasValue && fixedOutputSize.Item2.HasValue)
+ else if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1
+ && width.HasValue
+ && height.HasValue)
{
// Nothing to do, it's handled as an input resize filter
}
@@ -1631,7 +1701,12 @@ namespace MediaBrowser.Controller.MediaEncoding
var widthParam = requestedWidth.Value.ToString(_usCulture);
var heightParam = requestedHeight.Value.ToString(_usCulture);
- filters.Add(string.Format("scale=trunc({0}/64)*64:trunc({1}/2)*2", widthParam, heightParam));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "scale=trunc({0}/64)*64:trunc({1}/2)*2",
+ widthParam,
+ heightParam));
}
else
{
@@ -1647,11 +1722,21 @@ namespace MediaBrowser.Controller.MediaEncoding
if (isExynosV4L2)
{
- filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,min({0}\\,{1}*dar))/64)*64:trunc(min(max(iw/dar\\,ih)\\,min({0}/dar\\,{1}))/2)*2", maxWidthParam, maxHeightParam));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "scale=trunc(min(max(iw\\,ih*dar)\\,min({0}\\,{1}*dar))/64)*64:trunc(min(max(iw/dar\\,ih)\\,min({0}/dar\\,{1}))/2)*2",
+ maxWidthParam,
+ maxHeightParam));
}
else
{
- filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,min({0}\\,{1}*dar))/2)*2:trunc(min(max(iw/dar\\,ih)\\,min({0}/dar\\,{1}))/2)*2", maxWidthParam, maxHeightParam));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "scale=trunc(min(max(iw\\,ih*dar)\\,min({0}\\,{1}*dar))/2)*2:trunc(min(max(iw/dar\\,ih)\\,min({0}/dar\\,{1}))/2)*2",
+ maxWidthParam,
+ maxHeightParam));
}
}
@@ -1667,7 +1752,11 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var widthParam = requestedWidth.Value.ToString(_usCulture);
- filters.Add(string.Format("scale={0}:trunc(ow/a/2)*2", widthParam));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "scale={0}:trunc(ow/a/2)*2",
+ widthParam));
}
}
@@ -1678,11 +1767,19 @@ namespace MediaBrowser.Controller.MediaEncoding
if (isExynosV4L2)
{
- filters.Add(string.Format("scale=trunc(oh*a/64)*64:{0}", heightParam));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "scale=trunc(oh*a/64)*64:{0}",
+ heightParam));
}
else
{
- filters.Add(string.Format("scale=trunc(oh*a/2)*2:{0}", heightParam));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "scale=trunc(oh*a/2)*2:{0}",
+ heightParam));
}
}
@@ -1693,11 +1790,19 @@ namespace MediaBrowser.Controller.MediaEncoding
if (isExynosV4L2)
{
- filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,{0})/64)*64:trunc(ow/dar/2)*2", maxWidthParam));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "scale=trunc(min(max(iw\\,ih*dar)\\,{0})/64)*64:trunc(ow/dar/2)*2",
+ maxWidthParam));
}
else
{
- filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,{0})/2)*2:trunc(ow/dar/2)*2", maxWidthParam));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "scale=trunc(min(max(iw\\,ih*dar)\\,{0})/2)*2:trunc(ow/dar/2)*2",
+ maxWidthParam));
}
}
@@ -1708,11 +1813,19 @@ namespace MediaBrowser.Controller.MediaEncoding
if (isExynosV4L2)
{
- filters.Add(string.Format("scale=trunc(oh*a/64)*64:min(max(iw/dar\\,ih)\\,{0})", maxHeightParam));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "scale=trunc(oh*a/64)*64:min(max(iw/dar\\,ih)\\,{0})",
+ maxHeightParam));
}
else
{
- filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(max(iw/dar\\,ih)\\,{0})", maxHeightParam));
+ filters.Add(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "scale=trunc(oh*a/2)*2:min(max(iw/dar\\,ih)\\,{0})",
+ maxHeightParam));
}
}
}
@@ -1722,8 +1835,8 @@ namespace MediaBrowser.Controller.MediaEncoding
private string GetFixedSizeScalingFilter(Video3DFormat? threedFormat, int requestedWidth, int requestedHeight)
{
- var widthParam = requestedWidth.ToString(_usCulture);
- var heightParam = requestedHeight.ToString(_usCulture);
+ var widthParam = requestedWidth.ToString(CultureInfo.InvariantCulture);
+ var heightParam = requestedHeight.ToString(CultureInfo.InvariantCulture);
string filter = null;
@@ -1765,13 +1878,14 @@ namespace MediaBrowser.Controller.MediaEncoding
}
}
- return string.Format(filter, widthParam, heightParam);
+ return string.Format(CultureInfo.InvariantCulture, filter, widthParam, heightParam);
}
/// <summary>
/// If we're going to put a fixed size on the command line, this will calculate it
/// </summary>
- public string GetOutputSizeParam(EncodingJobInfo state,
+ public string GetOutputSizeParam(
+ EncodingJobInfo state,
EncodingOptions options,
string outputVideoCodec,
bool allowTimeStampCopy = true)
@@ -1780,25 +1894,45 @@ namespace MediaBrowser.Controller.MediaEncoding
var request = state.BaseRequest;
+ var videoStream = state.VideoStream;
var filters = new List<string>();
+ // If we're hardware VAAPI decoding and software encoding, download frames from the decoder first
+ var hwType = options.HardwareAccelerationType ?? string.Empty;
+ if (string.Equals(hwType, "vaapi", StringComparison.OrdinalIgnoreCase) && !options.EnableHardwareEncoding )
+ {
+ filters.Add("hwdownload");
+
+ // If transcoding from 10 bit, transform colour spaces too
+ if (!string.IsNullOrEmpty(videoStream.PixelFormat)
+ && videoStream.PixelFormat.IndexOf("p10", StringComparison.OrdinalIgnoreCase) != -1
+ && string.Equals(outputVideoCodec,"libx264", StringComparison.OrdinalIgnoreCase))
+ {
+ filters.Add("format=p010le");
+ filters.Add("format=nv12");
+ }
+ else
+ {
+ filters.Add("format=nv12");
+ }
+ }
+
if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
{
filters.Add("format=nv12|vaapi");
filters.Add("hwupload");
}
- if (state.DeInterlace("h264", true) && string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
+ if (state.DeInterlace("h264", true)
+ && string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
{
- filters.Add(string.Format("deinterlace_vaapi"));
+ filters.Add(string.Format(CultureInfo.InvariantCulture, "deinterlace_vaapi"));
}
- var videoStream = state.VideoStream;
-
- if ((state.DeInterlace("h264", true) || state.DeInterlace("h265", true) || state.DeInterlace("hevc", true)) &&
- !string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
+ if ((state.DeInterlace("h264", true) || state.DeInterlace("h265", true) || state.DeInterlace("hevc", true))
+ && !string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
{
- var inputFramerate = videoStream == null ? null : videoStream.RealFrameRate;
+ var inputFramerate = videoStream?.RealFrameRate;
// If it is already 60fps then it will create an output framerate that is much too high for roku and others to handle
if (string.Equals(options.DeinterlaceMethod, "bobandweave", StringComparison.OrdinalIgnoreCase) && (inputFramerate ?? 60) <= 30)
@@ -1811,11 +1945,11 @@ namespace MediaBrowser.Controller.MediaEncoding
}
}
- var inputWidth = videoStream == null ? null : videoStream.Width;
- var inputHeight = videoStream == null ? null : videoStream.Height;
+ var inputWidth = videoStream?.Width;
+ var inputHeight = videoStream?.Height;
var threeDFormat = state.MediaSource.Video3DFormat;
- var videoDecoder = this.GetHardwareAcceleratedVideoDecoder(state, options);
+ var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options);
filters.AddRange(GetScalingFilters(inputWidth, inputHeight, threeDFormat, videoDecoder, outputVideoCodec, request.Width, request.Height, request.MaxWidth, request.MaxHeight));
@@ -1833,6 +1967,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
filters.Add("hwmap");
}
+
if (allowTimeStampCopy)
{
output += " -copyts";
@@ -1841,7 +1976,10 @@ namespace MediaBrowser.Controller.MediaEncoding
if (filters.Count > 0)
{
- output += string.Format(" -vf \"{0}\"", string.Join(",", filters.ToArray()));
+ output += string.Format(
+ CultureInfo.InvariantCulture,
+ " -vf \"{0}\"",
+ string.Join(",", filters));
}
return output;
@@ -1889,7 +2027,8 @@ namespace MediaBrowser.Controller.MediaEncoding
}
}
- if (state.AudioStream != null && CanStreamCopyAudio(state, state.AudioStream, state.SupportedAudioCodecs))
+ if (state.AudioStream != null
+ && CanStreamCopyAudio(state, state.AudioStream, state.SupportedAudioCodecs))
{
state.OutputAudioCodec = "copy";
}
@@ -1906,14 +2045,10 @@ namespace MediaBrowser.Controller.MediaEncoding
}
public static string GetProbeSizeArgument(int numInputFiles)
- {
- return numInputFiles > 1 ? "-probesize 1G" : "";
- }
+ => numInputFiles > 1 ? "-probesize 1G" : "";
public static string GetAnalyzeDurationArgument(int numInputFiles)
- {
- return numInputFiles > 1 ? "-analyzeduration 200M" : "";
- }
+ => numInputFiles > 1 ? "-analyzeduration 200M" : "";
public string GetInputModifier(EncodingJobInfo state, EncodingOptions encodingOptions)
{
@@ -1981,18 +2116,22 @@ namespace MediaBrowser.Controller.MediaEncoding
{
flags.Add("+igndts");
}
+
if (state.IgnoreInputIndex)
{
flags.Add("+ignidx");
}
+
if (state.GenPtsInput || string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
{
flags.Add("+genpts");
}
+
if (state.DiscardCorruptFramesInput)
{
flags.Add("+discardcorrupt");
}
+
if (state.EnableFastSeekInput)
{
flags.Add("+fastseek");
@@ -2000,24 +2139,33 @@ namespace MediaBrowser.Controller.MediaEncoding
if (flags.Count > 0)
{
- inputModifier += " -fflags " + string.Join("", flags.ToArray());
+ inputModifier += " -fflags " + string.Join(string.Empty, flags);
}
- var videoDecoder = this.GetHardwareAcceleratedVideoDecoder(state, encodingOptions);
+ var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions);
if (!string.IsNullOrEmpty(videoDecoder))
{
inputModifier += " " + videoDecoder;
- var videoStream = state.VideoStream;
- var inputWidth = videoStream == null ? null : videoStream.Width;
- var inputHeight = videoStream == null ? null : videoStream.Height;
- var request = state.BaseRequest;
+ if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1)
+ {
+ var videoStream = state.VideoStream;
+ var inputWidth = videoStream?.Width;
+ var inputHeight = videoStream?.Height;
+ var request = state.BaseRequest;
- var fixedOutputSize = GetFixedOutputSize(inputWidth, inputHeight, request.Width, request.Height, request.MaxWidth, request.MaxHeight);
+ var (width, height) = GetFixedOutputSize(inputWidth, inputHeight, request.Width, request.Height, request.MaxWidth, request.MaxHeight);
- if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1 && fixedOutputSize.Item1.HasValue && fixedOutputSize.Item2.HasValue)
- {
- inputModifier += string.Format(" -resize {0}x{1}", fixedOutputSize.Item1.Value.ToString(_usCulture), fixedOutputSize.Item2.Value.ToString(_usCulture));
+ if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1
+ && width.HasValue
+ && height.HasValue)
+ {
+ inputModifier += string.Format(
+ CultureInfo.InvariantCulture,
+ " -resize {0}x{1}",
+ width.Value,
+ height.Value);
+ }
}
}
@@ -2026,9 +2174,9 @@ namespace MediaBrowser.Controller.MediaEncoding
var outputVideoCodec = GetVideoEncoder(state, encodingOptions);
// Important: If this is ever re-enabled, make sure not to use it with wtv because it breaks seeking
- if (!string.Equals(state.InputContainer, "wtv", StringComparison.OrdinalIgnoreCase) &&
- state.TranscodingType != TranscodingJobType.Progressive &&
- state.EnableBreakOnNonKeyFrames(outputVideoCodec))
+ if (!string.Equals(state.InputContainer, "wtv", StringComparison.OrdinalIgnoreCase)
+ && state.TranscodingType != TranscodingJobType.Progressive
+ && state.EnableBreakOnNonKeyFrames(outputVideoCodec))
{
inputModifier += " -noaccurate_seek";
}
@@ -2052,14 +2200,16 @@ namespace MediaBrowser.Controller.MediaEncoding
}
- public void AttachMediaSourceInfo(EncodingJobInfo state,
- MediaSourceInfo mediaSource,
- string requestedUrl)
+ public void AttachMediaSourceInfo(
+ EncodingJobInfo state,
+ MediaSourceInfo mediaSource,
+ string requestedUrl)
{
if (state == null)
{
throw new ArgumentNullException(nameof(state));
}
+
if (mediaSource == null)
{
throw new ArgumentNullException(nameof(mediaSource));
@@ -2117,15 +2267,16 @@ namespace MediaBrowser.Controller.MediaEncoding
state.RemoteHttpHeaders = mediaSource.RequiredHttpHeaders;
state.ReadInputAtNativeFramerate = mediaSource.ReadAtNativeFramerate;
- if (state.ReadInputAtNativeFramerate ||
- mediaSource.Protocol == MediaProtocol.File && string.Equals(mediaSource.Container, "wtv", StringComparison.OrdinalIgnoreCase))
+ if (state.ReadInputAtNativeFramerate
+ || mediaSource.Protocol == MediaProtocol.File
+ && string.Equals(mediaSource.Container, "wtv", StringComparison.OrdinalIgnoreCase))
{
state.InputVideoSync = "-1";
state.InputAudioSync = "1";
}
- if (string.Equals(mediaSource.Container, "wma", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(mediaSource.Container, "asf", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(mediaSource.Container, "wma", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(mediaSource.Container, "asf", StringComparison.OrdinalIgnoreCase))
{
// Seeing some stuttering when transcoding wma to audio-only HLS
state.InputAudioSync = "1";
@@ -2237,7 +2388,7 @@ namespace MediaBrowser.Controller.MediaEncoding
return null;
}
- return this.GetHardwareAcceleratedVideoDecoder(state.MediaSource.VideoType ?? VideoType.VideoFile, state.VideoStream, encodingOptions);
+ return GetHardwareAcceleratedVideoDecoder(state.MediaSource.VideoType ?? VideoType.VideoFile, state.VideoStream, encodingOptions);
}
public string GetHardwareAcceleratedVideoDecoder(VideoType videoType, MediaStream videoStream, EncodingOptions encodingOptions)
@@ -2250,9 +2401,9 @@ namespace MediaBrowser.Controller.MediaEncoding
return null;
}
- if (videoStream != null &&
- !string.IsNullOrEmpty(videoStream.Codec) &&
- !string.IsNullOrEmpty(encodingOptions.HardwareAccelerationType))
+ if (videoStream != null
+ && !string.IsNullOrEmpty(videoStream.Codec)
+ && !string.IsNullOrEmpty(encodingOptions.HardwareAccelerationType))
{
if (string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
{
@@ -2450,11 +2601,7 @@ namespace MediaBrowser.Controller.MediaEncoding
codec = format;
}
- var args = " -codec:s:0 " + codec;
-
- args += " -disposition:s:0 default";
-
- return args;
+ return " -codec:s:0 " + codec + " -disposition:s:0 default";
}
public string GetProgressiveVideoFullCommandLine(EncodingJobInfo state, EncodingOptions encodingOptions, string outputPath, string defaultPreset)
@@ -2465,8 +2612,8 @@ namespace MediaBrowser.Controller.MediaEncoding
var format = string.Empty;
var keyFrame = string.Empty;
- if (string.Equals(Path.GetExtension(outputPath), ".mp4", StringComparison.OrdinalIgnoreCase) &&
- state.BaseRequest.Context == EncodingContext.Streaming)
+ if (string.Equals(Path.GetExtension(outputPath), ".mp4", StringComparison.OrdinalIgnoreCase)
+ && state.BaseRequest.Context == EncodingContext.Streaming)
{
// Comparison: https://github.com/jansmolders86/mediacenterjs/blob/master/lib/transcoding/desktop.js
format = " -f mp4 -movflags frag_keyframe+empty_moov";
@@ -2476,7 +2623,9 @@ namespace MediaBrowser.Controller.MediaEncoding
var inputModifier = GetInputModifier(state, encodingOptions);
- return string.Format("{0} {1}{2} {3} {4} -map_metadata -1 -map_chapters -1 -threads {5} {6}{7}{8} -y \"{9}\"",
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} {1}{2} {3} {4} -map_metadata -1 -map_chapters -1 -threads {5} {6}{7}{8} -y \"{9}\"",
inputModifier,
GetInputArgument(state, encodingOptions),
keyFrame,
@@ -2486,8 +2635,7 @@ namespace MediaBrowser.Controller.MediaEncoding
GetProgressiveVideoAudioArguments(state, encodingOptions),
GetSubtitleEmbedArguments(state),
format,
- outputPath
- ).Trim();
+ outputPath).Trim();
}
public string GetOutputFFlags(EncodingJobInfo state)
@@ -2500,7 +2648,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (flags.Count > 0)
{
- return " -fflags " + string.Join("", flags.ToArray());
+ return " -fflags " + string.Join("", flags);
}
return string.Empty;
@@ -2517,9 +2665,9 @@ namespace MediaBrowser.Controller.MediaEncoding
if (string.Equals(videoCodec, "copy", StringComparison.OrdinalIgnoreCase))
{
- if (state.VideoStream != null &&
- string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) &&
- !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
+ if (state.VideoStream != null
+ && string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase)
+ && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
{
string bitStreamArgs = GetBitStreamArgs(state.VideoStream);
if (!string.IsNullOrEmpty(bitStreamArgs))
@@ -2540,8 +2688,10 @@ namespace MediaBrowser.Controller.MediaEncoding
}
else
{
- var keyFrameArg = string.Format(" -force_key_frames \"expr:gte(t,n_forced*{0})\"",
- 5.ToString(_usCulture));
+ var keyFrameArg = string.Format(
+ CultureInfo.InvariantCulture,
+ " -force_key_frames \"expr:gte(t,n_forced*{0})\"",
+ 5);
args += keyFrameArg;
@@ -2562,6 +2712,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
args += " -copyts";
}
+
args += " -avoid_negative_ts disabled -start_at_zero";
}
@@ -2662,39 +2813,22 @@ namespace MediaBrowser.Controller.MediaEncoding
}
}
- var albumCoverInput = string.Empty;
- var mapArgs = string.Empty;
- var metadata = string.Empty;
- var vn = string.Empty;
-
- var hasArt = !string.IsNullOrEmpty(state.AlbumCoverPath);
- hasArt = false;
-
- if (hasArt)
- {
- albumCoverInput = " -i \"" + state.AlbumCoverPath + "\"";
- mapArgs = " -map 0:a -map 1:v -c:1:v copy";
- metadata = " -metadata:s:v title=\"Album cover\" -metadata:s:v comment=\"Cover(Front)\"";
- }
- else
- {
- vn = " -vn";
- }
-
var threads = GetNumberOfThreads(state, encodingOptions, null);
var inputModifier = GetInputModifier(state, encodingOptions);
- return string.Format("{0} {1}{7}{8} -threads {2}{3} {4} -id3v2_version 3 -write_id3v1 1{6} -y \"{5}\"",
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} {1}{7}{8} -threads {2}{3} {4} -id3v2_version 3 -write_id3v1 1{6} -y \"{5}\"",
inputModifier,
GetInputArgument(state, encodingOptions),
threads,
- vn,
- string.Join(" ", audioTranscodeParams.ToArray()),
+ " -vn",
+ string.Join(" ", audioTranscodeParams),
outputPath,
- metadata,
- albumCoverInput,
- mapArgs).Trim();
+ string.Empty,
+ string.Empty,
+ string.Empty).Trim();
}
}
diff --git a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
index 7f842c1d0..5cedc3d57 100644
--- a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
+++ b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
@@ -1,8 +1,8 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using MediaBrowser.Model.IO;
-using MediaBrowser.Model.MediaInfo;
namespace MediaBrowser.Controller.MediaEncoding
{
@@ -16,31 +16,26 @@ namespace MediaBrowser.Controller.MediaEncoding
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <param name="videoPath">The video path.</param>
- /// <param name="protocol">The protocol.</param>
/// <param name="isoMount">The iso mount.</param>
/// <param name="playableStreamFileNames">The playable stream file names.</param>
- /// <returns>System.String[][].</returns>
- public static string[] GetInputArgument(IFileSystem fileSystem, string videoPath, MediaProtocol protocol, IIsoMount isoMount, string[] playableStreamFileNames)
+ /// <returns>string[].</returns>
+ public static string[] GetInputArgument(IFileSystem fileSystem, string videoPath, IIsoMount isoMount, IReadOnlyCollection<string> playableStreamFileNames)
{
- if (playableStreamFileNames.Length > 0)
+ if (playableStreamFileNames.Count > 0)
{
if (isoMount == null)
{
return GetPlayableStreamFiles(fileSystem, videoPath, playableStreamFileNames);
}
+
return GetPlayableStreamFiles(fileSystem, isoMount.MountedPath, playableStreamFileNames);
}
return new[] { videoPath };
}
- private static string[] GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, string[] filenames)
+ private static string[] GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, IEnumerable<string> filenames)
{
- if (filenames.Length == 0)
- {
- return new string[] { };
- }
-
var allFiles = fileSystem
.GetFilePaths(rootPath, true)
.ToArray();
diff --git a/MediaBrowser.Controller/Providers/AlbumInfo.cs b/MediaBrowser.Controller/Providers/AlbumInfo.cs
index b0b443fc0..ac6b86c1d 100644
--- a/MediaBrowser.Controller/Providers/AlbumInfo.cs
+++ b/MediaBrowser.Controller/Providers/AlbumInfo.cs
@@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Providers
/// Gets or sets the album artist.
/// </summary>
/// <value>The album artist.</value>
- public string[] AlbumArtists { get; set; }
+ public IReadOnlyList<string> AlbumArtists { get; set; }
/// <summary>
/// Gets or sets the artist provider ids.
diff --git a/MediaBrowser.Controller/Providers/MusicVideoInfo.cs b/MediaBrowser.Controller/Providers/MusicVideoInfo.cs
index 194b26484..9835351fc 100644
--- a/MediaBrowser.Controller/Providers/MusicVideoInfo.cs
+++ b/MediaBrowser.Controller/Providers/MusicVideoInfo.cs
@@ -1,7 +1,9 @@
+using System.Collections.Generic;
+
namespace MediaBrowser.Controller.Providers
{
public class MusicVideoInfo : ItemLookupInfo
{
- public string[] Artists { get; set; }
+ public IReadOnlyList<string> Artists { get; set; }
}
}
diff --git a/MediaBrowser.Controller/Providers/SongInfo.cs b/MediaBrowser.Controller/Providers/SongInfo.cs
index 61e950130..50615b0bd 100644
--- a/MediaBrowser.Controller/Providers/SongInfo.cs
+++ b/MediaBrowser.Controller/Providers/SongInfo.cs
@@ -1,12 +1,15 @@
using System;
+using System.Collections.Generic;
namespace MediaBrowser.Controller.Providers
{
public class SongInfo : ItemLookupInfo
{
- public string[] AlbumArtists { get; set; }
+ public IReadOnlyList<string> AlbumArtists { get; set; }
+
public string Album { get; set; }
- public string[] Artists { get; set; }
+
+ public IReadOnlyList<string> Artists { get; set; }
public SongInfo()
{
diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
index 30a33b729..19009e577 100644
--- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
+++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
@@ -228,7 +228,7 @@ namespace MediaBrowser.LocalMetadata.Savers
}
}
- if (item.RemoteTrailers.Length > 0)
+ if (item.RemoteTrailers.Count > 0)
{
writer.WriteStartElement("Trailers");
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index a8874b6d0..75bb960c3 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -303,7 +303,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
var extractChapters = request.MediaType == DlnaProfileType.Video && request.ExtractChapters;
- var inputFiles = MediaEncoderHelpers.GetInputArgument(FileSystem, request.MediaSource.Path, request.MediaSource.Protocol, request.MountedIso, request.PlayableStreamFileNames);
+ var inputFiles = MediaEncoderHelpers.GetInputArgument(FileSystem, request.MediaSource.Path, request.MountedIso, request.PlayableStreamFileNames);
var probeSize = EncodingHelper.GetProbeSizeArgument(inputFiles.Length);
string analyzeDuration;
diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs
index b382d9d4a..4da5508b4 100644
--- a/MediaBrowser.Model/Dto/BaseItemDto.cs
+++ b/MediaBrowser.Model/Dto/BaseItemDto.cs
@@ -234,7 +234,7 @@ namespace MediaBrowser.Model.Dto
/// Gets or sets the trailer urls.
/// </summary>
/// <value>The trailer urls.</value>
- public MediaUrl[] RemoteTrailers { get; set; }
+ public IReadOnlyCollection<MediaUrl> RemoteTrailers { get; set; }
/// <summary>
/// Gets or sets the provider ids.
@@ -386,7 +386,7 @@ namespace MediaBrowser.Model.Dto
/// Gets or sets the artists.
/// </summary>
/// <value>The artists.</value>
- public string[] Artists { get; set; }
+ public IReadOnlyList<string> Artists { get; set; }
/// <summary>
/// Gets or sets the artist items.
diff --git a/MediaBrowser.Model/Dto/RecommendationDto.cs b/MediaBrowser.Model/Dto/RecommendationDto.cs
index 0a890573b..acfb85e9b 100644
--- a/MediaBrowser.Model/Dto/RecommendationDto.cs
+++ b/MediaBrowser.Model/Dto/RecommendationDto.cs
@@ -1,10 +1,11 @@
using System;
+using System.Collections.Generic;
namespace MediaBrowser.Model.Dto
{
public class RecommendationDto
{
- public BaseItemDto[] Items { get; set; }
+ public IReadOnlyCollection<BaseItemDto> Items { get; set; }
public RecommendationType RecommendationType { get; set; }
diff --git a/MediaBrowser.Model/Net/MimeTypes.cs b/MediaBrowser.Model/Net/MimeTypes.cs
index d7bf956bb..de5e58d22 100644
--- a/MediaBrowser.Model/Net/MimeTypes.cs
+++ b/MediaBrowser.Model/Net/MimeTypes.cs
@@ -120,6 +120,7 @@ namespace MediaBrowser.Model.Net
{ ".m4b", "audio/m4b" },
{ ".xsp", "audio/xsp" },
{ ".dsp", "audio/dsp" },
+ { ".flac", "audio/flac" },
};
private static readonly Dictionary<string, string> _extensionLookup = CreateExtensionLookup();
diff --git a/MediaBrowser.Model/Querying/QueryResult.cs b/MediaBrowser.Model/Querying/QueryResult.cs
index e81f2b868..c007a45d6 100644
--- a/MediaBrowser.Model/Querying/QueryResult.cs
+++ b/MediaBrowser.Model/Querying/QueryResult.cs
@@ -1,3 +1,6 @@
+using System;
+using System.Collections.Generic;
+
namespace MediaBrowser.Model.Querying
{
public class QueryResult<T>
@@ -6,7 +9,7 @@ namespace MediaBrowser.Model.Querying
/// Gets or sets the items.
/// </summary>
/// <value>The items.</value>
- public T[] Items { get; set; }
+ public IReadOnlyList<T> Items { get; set; }
/// <summary>
/// The total number of records available
@@ -16,7 +19,7 @@ namespace MediaBrowser.Model.Querying
public QueryResult()
{
- Items = new T[] { };
+ Items = Array.Empty<T>();
}
}
}
diff --git a/MediaBrowser.Model/Search/SearchHint.cs b/MediaBrowser.Model/Search/SearchHint.cs
index 8a187f18e..8f4824903 100644
--- a/MediaBrowser.Model/Search/SearchHint.cs
+++ b/MediaBrowser.Model/Search/SearchHint.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
namespace MediaBrowser.Model.Search
{
@@ -111,6 +112,7 @@ namespace MediaBrowser.Model.Search
/// </summary>
/// <value>The album.</value>
public string Album { get; set; }
+
public Guid AlbumId { get; set; }
/// <summary>
@@ -123,7 +125,7 @@ namespace MediaBrowser.Model.Search
/// Gets or sets the artists.
/// </summary>
/// <value>The artists.</value>
- public string[] Artists { get; set; }
+ public IReadOnlyList<string> Artists { get; set; }
/// <summary>
/// Gets or sets the song count.
diff --git a/MediaBrowser.Providers/Books/AudioBookMetadataService.cs b/MediaBrowser.Providers/Books/AudioBookMetadataService.cs
index 4820e12ab..0062d5ab3 100644
--- a/MediaBrowser.Providers/Books/AudioBookMetadataService.cs
+++ b/MediaBrowser.Providers/Books/AudioBookMetadataService.cs
@@ -11,14 +11,31 @@ namespace MediaBrowser.Providers.Books
{
public class AudioBookMetadataService : MetadataService<AudioBook, SongInfo>
{
- protected override void MergeData(MetadataResult<AudioBook> source, MetadataResult<AudioBook> target, MetadataFields[] lockedFields, bool replaceData, bool mergeMetadataSettings)
+ public AudioBookMetadataService(
+ IServerConfigurationManager serverConfigurationManager,
+ ILogger logger,
+ IProviderManager providerManager,
+ IFileSystem fileSystem,
+ IUserDataManager userDataManager,
+ ILibraryManager libraryManager)
+ : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override void MergeData(
+ MetadataResult<AudioBook> source,
+ MetadataResult<AudioBook> target,
+ MetadataFields[] lockedFields,
+ bool replaceData,
+ bool mergeMetadataSettings)
{
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
var sourceItem = source.Item;
var targetItem = target.Item;
- if (replaceData || targetItem.Artists.Length == 0)
+ if (replaceData || targetItem.Artists.Count == 0)
{
targetItem.Artists = sourceItem.Artists;
}
@@ -28,9 +45,5 @@ namespace MediaBrowser.Providers.Books
targetItem.Album = sourceItem.Album;
}
}
-
- public AudioBookMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
- {
- }
}
}
diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs
index a22eaaa51..6a8d03f6d 100644
--- a/MediaBrowser.Providers/Manager/ProviderManager.cs
+++ b/MediaBrowser.Providers/Manager/ProviderManager.cs
@@ -278,7 +278,7 @@ namespace MediaBrowser.Providers.Manager
var currentOptions = options;
var typeOptions = libraryOptions.GetTypeOptions(item.GetType().Name);
- var typeFetcherOrder = typeOptions == null ? null : typeOptions.ImageFetcherOrder;
+ var typeFetcherOrder = typeOptions?.ImageFetcherOrder;
return ImageProviders.Where(i => CanRefresh(i, item, libraryOptions, options, refreshOptions, includeDisabled))
.OrderBy(i =>
@@ -287,7 +287,6 @@ namespace MediaBrowser.Providers.Manager
if (!(i is ILocalImageProvider))
{
var fetcherOrder = typeFetcherOrder ?? currentOptions.ImageFetcherOrder;
-
var index = Array.IndexOf(fetcherOrder, i.Name);
if (index != -1)
diff --git a/MediaBrowser.Providers/Manager/ProviderUtils.cs b/MediaBrowser.Providers/Manager/ProviderUtils.cs
index 2031449d9..8d1588c4e 100644
--- a/MediaBrowser.Providers/Manager/ProviderUtils.cs
+++ b/MediaBrowser.Providers/Manager/ProviderUtils.cs
@@ -11,7 +11,8 @@ namespace MediaBrowser.Providers.Manager
{
public static class ProviderUtils
{
- public static void MergeBaseItemData<T>(MetadataResult<T> sourceResult,
+ public static void MergeBaseItemData<T>(
+ MetadataResult<T> sourceResult,
MetadataResult<T> targetResult,
MetadataFields[] lockedFields,
bool replaceData,
@@ -174,11 +175,11 @@ namespace MediaBrowser.Providers.Manager
}
}
- MergeAlbumArtist(source, target, lockedFields, replaceData);
- MergeCriticRating(source, target, lockedFields, replaceData);
- MergeTrailers(source, target, lockedFields, replaceData);
- MergeVideoInfo(source, target, lockedFields, replaceData);
- MergeDisplayOrder(source, target, lockedFields, replaceData);
+ MergeAlbumArtist(source, target, replaceData);
+ MergeCriticRating(source, target, replaceData);
+ MergeTrailers(source, target, replaceData);
+ MergeVideoInfo(source, target, replaceData);
+ MergeDisplayOrder(source, target, replaceData);
if (replaceData || string.IsNullOrEmpty(target.ForcedSortName))
{
@@ -196,7 +197,7 @@ namespace MediaBrowser.Providers.Manager
target.IsLocked = source.IsLocked;
// Grab the value if it's there, but if not then don't overwrite the default
- if (source.DateCreated != default(DateTime))
+ if (source.DateCreated != default)
{
target.DateCreated = source.DateCreated;
}
@@ -231,12 +232,10 @@ namespace MediaBrowser.Providers.Manager
}
}
- private static void MergeDisplayOrder(BaseItem source, BaseItem target, MetadataFields[] lockedFields, bool replaceData)
+ private static void MergeDisplayOrder(BaseItem source, BaseItem target, bool replaceData)
{
- var sourceHasDisplayOrder = source as IHasDisplayOrder;
- var targetHasDisplayOrder = target as IHasDisplayOrder;
-
- if (sourceHasDisplayOrder != null && targetHasDisplayOrder != null)
+ if (source is IHasDisplayOrder sourceHasDisplayOrder
+ && target is IHasDisplayOrder targetHasDisplayOrder)
{
if (replaceData || string.IsNullOrEmpty(targetHasDisplayOrder.DisplayOrder))
{
@@ -250,21 +249,19 @@ namespace MediaBrowser.Providers.Manager
}
}
- private static void MergeAlbumArtist(BaseItem source, BaseItem target, MetadataFields[] lockedFields, bool replaceData)
+ private static void MergeAlbumArtist(BaseItem source, BaseItem target, bool replaceData)
{
- var sourceHasAlbumArtist = source as IHasAlbumArtist;
- var targetHasAlbumArtist = target as IHasAlbumArtist;
-
- if (sourceHasAlbumArtist != null && targetHasAlbumArtist != null)
+ if (source is IHasAlbumArtist sourceHasAlbumArtist
+ && target is IHasAlbumArtist targetHasAlbumArtist)
{
- if (replaceData || targetHasAlbumArtist.AlbumArtists.Length == 0)
+ if (replaceData || targetHasAlbumArtist.AlbumArtists.Count == 0)
{
targetHasAlbumArtist.AlbumArtists = sourceHasAlbumArtist.AlbumArtists;
}
}
}
- private static void MergeCriticRating(BaseItem source, BaseItem target, MetadataFields[] lockedFields, bool replaceData)
+ private static void MergeCriticRating(BaseItem source, BaseItem target, bool replaceData)
{
if (replaceData || !target.CriticRating.HasValue)
{
@@ -272,20 +269,17 @@ namespace MediaBrowser.Providers.Manager
}
}
- private static void MergeTrailers(BaseItem source, BaseItem target, MetadataFields[] lockedFields, bool replaceData)
+ private static void MergeTrailers(BaseItem source, BaseItem target, bool replaceData)
{
- if (replaceData || target.RemoteTrailers.Length == 0)
+ if (replaceData || target.RemoteTrailers.Count == 0)
{
target.RemoteTrailers = source.RemoteTrailers;
}
}
- private static void MergeVideoInfo(BaseItem source, BaseItem target, MetadataFields[] lockedFields, bool replaceData)
+ private static void MergeVideoInfo(BaseItem source, BaseItem target, bool replaceData)
{
- var sourceCast = source as Video;
- var targetCast = target as Video;
-
- if (sourceCast != null && targetCast != null)
+ if (source is Video sourceCast && target is Video targetCast)
{
if (replaceData || targetCast.Video3DFormat == null)
{
diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
index c8089d6f5..c7ecc59c9 100644
--- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj
+++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
@@ -28,5 +28,5 @@
<!-- We need at least C# 7.1 -->
<LangVersion>latest</LangVersion>
</PropertyGroup>
-
+
</Project>
diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
index d80084acf..e0b23108f 100644
--- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs
@@ -62,7 +62,7 @@ namespace MediaBrowser.Providers.MediaInfo
{
var protocol = item.PathProtocol ?? MediaProtocol.File;
- var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, item.Path, protocol, null, item.GetPlayableStreamFileNames(_mediaEncoder));
+ var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, item.Path, null, item.GetPlayableStreamFileNames(_mediaEncoder));
var mediaStreams =
item.GetMediaStreams();
diff --git a/MediaBrowser.Providers/Music/AlbumMetadataService.cs b/MediaBrowser.Providers/Music/AlbumMetadataService.cs
index 33a6c2fa3..4e59b4119 100644
--- a/MediaBrowser.Providers/Music/AlbumMetadataService.cs
+++ b/MediaBrowser.Providers/Music/AlbumMetadataService.cs
@@ -15,12 +15,34 @@ namespace MediaBrowser.Providers.Music
{
public class AlbumMetadataService : MetadataService<MusicAlbum, AlbumInfo>
{
+ public AlbumMetadataService(
+ IServerConfigurationManager serverConfigurationManager,
+ ILogger logger,
+ IProviderManager providerManager,
+ IFileSystem fileSystem,
+ IUserDataManager userDataManager,
+ ILibraryManager libraryManager)
+ : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override bool EnableUpdatingPremiereDateFromChildren => true;
+
+ /// <inheritdoc />
+ protected override bool EnableUpdatingGenresFromChildren => true;
+
+ /// <inheritdoc />
+ protected override bool EnableUpdatingStudiosFromChildren => true;
+
+ /// <inheritdoc />
protected override IList<BaseItem> GetChildrenForMetadataUpdates(MusicAlbum item)
{
return item.GetRecursiveChildren(i => i is Audio)
.ToList();
}
+ /// <inheritdoc />
protected override ItemUpdateType UpdateMetadataFromChildren(MusicAlbum item, IList<BaseItem> children, bool isFullRefresh, ItemUpdateType currentUpdateType)
{
var updateType = base.UpdateMetadataFromChildren(item, children, isFullRefresh, currentUpdateType);
@@ -50,12 +72,6 @@ namespace MediaBrowser.Providers.Music
return updateType;
}
- protected override bool EnableUpdatingPremiereDateFromChildren => true;
-
- protected override bool EnableUpdatingGenresFromChildren => true;
-
- protected override bool EnableUpdatingStudiosFromChildren => true;
-
private ItemUpdateType SetAlbumArtistFromSongs(MusicAlbum item, IEnumerable<Audio> songs)
{
var updateType = ItemUpdateType.None;
@@ -94,21 +110,23 @@ namespace MediaBrowser.Providers.Music
return updateType;
}
- protected override void MergeData(MetadataResult<MusicAlbum> source, MetadataResult<MusicAlbum> target, MetadataFields[] lockedFields, bool replaceData, bool mergeMetadataSettings)
+ /// <inheritdoc />
+ protected override void MergeData(
+ MetadataResult<MusicAlbum> source,
+ MetadataResult<MusicAlbum> target,
+ MetadataFields[] lockedFields,
+ bool replaceData,
+ bool mergeMetadataSettings)
{
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
var sourceItem = source.Item;
var targetItem = target.Item;
- if (replaceData || targetItem.Artists.Length == 0)
+ if (replaceData || targetItem.Artists.Count == 0)
{
targetItem.Artists = sourceItem.Artists;
}
}
-
- public AlbumMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
- {
- }
}
}
diff --git a/MediaBrowser.Providers/Music/AudioMetadataService.cs b/MediaBrowser.Providers/Music/AudioMetadataService.cs
index 1422a4eaa..3bf854b91 100644
--- a/MediaBrowser.Providers/Music/AudioMetadataService.cs
+++ b/MediaBrowser.Providers/Music/AudioMetadataService.cs
@@ -11,6 +11,18 @@ namespace MediaBrowser.Providers.Music
{
public class AudioMetadataService : MetadataService<Audio, SongInfo>
{
+ public AudioMetadataService(
+ IServerConfigurationManager serverConfigurationManager,
+ ILogger logger,
+ IProviderManager providerManager,
+ IFileSystem fileSystem,
+ IUserDataManager userDataManager,
+ ILibraryManager libraryManager)
+ : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
+ {
+ }
+
+ /// <inheritdoc />
protected override void MergeData(MetadataResult<Audio> source, MetadataResult<Audio> target, MetadataFields[] lockedFields, bool replaceData, bool mergeMetadataSettings)
{
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
@@ -18,7 +30,7 @@ namespace MediaBrowser.Providers.Music
var sourceItem = source.Item;
var targetItem = target.Item;
- if (replaceData || targetItem.Artists.Length == 0)
+ if (replaceData || targetItem.Artists.Count == 0)
{
targetItem.Artists = sourceItem.Artists;
}
@@ -28,9 +40,5 @@ namespace MediaBrowser.Providers.Music
targetItem.Album = sourceItem.Album;
}
}
-
- public AudioMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
- {
- }
}
}
diff --git a/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs b/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs
index 93412306f..c743ffcb0 100644
--- a/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs
+++ b/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs
@@ -11,7 +11,24 @@ namespace MediaBrowser.Providers.Music
{
public class MusicVideoMetadataService : MetadataService<MusicVideo, MusicVideoInfo>
{
- protected override void MergeData(MetadataResult<MusicVideo> source, MetadataResult<MusicVideo> target, MetadataFields[] lockedFields, bool replaceData, bool mergeMetadataSettings)
+ public MusicVideoMetadataService(
+ IServerConfigurationManager serverConfigurationManager,
+ ILogger logger,
+ IProviderManager providerManager,
+ IFileSystem fileSystem,
+ IUserDataManager userDataManager,
+ ILibraryManager libraryManager)
+ : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
+ {
+ }
+
+ /// <inheritdoc />
+ protected override void MergeData(
+ MetadataResult<MusicVideo> source,
+ MetadataResult<MusicVideo> target,
+ MetadataFields[] lockedFields,
+ bool replaceData,
+ bool mergeMetadataSettings)
{
ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
@@ -23,14 +40,10 @@ namespace MediaBrowser.Providers.Music
targetItem.Album = sourceItem.Album;
}
- if (replaceData || targetItem.Artists.Length == 0)
+ if (replaceData || targetItem.Artists.Count == 0)
{
targetItem.Artists = sourceItem.Artists;
}
}
-
- public MusicVideoMetadataService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IFileSystem fileSystem, IUserDataManager userDataManager, ILibraryManager libraryManager) : base(serverConfigurationManager, logger, providerManager, fileSystem, userDataManager, libraryManager)
- {
- }
}
}
diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs
index 1578e4341..10ed4f073 100644
--- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs
+++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
+using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
@@ -312,14 +313,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
}
sb.Replace(", the", string.Empty).Replace("the ", " ").Replace(" the ", " ");
- int prevLength;
- do
- {
- prevLength = sb.Length;
- sb.Replace(" ", " ");
- } while (name.Length != prevLength);
-
- return sb.ToString().Trim();
+ return Regex.Replace(sb.ToString().Trim(), @"\s+", " ");
}
private void MapSeriesToResult(MetadataResult<Series> result, TvDbSharper.Dto.Series tvdbSeries, string metadataLanguage)
diff --git a/MediaBrowser.XbmcMetadata/EntryPoint.cs b/MediaBrowser.XbmcMetadata/EntryPoint.cs
index 992991a7e..fe4d50efa 100644
--- a/MediaBrowser.XbmcMetadata/EntryPoint.cs
+++ b/MediaBrowser.XbmcMetadata/EntryPoint.cs
@@ -16,27 +16,30 @@ namespace MediaBrowser.XbmcMetadata
{
private readonly IUserDataManager _userDataManager;
private readonly ILogger _logger;
- private readonly ILibraryManager _libraryManager;
private readonly IProviderManager _providerManager;
private readonly IConfigurationManager _config;
- public EntryPoint(IUserDataManager userDataManager, ILibraryManager libraryManager, ILogger logger, IProviderManager providerManager, IConfigurationManager config)
+ public EntryPoint(
+ IUserDataManager userDataManager,
+ ILogger logger,
+ IProviderManager providerManager,
+ IConfigurationManager config)
{
_userDataManager = userDataManager;
- _libraryManager = libraryManager;
_logger = logger;
_providerManager = providerManager;
_config = config;
}
+ /// <inheritdoc />
public Task RunAsync()
{
- _userDataManager.UserDataSaved += _userDataManager_UserDataSaved;
+ _userDataManager.UserDataSaved += OnUserDataSaved;
return Task.CompletedTask;
}
- void _userDataManager_UserDataSaved(object sender, UserDataSaveEventArgs e)
+ private void OnUserDataSaved(object sender, UserDataSaveEventArgs e)
{
if (e.SaveReason == UserDataSaveReason.PlaybackFinished || e.SaveReason == UserDataSaveReason.TogglePlayed || e.SaveReason == UserDataSaveReason.UpdateUserRating)
{
@@ -47,9 +50,10 @@ namespace MediaBrowser.XbmcMetadata
}
}
+ /// <inheritdoc />
public void Dispose()
{
- _userDataManager.UserDataSaved -= _userDataManager_UserDataSaved;
+ _userDataManager.UserDataSaved -= OnUserDataSaved;
}
private void SaveMetadataForItem(BaseItem item, ItemUpdateType updateReason)
diff --git a/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs
index 430b93199..a1905bf26 100644
--- a/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs
+++ b/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs
@@ -15,16 +15,30 @@ namespace MediaBrowser.XbmcMetadata.Savers
{
public class AlbumNfoSaver : BaseNfoSaver
{
+ public AlbumNfoSaver(
+ IFileSystem fileSystem,
+ IServerConfigurationManager configurationManager,
+ ILibraryManager libraryManager,
+ IUserManager userManager,
+ IUserDataManager userDataManager,
+ ILogger logger)
+ : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
+ {
+ }
+
+ /// <inheritdoc />
protected override string GetLocalSavePath(BaseItem item)
{
return Path.Combine(item.Path, "album.nfo");
}
+ /// <inheritdoc />
protected override string GetRootElementName(BaseItem item)
{
return "album";
}
+ /// <inheritdoc />
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (!item.SupportsLocalMetadata)
@@ -35,6 +49,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
return item is MusicAlbum && updateType >= MinimumUpdateType;
}
+ /// <inheritdoc />
protected override void WriteCustomElements(BaseItem item, XmlWriter writer)
{
var album = (MusicAlbum)item;
@@ -52,8 +67,6 @@ namespace MediaBrowser.XbmcMetadata.Savers
AddTracks(album.Tracks, writer);
}
- private readonly CultureInfo UsCulture = new CultureInfo("en-US");
-
private void AddTracks(IEnumerable<BaseItem> tracks, XmlWriter writer)
{
foreach (var track in tracks.OrderBy(i => i.ParentIndexNumber ?? 0).ThenBy(i => i.IndexNumber ?? 0))
@@ -62,7 +75,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
if (track.IndexNumber.HasValue)
{
- writer.WriteElementString("position", track.IndexNumber.Value.ToString(UsCulture));
+ writer.WriteElementString("position", track.IndexNumber.Value.ToString(CultureInfo.InvariantCulture));
}
if (!string.IsNullOrEmpty(track.Name))
@@ -81,21 +94,19 @@ namespace MediaBrowser.XbmcMetadata.Savers
}
}
+ /// <inheritdoc />
protected override List<string> GetTagsUsed(BaseItem item)
{
var list = base.GetTagsUsed(item);
- list.AddRange(new string[]
- {
- "track",
- "artist",
- "albumartist"
- });
- return list;
- }
+ list.AddRange(
+ new string[]
+ {
+ "track",
+ "artist",
+ "albumartist"
+ });
- public AlbumNfoSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
- : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
- {
+ return list;
}
}
}
diff --git a/MediaBrowser.sln b/MediaBrowser.sln
index 3ed86d65c..39839e273 100644
--- a/MediaBrowser.sln
+++ b/MediaBrowser.sln
@@ -1,4 +1,4 @@
-
+
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.3
@@ -41,8 +41,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emby.Naming", "Emby.Naming\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Emby.XmlTv", "Emby.XmlTv\Emby.XmlTv\Emby.XmlTv.csproj", "{6EAFA7F0-8A82-49E6-B2FA-086C5CAEA95B}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IsoMounter", "Emby.IsoMounting\IsoMounter\IsoMounter.csproj", "{9BA471D2-6DB9-4DBF-B3A0-9FB3171F94A6}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediaBrowser.MediaEncoding", "MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj", "{960295EE-4AF4-4440-A525-B4C295B01A61}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Server", "Jellyfin.Server\Jellyfin.Server.csproj", "{07E39F42-A2C6-4B32-AF8C-725F957A73FF}"
@@ -141,10 +139,6 @@ Global
{6EAFA7F0-8A82-49E6-B2FA-086C5CAEA95B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EAFA7F0-8A82-49E6-B2FA-086C5CAEA95B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6EAFA7F0-8A82-49E6-B2FA-086C5CAEA95B}.Release|Any CPU.Build.0 = Release|Any CPU
- {9BA471D2-6DB9-4DBF-B3A0-9FB3171F94A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9BA471D2-6DB9-4DBF-B3A0-9FB3171F94A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9BA471D2-6DB9-4DBF-B3A0-9FB3171F94A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9BA471D2-6DB9-4DBF-B3A0-9FB3171F94A6}.Release|Any CPU.Build.0 = Release|Any CPU
{960295EE-4AF4-4440-A525-B4C295B01A61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{960295EE-4AF4-4440-A525-B4C295B01A61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{960295EE-4AF4-4440-A525-B4C295B01A61}.Release|Any CPU.ActiveCfg = Release|Any CPU