diff options
Diffstat (limited to 'MediaBrowser.Api')
30 files changed, 122 insertions, 172 deletions
diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 5aa803b9b..ed0a0c81a 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -6,7 +6,7 @@ using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Diagnostics; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.Threading; using System.Collections.Generic; using System.Threading; @@ -147,7 +147,7 @@ namespace MediaBrowser.Api } catch (Exception ex) { - Logger.ErrorException("Error deleting encoded media cache", ex); + Logger.LogError(ex, "Error deleting encoded media cache"); } } @@ -378,7 +378,7 @@ namespace MediaBrowser.Api public void OnTranscodeEndRequest(TranscodingJob job) { job.ActiveRequestCount--; - //Logger.Debug("OnTranscodeEndRequest job.ActiveRequestCount={0}", job.ActiveRequestCount); + //Logger.LogDebug("OnTranscodeEndRequest job.ActiveRequestCount={0}", job.ActiveRequestCount); if (job.ActiveRequestCount <= 0) { PingTimer(job, false); @@ -391,7 +391,7 @@ namespace MediaBrowser.Api throw new ArgumentNullException("playSessionId"); } - //Logger.Debug("PingTranscodingJob PlaySessionId={0} isUsedPaused: {1}", playSessionId, isUserPaused); + //Logger.LogDebug("PingTranscodingJob PlaySessionId={0} isUsedPaused: {1}", playSessionId, isUserPaused); List<TranscodingJob> jobs; @@ -406,7 +406,7 @@ namespace MediaBrowser.Api { if (isUserPaused.HasValue) { - //Logger.Debug("Setting job.IsUserPaused to {0}. jobId: {1}", isUserPaused, job.Id); + //Logger.LogDebug("Setting job.IsUserPaused to {0}. jobId: {1}", isUserPaused, job.Id); job.IsUserPaused = isUserPaused.Value; } PingTimer(job, true); @@ -461,7 +461,7 @@ namespace MediaBrowser.Api } } - Logger.Info("Transcoding kill timer stopped for JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); + Logger.LogInformation("Transcoding kill timer stopped for JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); KillTranscodingJob(job, true, path => true); } @@ -525,7 +525,7 @@ namespace MediaBrowser.Api { job.DisposeKillTimer(); - Logger.Debug("KillTranscodingJob - JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); + Logger.LogDebug("KillTranscodingJob - JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); lock (_activeTranscodingJobs) { @@ -557,7 +557,7 @@ namespace MediaBrowser.Api { try { - Logger.Info("Stopping ffmpeg process with q command for {0}", job.Path); + Logger.LogInformation("Stopping ffmpeg process with q command for {path}", job.Path); //process.Kill(); process.StandardInput.WriteLine("q"); @@ -565,13 +565,13 @@ namespace MediaBrowser.Api // Need to wait because killing is asynchronous if (!process.WaitForExit(5000)) { - Logger.Info("Killing ffmpeg process for {0}", job.Path); + Logger.LogInformation("Killing ffmpeg process for {path}", job.Path); process.Kill(); } } catch (Exception ex) { - Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path); + Logger.LogError(ex, "Error killing transcoding job for {path}", job.Path); } } } @@ -589,7 +589,7 @@ namespace MediaBrowser.Api } catch (Exception ex) { - Logger.ErrorException("Error closing live stream for {0}", ex, job.Path); + Logger.LogError(ex, "Error closing live stream for {path}", job.Path); } } } @@ -601,7 +601,7 @@ namespace MediaBrowser.Api return; } - Logger.Info("Deleting partial stream file(s) {0}", path); + Logger.LogInformation("Deleting partial stream file(s) {0}", path); await Task.Delay(delayMs).ConfigureAwait(false); @@ -620,15 +620,15 @@ namespace MediaBrowser.Api { } - catch (IOException) + catch (IOException ex) { - //Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); + Logger.LogError(ex, "Error deleting partial stream file(s) {path}", path); DeletePartialStreamFiles(path, jobType, retryCount + 1, 500); } - catch + catch (Exception ex) { - //Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); + Logger.LogError(ex, "Error deleting partial stream file(s) {path}", path); } } @@ -660,7 +660,7 @@ namespace MediaBrowser.Api { try { - //Logger.Debug("Deleting HLS file {0}", file); + //Logger.LogDebug("Deleting HLS file {0}", file); _fileSystem.DeleteFile(file); } catch (FileNotFoundException) @@ -670,7 +670,7 @@ namespace MediaBrowser.Api catch (IOException ex) { e = ex; - //Logger.ErrorException("Error deleting HLS file {0}", ex, file); + Logger.LogError(ex, "Error deleting HLS file {path}", file); } } @@ -802,12 +802,12 @@ namespace MediaBrowser.Api { if (KillTimer == null) { - //Logger.Debug("Starting kill timer at {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); + //Logger.LogDebug("Starting kill timer at {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); KillTimer = _timerFactory.Create(callback, this, intervalMs, Timeout.Infinite); } else { - //Logger.Debug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); + //Logger.LogDebug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); KillTimer.Change(intervalMs, Timeout.Infinite); } } @@ -826,7 +826,7 @@ namespace MediaBrowser.Api { var intervalMs = PingTimeout; - //Logger.Debug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); + //Logger.LogDebug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); KillTimer.Change(intervalMs, Timeout.Infinite); } } diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index e243927a0..ed31cbd1d 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -5,7 +5,7 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; @@ -55,12 +55,11 @@ namespace MediaBrowser.Api return Request.Headers[name]; } - private static readonly string[] EmptyStringArray = Array.Empty<string>(); public static string[] SplitValue(string value, char delim) { if (string.IsNullOrWhiteSpace(value)) { - return EmptyStringArray; + return Array.Empty<string>(); } return value.Split(new[] { delim }, StringSplitOptions.RemoveEmptyEntries); diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index c3b2e82e7..17c6d5dc5 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -21,6 +21,8 @@ using MediaBrowser.Controller.LiveTv; using MediaBrowser.Model.IO; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; + namespace MediaBrowser.Api.Images { /// <summary> @@ -360,7 +362,7 @@ namespace MediaBrowser.Api.Images } catch (Exception ex) { - Logger.ErrorException("Error getting image information for {0}", ex, info.Path); + Logger.LogError(ex, "Error getting image information for {path}", info.Path); return null; } @@ -673,7 +675,7 @@ namespace MediaBrowser.Api.Images private ImageFormat[] GetClientSupportedFormats() { - //Logger.Debug("Request types: {0}", string.Join(",", Request.AcceptTypes ?? Array.Empty<string>())); + //logger.LogDebug("Request types: {0}", string.Join(",", Request.AcceptTypes ?? Array.Empty<string>())); var supportedFormats = (Request.AcceptTypes ?? Array.Empty<string>()).Select(i => i.Split(';')[0]).ToArray(); var acceptParam = Request.QueryString["accept"]; diff --git a/MediaBrowser.Api/ItemLookupService.cs b/MediaBrowser.Api/ItemLookupService.cs index 39a790486..331fb711d 100644 --- a/MediaBrowser.Api/ItemLookupService.cs +++ b/MediaBrowser.Api/ItemLookupService.cs @@ -17,6 +17,7 @@ using System.Threading.Tasks; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -232,14 +233,14 @@ namespace MediaBrowser.Api // item.SetProviderId(key.Key, value); // } //} - Logger.Info("Setting provider id's to item {0}-{1}: {2}", item.Id, item.Name, _json.SerializeToString(request.ProviderIds)); + Logger.LogInformation("Setting provider id's to item {0}-{1}: {2}", item.Id, item.Name, _json.SerializeToString(request.ProviderIds)); // Since the refresh process won't erase provider Ids, we need to set this explicitly now. item.ProviderIds = request.ProviderIds; //item.ProductionYear = request.ProductionYear; //item.Name = request.Name; - return _providerManager.RefreshFullItem(item, new MetadataRefreshOptions(_fileSystem) + return _providerManager.RefreshFullItem(item, new MetadataRefreshOptions(new DirectoryService(Logger, _fileSystem)) { MetadataRefreshMode = MetadataRefreshMode.FullRefresh, ImageRefreshMode = MetadataRefreshMode.FullRefresh, diff --git a/MediaBrowser.Api/ItemRefreshService.cs b/MediaBrowser.Api/ItemRefreshService.cs index ab083c207..ba1c809fe 100644 --- a/MediaBrowser.Api/ItemRefreshService.cs +++ b/MediaBrowser.Api/ItemRefreshService.cs @@ -6,7 +6,7 @@ using System.Threading; using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.Services; namespace MediaBrowser.Api diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 22eb7ea09..d89750eae 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -230,7 +230,7 @@ namespace MediaBrowser.Api if (displayOrderChanged) { - _providerManager.QueueRefresh(series.Id, new MetadataRefreshOptions(_fileSystem) + _providerManager.QueueRefresh(series.Id, new MetadataRefreshOptions(new DirectoryService(Logger, _fileSystem)) { MetadataRefreshMode = MetadataRefreshMode.FullRefresh, ImageRefreshMode = MetadataRefreshMode.FullRefresh, diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index cc8c1251f..ecf3eb7db 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -32,6 +32,7 @@ using MediaBrowser.Common.Progress; using MediaBrowser.Model.Extensions; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Library { @@ -1000,7 +1001,7 @@ namespace MediaBrowser.Api.Library } catch (Exception ex) { - Logger.ErrorException("Error refreshing library", ex); + Logger.LogError(ex, "Error refreshing library"); } }); } diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 06c0c6862..ef9ce9aec 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -17,7 +17,6 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Api.UserLibrary; using MediaBrowser.Model.IO; -using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Model.Services; diff --git a/MediaBrowser.Api/LiveTv/ProgressiveFileCopier.cs b/MediaBrowser.Api/LiveTv/ProgressiveFileCopier.cs index 0a6ccd4c5..07ac7f28d 100644 --- a/MediaBrowser.Api/LiveTv/ProgressiveFileCopier.cs +++ b/MediaBrowser.Api/LiveTv/ProgressiveFileCopier.cs @@ -5,10 +5,10 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Library; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; using MediaBrowser.Model.Services; using MediaBrowser.Model.System; using MediaBrowser.Controller.IO; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.LiveTv { @@ -95,7 +95,7 @@ namespace MediaBrowser.Api.LiveTv bytesRead = await _streamHelper.CopyToAsync(inputStream, outputStream, cancellationToken).ConfigureAwait(false); //var position = fs.Position; - //_logger.Debug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path); + //_logger.LogDebug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path); if (bytesRead == 0) { diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index 3fa60fad1..5ffaaed27 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -6,7 +6,7 @@ </ItemGroup> <ItemGroup> - <Compile Include="..\SharedVersion.cs"/> + <Compile Include="..\SharedVersion.cs" /> </ItemGroup> <PropertyGroup> diff --git a/MediaBrowser.Api/NewsService.cs b/MediaBrowser.Api/NewsService.cs deleted file mode 100644 index cbc77bfc9..000000000 --- a/MediaBrowser.Api/NewsService.cs +++ /dev/null @@ -1,46 +0,0 @@ -using MediaBrowser.Model.News; -using MediaBrowser.Model.Querying; -using MediaBrowser.Model.Services; - -namespace MediaBrowser.Api -{ - [Route("/News/Product", "GET", Summary = "Gets the latest product news.")] - public class GetProductNews : IReturn<QueryResult<NewsItem>> - { - /// <summary> - /// Skips over a given number of items within the results. Use for paging. - /// </summary> - /// <value>The start index.</value> - [ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? StartIndex { get; set; } - - /// <summary> - /// The maximum number of items to return - /// </summary> - /// <value>The limit.</value> - [ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int? Limit { get; set; } - } - - public class NewsService : BaseApiService - { - private readonly INewsService _newsService; - - public NewsService(INewsService newsService) - { - _newsService = newsService; - } - - public object Get(GetProductNews request) - { - var result = _newsService.GetProductNews(new NewsQuery - { - StartIndex = request.StartIndex, - Limit = request.Limit - - }); - - return ToOptimizedResult(result); - } - } -} diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 9c2e0e9d8..fa6502bda 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -24,6 +24,7 @@ using MediaBrowser.Controller; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Diagnostics; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback { @@ -248,7 +249,7 @@ namespace MediaBrowser.Api.Playback cancellationTokenSource); var commandLineLogMessage = process.StartInfo.FileName + " " + process.StartInfo.Arguments; - Logger.Info(commandLineLogMessage); + Logger.LogInformation(commandLineLogMessage); var logFilePrefix = "ffmpeg-transcode"; if (state.VideoRequest != null && string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) && string.Equals(state.OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase)) @@ -277,7 +278,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - Logger.ErrorException("Error starting ffmpeg", ex); + Logger.LogError(ex, "Error starting ffmpeg"); ApiEntryPoint.Instance.OnTranscodeFailedToStart(outputPath, TranscodingJobType, state); @@ -351,16 +352,16 @@ namespace MediaBrowser.Api.Playback job.HasExited = true; } - Logger.Debug("Disposing stream resources"); + Logger.LogDebug("Disposing stream resources"); state.Dispose(); try { - Logger.Info("FFMpeg exited with code {0}", process.ExitCode); + Logger.LogInformation("FFMpeg exited with code {0}", process.ExitCode); } catch { - Logger.Error("FFMpeg exited with an error."); + Logger.LogError("FFMpeg exited with an error."); } // This causes on exited to be called twice: @@ -371,7 +372,7 @@ namespace MediaBrowser.Api.Playback //} //catch (Exception ex) //{ - // Logger.ErrorException("Error disposing ffmpeg.", ex); + // Logger.LogError(ex, "Error disposing ffmpeg."); //} } @@ -589,6 +590,22 @@ namespace MediaBrowser.Api.Playback } /// <summary> + /// Parses query parameters as StreamOptions + /// <summary> + /// <param name="request">The stream request.</param> + private void ParseStreamOptions(StreamRequest request) + { + foreach (var param in Request.QueryString) { + if (Char.IsLower(param.Name[0])) { + // This was probably not parsed initially and should be a StreamOptions + // TODO: This should be incorporated either in the lower framework for parsing requests + // or the generated URL should correctly serialize it + request.StreamOptions[param.Name] = param.Value; + } + } + } + + /// <summary> /// Parses the dlna headers. /// </summary> /// <param name="request">The request.</param> @@ -666,6 +683,8 @@ namespace MediaBrowser.Api.Playback ParseParams(request); } + ParseStreamOptions(request); + var url = Request.PathInfo; if (string.IsNullOrEmpty(request.AudioCodec)) @@ -685,7 +704,7 @@ namespace MediaBrowser.Api.Playback }; var auth = AuthorizationContext.GetAuthorizationInfo(Request); - if (auth.UserId != null) + if (!auth.UserId.Equals(Guid.Empty)) { state.User = UserManager.GetUserById(auth.UserId); } diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index a0f4a2e71..7ef7b81e6 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -15,6 +15,7 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Configuration; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback.Hls { @@ -185,7 +186,7 @@ namespace MediaBrowser.Api.Playback.Hls protected virtual async Task WaitForMinimumSegmentCount(string playlist, int segmentCount, CancellationToken cancellationToken) { - Logger.Debug("Waiting for {0} segments in {1}", segmentCount, playlist); + Logger.LogDebug("Waiting for {0} segments in {1}", segmentCount, playlist); while (!cancellationToken.IsCancellationRequested) { @@ -207,7 +208,7 @@ namespace MediaBrowser.Api.Playback.Hls count++; if (count >= segmentCount) { - Logger.Debug("Finished waiting for {0} segments in {1}", segmentCount, playlist); + Logger.LogDebug("Finished waiting for {0} segments in {1}", segmentCount, playlist); return; } } @@ -330,4 +331,4 @@ namespace MediaBrowser.Api.Playback.Hls { } } -}
\ No newline at end of file +} diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 0525c8cc4..5361e313c 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -21,6 +21,7 @@ using System.Threading.Tasks; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Services; using MimeTypes = MediaBrowser.Model.Net.MimeTypes; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback.Hls { @@ -190,17 +191,17 @@ namespace MediaBrowser.Api.Playback.Hls if (currentTranscodingIndex == null) { - Logger.Debug("Starting transcoding because currentTranscodingIndex=null"); + Logger.LogDebug("Starting transcoding because currentTranscodingIndex=null"); startTranscoding = true; } else if (requestedIndex < currentTranscodingIndex.Value) { - Logger.Debug("Starting transcoding because requestedIndex={0} and currentTranscodingIndex={1}", requestedIndex, currentTranscodingIndex); + Logger.LogDebug("Starting transcoding because requestedIndex={0} and currentTranscodingIndex={1}", requestedIndex, currentTranscodingIndex); startTranscoding = true; } else if (requestedIndex - currentTranscodingIndex.Value > segmentGapRequiringTranscodingChange) { - Logger.Debug("Starting transcoding because segmentGap is {0} and max allowed gap is {1}. requestedIndex={2}", requestedIndex - currentTranscodingIndex.Value, segmentGapRequiringTranscodingChange, requestedIndex); + Logger.LogDebug("Starting transcoding because segmentGap is {0} and max allowed gap is {1}. requestedIndex={2}", requestedIndex - currentTranscodingIndex.Value, segmentGapRequiringTranscodingChange, requestedIndex); startTranscoding = true; } if (startTranscoding) @@ -245,13 +246,13 @@ namespace MediaBrowser.Api.Playback.Hls } } - //Logger.Info("waiting for {0}", segmentPath); + //Logger.LogInformation("waiting for {0}", segmentPath); //while (!File.Exists(segmentPath)) //{ // await Task.Delay(50, cancellationToken).ConfigureAwait(false); //} - Logger.Info("returning {0}", segmentPath); + Logger.LogInformation("returning {0}", segmentPath); job = job ?? ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType); return await GetSegmentResult(state, playlistPath, segmentPath, segmentExtension, requestedIndex, job, cancellationToken).ConfigureAwait(false); } @@ -358,7 +359,7 @@ namespace MediaBrowser.Api.Playback.Hls return; } - Logger.Debug("Deleting partial HLS file {0}", path); + Logger.LogDebug("Deleting partial HLS file {path}", path); try { @@ -366,7 +367,7 @@ namespace MediaBrowser.Api.Playback.Hls } catch (IOException ex) { - Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); + Logger.LogError(ex, "Error deleting partial stream file(s) {path}", path); var task = Task.Delay(100); Task.WaitAll(task); @@ -374,7 +375,7 @@ namespace MediaBrowser.Api.Playback.Hls } catch (Exception ex) { - Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); + Logger.LogError(ex, "Error deleting partial stream file(s) {path}", path); } } @@ -968,4 +969,4 @@ namespace MediaBrowser.Api.Playback.Hls ).Trim(); } } -}
\ No newline at end of file +} diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index 2db0f8f41..6dafe134c 100644 --- a/MediaBrowser.Api/Playback/MediaInfoService.cs +++ b/MediaBrowser.Api/Playback/MediaInfoService.cs @@ -18,6 +18,7 @@ using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback { @@ -381,11 +382,11 @@ namespace MediaBrowser.Api.Playback if (item is Audio) { - Logger.Info("User policy for {0}. EnableAudioPlaybackTranscoding: {1}", user.Name, user.Policy.EnableAudioPlaybackTranscoding); + Logger.LogInformation("User policy for {0}. EnableAudioPlaybackTranscoding: {1}", user.Name, user.Policy.EnableAudioPlaybackTranscoding); } else { - Logger.Info("User policy for {0}. EnablePlaybackRemuxing: {1} EnableVideoPlaybackTranscoding: {2} EnableAudioPlaybackTranscoding: {3}", + Logger.LogInformation("User policy for {0}. EnablePlaybackRemuxing: {1} EnableVideoPlaybackTranscoding: {2} EnableAudioPlaybackTranscoding: {3}", user.Name, user.Policy.EnablePlaybackRemuxing, user.Policy.EnableVideoPlaybackTranscoding, @@ -525,7 +526,7 @@ namespace MediaBrowser.Api.Playback { var isInLocalNetwork = _networkManager.IsInLocalNetwork(Request.RemoteIp); - Logger.Info("RemoteClientBitrateLimit: {0}, RemoteIp: {1}, IsInLocalNetwork: {2}", remoteClientMaxBitrate, Request.RemoteIp, isInLocalNetwork); + Logger.LogInformation("RemoteClientBitrateLimit: {0}, RemoteIp: {1}, IsInLocalNetwork: {2}", remoteClientMaxBitrate, Request.RemoteIp, isInLocalNetwork); if (!isInLocalNetwork) { maxBitrate = Math.Min(maxBitrate ?? remoteClientMaxBitrate, remoteClientMaxBitrate); diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs index 44261f2d5..cc59b1049 100644 --- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs +++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs @@ -17,6 +17,8 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Services; using MediaBrowser.Model.System; +using Microsoft.Extensions.Logging; +using MediaBrowser.Api.LiveTv; namespace MediaBrowser.Api.Playback.Progressive { diff --git a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs index 9839a7a9a..ed2930b4d 100644 --- a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs +++ b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs @@ -1,16 +1,15 @@ -using MediaBrowser.Model.Logging; -using System; +using System; using System.IO; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.IO; using MediaBrowser.Controller.Net; using System.Collections.Generic; - using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Services; using MediaBrowser.Model.System; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback.Progressive { @@ -110,7 +109,7 @@ namespace MediaBrowser.Api.Playback.Progressive } //var position = fs.Position; - //_logger.Debug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path); + //_logger.LogDebug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path); if (bytesRead == 0) { diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index db5d256c4..67fb04d0c 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -4,7 +4,6 @@ using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Net; using System; @@ -14,6 +13,7 @@ using System.IO; using System.Linq; using System.Threading; using MediaBrowser.Controller.MediaEncoding; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback { @@ -162,7 +162,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.ErrorException("Error disposing log stream", ex); + _logger.LogError(ex, "Error disposing log stream"); } LogFileStream = null; @@ -179,7 +179,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.ErrorException("Error disposing TranscodingThrottler", ex); + _logger.LogError(ex, "Error disposing TranscodingThrottler"); } TranscodingThrottler = null; @@ -196,7 +196,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.ErrorException("Error closing media source", ex); + _logger.LogError(ex, "Error closing media source"); } } } diff --git a/MediaBrowser.Api/Playback/TranscodingThrottler.cs b/MediaBrowser.Api/Playback/TranscodingThrottler.cs index c42d0c3e4..5852852f6 100644 --- a/MediaBrowser.Api/Playback/TranscodingThrottler.cs +++ b/MediaBrowser.Api/Playback/TranscodingThrottler.cs @@ -1,9 +1,9 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Logging; using System; using MediaBrowser.Model.IO; using MediaBrowser.Model.Threading; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback { @@ -60,7 +60,7 @@ namespace MediaBrowser.Api.Playback { if (!_isPaused) { - _logger.Debug("Sending pause command to ffmpeg"); + _logger.LogDebug("Sending pause command to ffmpeg"); try { @@ -69,7 +69,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.ErrorException("Error pausing transcoding", ex); + _logger.LogError(ex, "Error pausing transcoding"); } } } @@ -78,7 +78,7 @@ namespace MediaBrowser.Api.Playback { if (_isPaused) { - _logger.Debug("Sending unpause command to ffmpeg"); + _logger.LogDebug("Sending resume command to ffmpeg"); try { @@ -87,7 +87,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.ErrorException("Error unpausing transcoding", ex); + _logger.LogError(ex, "Error resuming transcoding"); } } } @@ -110,11 +110,11 @@ namespace MediaBrowser.Api.Playback if (gap < targetGap) { - //_logger.Debug("Not throttling transcoder gap {0} target gap {1}", gap, targetGap); + _logger.LogDebug("Not throttling transcoder gap {0} target gap {1}", gap, targetGap); return false; } - //_logger.Debug("Throttling transcoder gap {0} target gap {1}", gap, targetGap); + _logger.LogDebug("Throttling transcoder gap {0} target gap {1}", gap, targetGap); return true; } @@ -135,21 +135,21 @@ namespace MediaBrowser.Api.Playback if (gap < targetGap) { - //_logger.Debug("Not throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); + _logger.LogDebug("Not throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); return false; } - //_logger.Debug("Throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); + _logger.LogDebug("Throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); return true; } - catch + catch (Exception ex) { - //_logger.Error("Error getting output size"); + _logger.LogError(ex, "Error getting output size"); return false; } } - //_logger.Debug("No throttle data for " + path); + _logger.LogDebug("No throttle data for " + path); return false; } diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index 1ee096a2e..1f1bb3614 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -8,13 +8,13 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Serialization; using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Services; using MediaBrowser.Common.Plugins; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -230,9 +230,9 @@ namespace MediaBrowser.Api .ToArray(); } } - catch + catch (Exception ex) { - //Logger.ErrorException("Error getting plugin list", ex); + Logger.LogError(ex, "Error getting plugin list"); // Play it safe here if (requireAppStoreEnabled) { diff --git a/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.cs b/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.cs index ff57b4dd1..fa5fa99d1 100644 --- a/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.cs +++ b/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.cs @@ -1,5 +1,5 @@ using MediaBrowser.Model.Events; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.Tasks; using System.Collections.Generic; using System.Linq; diff --git a/MediaBrowser.Api/Session/SessionInfoWebSocketListener.cs b/MediaBrowser.Api/Session/SessionInfoWebSocketListener.cs index ca2c381cf..533e7d307 100644 --- a/MediaBrowser.Api/Session/SessionInfoWebSocketListener.cs +++ b/MediaBrowser.Api/Session/SessionInfoWebSocketListener.cs @@ -1,7 +1,7 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.Session; using System.Collections.Generic; using System.Linq; diff --git a/MediaBrowser.Api/SimilarItemsHelper.cs b/MediaBrowser.Api/SimilarItemsHelper.cs index db5908f76..db075e8f4 100644 --- a/MediaBrowser.Api/SimilarItemsHelper.cs +++ b/MediaBrowser.Api/SimilarItemsHelper.cs @@ -3,7 +3,7 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.Querying; using System; using System.Collections.Generic; diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 7fccbcc9b..0ddc1e1dd 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -68,35 +68,6 @@ namespace MediaBrowser.Api _config.Configuration.IsStartupWizardCompleted = true; _config.SetOptimalValues(); _config.SaveConfiguration(); - - Task.Run(UpdateStats); - } - - private async Task UpdateStats() - { - try - { - var url = string.Format("http://www.mb3admin.local/admin/service/package/installed?mac={0}&product=MBServer&operation=Install&version={1}", - _appHost.SystemId, - _appHost.ApplicationVersion.ToString()); - - using (var response = await _httpClient.SendAsync(new HttpRequestOptions - { - - Url = url, - CancellationToken = CancellationToken.None, - LogErrors = false, - LogRequest = false - - }, "GET").ConfigureAwait(false)) - { - - } - } - catch - { - - } } public object Get(GetStartupConfiguration request) diff --git a/MediaBrowser.Api/Subtitles/SubtitleService.cs b/MediaBrowser.Api/Subtitles/SubtitleService.cs index c8b0a32e9..0e5b0a964 100644 --- a/MediaBrowser.Api/Subtitles/SubtitleService.cs +++ b/MediaBrowser.Api/Subtitles/SubtitleService.cs @@ -17,6 +17,7 @@ using System.Threading.Tasks; using MediaBrowser.Model.IO; using MediaBrowser.Model.Services; using MimeTypes = MediaBrowser.Model.Net.MimeTypes; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Subtitles { @@ -273,11 +274,11 @@ namespace MediaBrowser.Api.Subtitles await _subtitleManager.DownloadSubtitles(video, request.SubtitleId, CancellationToken.None) .ConfigureAwait(false); - _providerManager.QueueRefresh(video.Id, new MetadataRefreshOptions(_fileSystem), RefreshPriority.High); + _providerManager.QueueRefresh(video.Id, new MetadataRefreshOptions(new DirectoryService(Logger, _fileSystem)), RefreshPriority.High); } catch (Exception ex) { - Logger.ErrorException("Error downloading subtitles", ex); + Logger.LogError(ex, "Error downloading subtitles"); } }); diff --git a/MediaBrowser.Api/System/ActivityLogWebSocketListener.cs b/MediaBrowser.Api/System/ActivityLogWebSocketListener.cs index 6991244c6..b61ff8d93 100644 --- a/MediaBrowser.Api/System/ActivityLogWebSocketListener.cs +++ b/MediaBrowser.Api/System/ActivityLogWebSocketListener.cs @@ -1,6 +1,6 @@ using MediaBrowser.Model.Activity; using MediaBrowser.Model.Events; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using System.Collections.Generic; using System.Threading.Tasks; using MediaBrowser.Controller.Net; diff --git a/MediaBrowser.Api/System/SystemService.cs b/MediaBrowser.Api/System/SystemService.cs index d2880f735..52e14dbcc 100644 --- a/MediaBrowser.Api/System/SystemService.cs +++ b/MediaBrowser.Api/System/SystemService.cs @@ -9,12 +9,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; - -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Model.Net; using MediaBrowser.Model.Services; using System.Threading; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.System { @@ -137,11 +136,12 @@ namespace MediaBrowser.Api.System try { - files = _fileSystem.GetFiles(_appPaths.LogDirectoryPath, new[] { ".txt" }, true, false); + files = _fileSystem.GetFiles(_appPaths.LogDirectoryPath, new[] { ".txt", ".log" }, true, false); } - catch (IOException) + catch (IOException ex) { - files = new FileSystemMetadata[] { }; + Logger.LogError(ex, "Error getting logs"); + files = Enumerable.Empty<FileSystemMetadata>(); } var result = files.Select(i => new LogFile diff --git a/MediaBrowser.Api/UserLibrary/PlaystateService.cs b/MediaBrowser.Api/UserLibrary/PlaystateService.cs index 2c514a109..9b269542a 100644 --- a/MediaBrowser.Api/UserLibrary/PlaystateService.cs +++ b/MediaBrowser.Api/UserLibrary/PlaystateService.cs @@ -6,9 +6,9 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Session; using System; using System.Globalization; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.UserLibrary { @@ -381,7 +381,7 @@ namespace MediaBrowser.Api.UserLibrary public void Post(ReportPlaybackStopped request) { - Logger.Debug("ReportPlaybackStopped PlaySessionId: {0}", request.PlaySessionId ?? string.Empty); + Logger.LogDebug("ReportPlaybackStopped PlaySessionId: {0}", request.PlaySessionId ?? string.Empty); if (!string.IsNullOrWhiteSpace(request.PlaySessionId)) { diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index 30df0ad23..d188d7f7e 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -404,7 +404,7 @@ namespace MediaBrowser.Api.UserLibrary if (!hasMetdata) { - var options = new MetadataRefreshOptions(_fileSystem) + var options = new MetadataRefreshOptions(new DirectoryService(Logger, _fileSystem)) { MetadataRefreshMode = MetadataRefreshMode.FullRefresh, ImageRefreshMode = MetadataRefreshMode.FullRefresh, diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 29f3070a5..913a55b2b 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Authentication; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Devices; @@ -10,11 +11,9 @@ using MediaBrowser.Model.Connect; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Users; using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using MediaBrowser.Model.Services; -using MediaBrowser.Controller.Authentication; namespace MediaBrowser.Api { |
