aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Api')
-rw-r--r--MediaBrowser.Api/Movies/CollectionService.cs9
-rw-r--r--MediaBrowser.Api/SessionsService.cs12
-rw-r--r--MediaBrowser.Api/VideosService.cs178
3 files changed, 11 insertions, 188 deletions
diff --git a/MediaBrowser.Api/Movies/CollectionService.cs b/MediaBrowser.Api/Movies/CollectionService.cs
index 456449b7b6..f09992e00f 100644
--- a/MediaBrowser.Api/Movies/CollectionService.cs
+++ b/MediaBrowser.Api/Movies/CollectionService.cs
@@ -6,8 +6,7 @@ using System.Threading.Tasks;
namespace MediaBrowser.Api.Movies
{
- [Route("/Collections", "POST")]
- [Api(Description = "Creates a new collection")]
+ [Route("/Collections", "POST", Summary = "Creates a new collection")]
public class CreateCollection : IReturnVoid
{
[ApiMember(Name = "IsLocked", Description = "Whether or not to lock the new collection.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
@@ -20,8 +19,7 @@ namespace MediaBrowser.Api.Movies
public Guid? ParentId { get; set; }
}
- [Route("/Collections/{Id}/Items", "POST")]
- [Api(Description = "Adds items to a collection")]
+ [Route("/Collections/{Id}/Items", "POST", Summary = "Adds items to a collection")]
public class AddToCollection : IReturnVoid
{
[ApiMember(Name = "Ids", Description = "Item id, comma delimited", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
@@ -31,8 +29,7 @@ namespace MediaBrowser.Api.Movies
public Guid Id { get; set; }
}
- [Route("/Collections/{Id}/Items", "DELETE")]
- [Api(Description = "Removes items from a collection")]
+ [Route("/Collections/{Id}/Items", "DELETE", Summary = "Removes items from a collection")]
public class RemoveFromCollection : IReturnVoid
{
[ApiMember(Name = "Ids", Description = "Item id, comma delimited", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs
index 62e5a252ec..e73e3490ec 100644
--- a/MediaBrowser.Api/SessionsService.cs
+++ b/MediaBrowser.Api/SessionsService.cs
@@ -210,6 +210,9 @@ namespace MediaBrowser.Api
[ApiMember(Name = "PlayableMediaTypes", Description = "A list of playable media types, comma delimited. Audio, Video, Book, Game, Photo.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
public string PlayableMediaTypes { get; set; }
+
+ [ApiMember(Name = "SupportsFullscreenToggle", Description = "Whether or not the session supports fullscreen toggle", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")]
+ public bool SupportsFullscreenToggle { get; set; }
}
/// <summary>
@@ -361,11 +364,12 @@ namespace MediaBrowser.Api
public void Post(PostCapabilities request)
{
- var session = _sessionManager.Sessions.First(i => i.Id == request.Id);
+ _sessionManager.ReportCapabilities(request.Id, new SessionCapabilities
+ {
+ PlayableMediaTypes = request.PlayableMediaTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries),
- session.PlayableMediaTypes = request.PlayableMediaTypes
- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
- .ToList();
+ SupportsFullscreenToggle = request.SupportsFullscreenToggle
+ });
}
private SessionInfo GetSession()
diff --git a/MediaBrowser.Api/VideosService.cs b/MediaBrowser.Api/VideosService.cs
index f7f864d7e5..fa4b22cea7 100644
--- a/MediaBrowser.Api/VideosService.cs
+++ b/MediaBrowser.Api/VideosService.cs
@@ -4,12 +4,9 @@ using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
using ServiceStack;
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -31,18 +28,6 @@ namespace MediaBrowser.Api
public string Id { get; set; }
}
- [Route("/Videos/{Id}/Versions", "GET")]
- [Api(Description = "Gets all versions of a video.")]
- public class GetMediaVersions : IReturn<List<MediaVersionInfo>>
- {
- /// <summary>
- /// Gets or sets the id.
- /// </summary>
- /// <value>The id.</value>
- [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
- public string Id { get; set; }
- }
-
[Route("/Videos/{Id}/AlternateVersions", "DELETE")]
[Api(Description = "Assigns videos as alternates of antoher.")]
public class DeleteAlternateVersions : IReturnVoid
@@ -113,169 +98,6 @@ namespace MediaBrowser.Api
return ToOptimizedSerializedResultUsingCache(result);
}
- public object Get(GetMediaVersions request)
- {
- var item = _libraryManager.GetItemById(new Guid(request.Id));
-
- var video = (Video)item;
-
- var result = video.GetAlternateVersions().Select(GetVersionInfo).ToList();
-
- result.Add(GetVersionInfo(video));
-
- result = result.OrderBy(i =>
- {
- if (video.VideoType == VideoType.VideoFile)
- {
- return 0;
- }
-
- return 1;
-
- }).ThenBy(i => i.Video3DFormat.HasValue ? 1 : 0)
- .ThenByDescending(i =>
- {
- var stream = i.MediaStreams.FirstOrDefault(m => m.Type == MediaStreamType.Video);
-
- return stream == null || stream.Width == null ? 0 : stream.Width.Value;
- })
- .ToList();
-
- return ToOptimizedSerializedResultUsingCache(result);
- }
-
- private MediaVersionInfo GetVersionInfo(Video i)
- {
- return new MediaVersionInfo
- {
- Chapters = _itemRepo.GetChapters(i.Id).Select(c => _dtoService.GetChapterInfoDto(c, i)).ToList(),
-
- Id = i.Id.ToString("N"),
- IsoType = i.IsoType,
- LocationType = i.LocationType,
- MediaStreams = _itemRepo.GetMediaStreams(new MediaStreamQuery {ItemId = i.Id}).ToList(),
- Name = GetAlternateVersionName(i),
- Path = GetMappedPath(i),
- RunTimeTicks = i.RunTimeTicks,
- Video3DFormat = i.Video3DFormat,
- VideoType = i.VideoType
- };
- }
-
- private string GetMappedPath(Video video)
- {
- var path = video.Path;
-
- var locationType = video.LocationType;
-
- if (locationType != LocationType.FileSystem && locationType != LocationType.Offline)
- {
- return path;
- }
-
- foreach (var map in _config.Configuration.PathSubstitutions)
- {
- path = _fileSystem.SubstitutePath(path, map.From, map.To);
- }
-
- return path;
- }
-
- private string GetAlternateVersionName(Video video)
- {
- var name = "";
-
- var stream = video.GetDefaultVideoStream();
-
- if (video.Video3DFormat.HasValue)
- {
- name = "3D " + name;
- name = name.Trim();
- }
-
- if (video.VideoType == VideoType.BluRay)
- {
- name = name + " " + "Bluray";
- name = name.Trim();
- }
- else if (video.VideoType == VideoType.Dvd)
- {
- name = name + " " + "DVD";
- name = name.Trim();
- }
- else if (video.VideoType == VideoType.HdDvd)
- {
- name = name + " " + "HD-DVD";
- name = name.Trim();
- }
- else if (video.VideoType == VideoType.Iso)
- {
- if (video.IsoType.HasValue)
- {
- if (video.IsoType.Value == IsoType.BluRay)
- {
- name = name + " " + "Bluray";
- }
- else if (video.IsoType.Value == IsoType.Dvd)
- {
- name = name + " " + "DVD";
- }
- }
- else
- {
- name = name + " " + "ISO";
- }
- name = name.Trim();
- }
- else if (video.VideoType == VideoType.VideoFile)
- {
- if (stream != null)
- {
- if (stream.Width.HasValue)
- {
- if (stream.Width.Value >= 3800)
- {
- name = name + " " + "4K";
- name = name.Trim();
- }
- else if (stream.Width.Value >= 1900)
- {
- name = name + " " + "1080P";
- name = name.Trim();
- }
- else if (stream.Width.Value >= 1270)
- {
- name = name + " " + "720P";
- name = name.Trim();
- }
- else if (stream.Width.Value >= 700)
- {
- name = name + " " + "480p";
- name = name.Trim();
- }
- else
- {
- name = name + " " + "SD";
- name = name.Trim();
- }
- }
- }
- }
-
- if (stream != null && !string.IsNullOrWhiteSpace(stream.Codec))
- {
- name = name + " " + stream.Codec.ToUpper();
- name = name.Trim();
- }
-
- if (string.IsNullOrWhiteSpace(name))
- {
- return video.Name;
- }
-
- return name;
- }
-
public void Delete(DeleteAlternateVersions request)
{
var task = RemoveAlternateVersions(request);