Skip to content

Commit

Permalink
Merge pull request #2080 from MediaBrowser/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
LukePulverenti committed Aug 19, 2016
2 parents 7377ab6 + 0f98473 commit 0e2004d
Show file tree
Hide file tree
Showing 396 changed files with 17,574 additions and 5,949 deletions.
8 changes: 5 additions & 3 deletions MediaBrowser.Api/ApiEntryPoint.cs
Expand Up @@ -192,13 +192,13 @@ protected virtual void Dispose(bool dispose)

_activeTranscodingJobs.Add(job);

ReportTranscodingProgress(job, state, null, null, null, null);
ReportTranscodingProgress(job, state, null, null, null, null, null);

return job;
}
}

public void ReportTranscodingProgress(TranscodingJob job, StreamState state, TimeSpan? transcodingPosition, float? framerate, double? percentComplete, long? bytesTranscoded)
public void ReportTranscodingProgress(TranscodingJob job, StreamState state, TimeSpan? transcodingPosition, float? framerate, double? percentComplete, long? bytesTranscoded, int? bitRate)
{
var ticks = transcodingPosition.HasValue ? transcodingPosition.Value.Ticks : (long?)null;

Expand All @@ -208,6 +208,7 @@ public void ReportTranscodingProgress(TranscodingJob job, StreamState state, Tim
job.CompletionPercentage = percentComplete;
job.TranscodingPositionTicks = ticks;
job.BytesTranscoded = bytesTranscoded;
job.BitRate = bitRate;
}

var deviceId = state.Request.DeviceId;
Expand All @@ -219,7 +220,7 @@ public void ReportTranscodingProgress(TranscodingJob job, StreamState state, Tim

_sessionManager.ReportTranscodingInfo(deviceId, new TranscodingInfo
{
Bitrate = state.TotalOutputBitrate,
Bitrate = bitRate ?? state.TotalOutputBitrate,
AudioCodec = audioCodec,
VideoCodec = videoCodec,
Container = state.OutputContainer,
Expand Down Expand Up @@ -694,6 +695,7 @@ public class TranscodingJob

public long? BytesDownloaded { get; set; }
public long? BytesTranscoded { get; set; }
public int? BitRate { get; set; }

public long? TranscodingPositionTicks { get; set; }
public long? DownloadPositionTicks { get; set; }
Expand Down
4 changes: 4 additions & 0 deletions MediaBrowser.Api/BaseApiService.cs
Expand Up @@ -139,6 +139,10 @@ protected DtoOptions GetDtoOptions(object request)
{
options.ImageTypeLimit = hasDtoOptions.ImageTypeLimit.Value;
}
if (hasDtoOptions.EnableUserData.HasValue)
{
options.EnableUserData = hasDtoOptions.EnableUserData.Value;
}

if (!string.IsNullOrWhiteSpace(hasDtoOptions.EnableImageTypes))
{
Expand Down
1 change: 1 addition & 0 deletions MediaBrowser.Api/IHasDtoOptions.cs
Expand Up @@ -4,6 +4,7 @@ namespace MediaBrowser.Api
public interface IHasDtoOptions : IHasItemFields
{
bool? EnableImages { get; set; }
bool? EnableUserData { get; set; }

int? ImageTypeLimit { get; set; }

Expand Down
4 changes: 1 addition & 3 deletions MediaBrowser.Api/Images/ImageService.cs
Expand Up @@ -573,11 +573,9 @@ public Task<object> GetImage(ImageRequest request, IHasImages item, bool isHeadR

var outputFormats = GetOutputFormats(request, imageInfo, cropwhitespace, supportedImageEnhancers);

var cacheGuid = new Guid(_imageProcessor.GetImageCacheTag(item, imageInfo, supportedImageEnhancers));

TimeSpan? cacheDuration = null;

if (!string.IsNullOrEmpty(request.Tag) && cacheGuid == new Guid(request.Tag))
if (!string.IsNullOrEmpty(request.Tag))
{
cacheDuration = TimeSpan.FromDays(365);
}
Expand Down
32 changes: 27 additions & 5 deletions MediaBrowser.Api/Library/LibraryStructureService.cs
Expand Up @@ -10,6 +10,9 @@
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Configuration;

namespace MediaBrowser.Api.Library
{
Expand Down Expand Up @@ -52,6 +55,8 @@ public class AddVirtualFolder : IReturnVoid
/// </summary>
/// <value>The path.</value>
public string[] Paths { get; set; }

public LibraryOptions LibraryOptions { get; set; }
}

[Route("/Library/VirtualFolders", "DELETE")]
Expand Down Expand Up @@ -136,6 +141,14 @@ public class RemoveMediaPath : IReturnVoid
public bool RefreshLibrary { get; set; }
}

[Route("/Library/VirtualFolders/LibraryOptions", "POST")]
public class UpdateLibraryOptions : IReturnVoid
{
public string Id { get; set; }

public LibraryOptions LibraryOptions { get; set; }
}

/// <summary>
/// Class LibraryStructureService
/// </summary>
Expand Down Expand Up @@ -184,13 +197,22 @@ public object Get(GetVirtualFolders request)
return ToOptimizedSerializedResultUsingCache(result);
}

public void Post(UpdateLibraryOptions request)
{
var collectionFolder = (CollectionFolder)_libraryManager.GetItemById(request.Id);

collectionFolder.UpdateLibraryOptions(request.LibraryOptions);
}

/// <summary>
/// Posts the specified request.
/// </summary>
/// <param name="request">The request.</param>
public void Post(AddVirtualFolder request)
{
_libraryManager.AddVirtualFolder(request.Name, request.CollectionType, request.Paths, request.RefreshLibrary);
var libraryOptions = request.LibraryOptions ?? new LibraryOptions();

_libraryManager.AddVirtualFolder(request.Name, request.CollectionType, request.Paths, libraryOptions, request.RefreshLibrary);
}

/// <summary>
Expand All @@ -214,12 +236,12 @@ public void Post(RenameVirtualFolder request)
var currentPath = Path.Combine(rootFolderPath, request.Name);
var newPath = Path.Combine(rootFolderPath, request.NewName);

if (!_fileSystem.DirectoryExists(currentPath))
if (!_fileSystem.DirectoryExists(currentPath))
{
throw new DirectoryNotFoundException("The media collection does not exist");
}

if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && _fileSystem.DirectoryExists(newPath))
if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && _fileSystem.DirectoryExists(newPath))
{
throw new ArgumentException("There is already a media collection with the name " + newPath + ".");
}
Expand All @@ -234,11 +256,11 @@ public void Post(RenameVirtualFolder request)
//Create an unique name
var temporaryName = Guid.NewGuid().ToString();
var temporaryPath = Path.Combine(rootFolderPath, temporaryName);
_fileSystem.MoveDirectory(currentPath, temporaryPath);
_fileSystem.MoveDirectory(currentPath, temporaryPath);
currentPath = temporaryPath;
}

_fileSystem.MoveDirectory(currentPath, newPath);
_fileSystem.MoveDirectory(currentPath, newPath);
}
finally
{
Expand Down
27 changes: 26 additions & 1 deletion MediaBrowser.Api/LiveTv/LiveTvService.cs
Expand Up @@ -82,6 +82,9 @@ public class GetChannels : IReturn<QueryResult<ChannelInfoDto>>, IHasDtoOptions
[ApiMember(Name = "AddCurrentProgram", Description = "Optional. Adds current program info to each channel", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public bool AddCurrentProgram { get; set; }

[ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool? EnableUserData { get; set; }

public GetChannels()
{
AddCurrentProgram = true;
Expand Down Expand Up @@ -149,6 +152,9 @@ public class GetRecordings : IReturn<QueryResult<BaseItemDto>>, IHasDtoOptions

public bool EnableTotalRecordCount { get; set; }

[ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool? EnableUserData { get; set; }

public GetRecordings()
{
EnableTotalRecordCount = true;
Expand Down Expand Up @@ -271,6 +277,9 @@ public class GetPrograms : IReturn<QueryResult<BaseItemDto>>, IHasDtoOptions
[ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string EnableImageTypes { get; set; }

[ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool? EnableUserData { get; set; }

/// <summary>
/// Fields to return within the items, in addition to basic information
/// </summary>
Expand Down Expand Up @@ -331,6 +340,9 @@ public GetRecommendedPrograms()
/// <value>The fields.</value>
[ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Fields { get; set; }

[ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
public bool? EnableUserData { get; set; }
}

[Route("/LiveTv/Programs/{Id}", "GET", Summary = "Gets a live tv program")]
Expand Down Expand Up @@ -726,7 +738,12 @@ public async Task<object> Get(GetChannels request)

var user = string.IsNullOrEmpty(request.UserId) ? null : _userManager.GetUserById(request.UserId);

var returnArray = (await _dtoService.GetBaseItemDtos(channelResult.Items, GetDtoOptions(Request), user).ConfigureAwait(false)).ToArray();
var options = GetDtoOptions(request);
RemoveFields(options);

options.AddCurrentProgram = request.AddCurrentProgram;

var returnArray = (await _dtoService.GetBaseItemDtos(channelResult.Items, options, user).ConfigureAwait(false)).ToArray();

var result = new QueryResult<BaseItemDto>
{
Expand All @@ -737,6 +754,14 @@ public async Task<object> Get(GetChannels request)
return ToOptimizedSerializedResultUsingCache(result);
}

private void RemoveFields(DtoOptions options)
{
options.Fields.Remove(ItemFields.CanDelete);
options.Fields.Remove(ItemFields.CanDownload);
options.Fields.Remove(ItemFields.DisplayPreferencesId);
options.Fields.Remove(ItemFields.Etag);
}

public object Get(GetChannel request)
{
var user = string.IsNullOrWhiteSpace(request.UserId) ? null : _userManager.GetUserById(request.UserId);
Expand Down

0 comments on commit 0e2004d

Please sign in to comment.