#712 - group multiple versions

pull/702/head
Luke Pulverenti 11 years ago
parent 683d8455c6
commit b762d98fc4

@ -31,9 +31,9 @@ namespace MediaBrowser.Api
public string Id { get; set; }
}
[Route("/Videos/{Id}/AlternateVersions", "GET")]
[Api(Description = "Gets alternate versions of a video.")]
public class GetAlternateVersions : IReturn<List<AlternateVersionInfo>>
[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.
@ -113,32 +113,54 @@ namespace MediaBrowser.Api
return ToOptimizedSerializedResultUsingCache(result);
}
public object Get(GetAlternateVersions request)
public object Get(GetMediaVersions request)
{
var item = _libraryManager.GetItemById(new Guid(request.Id));
var video = (Video)item;
var items = video.GetAlternateVersions();
var result = video.GetAlternateVersions().Select(GetVersionInfo).ToList();
var result = items.Select(i => new AlternateVersionInfo
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(),
MediaStreams = _itemRepo.GetMediaStreams(new MediaStreamQuery {ItemId = i.Id}).ToList(),
Name = GetAlternateVersionName(i),
Path = GetMappedPath(i),
RunTimeTicks = i.RunTimeTicks,
Video3DFormat = i.Video3DFormat,
VideoType = i.VideoType,
IsHD = i.IsHD
}).ToList();
return ToOptimizedSerializedResultUsingCache(result);
};
}
private string GetMappedPath(Video video)

@ -107,9 +107,6 @@
<Compile Include="..\MediaBrowser.Model\Drawing\ImageOutputFormat.cs">
<Link>Drawing\ImageOutputFormat.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\AlternateVersionInfo.cs">
<Link>Dto\AlternateVersionInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\BaseItemDto.cs">
<Link>Dto\BaseItemDto.cs</Link>
</Compile>
@ -140,6 +137,9 @@
<Compile Include="..\MediaBrowser.Model\Dto\ItemIndex.cs">
<Link>Dto\ItemIndex.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\MediaVersionInfo.cs">
<Link>Dto\MediaVersionInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\RecommendationDto.cs">
<Link>Dto\RecommendationDto.cs</Link>
</Compile>

@ -94,9 +94,6 @@
<Compile Include="..\MediaBrowser.Model\Drawing\ImageOutputFormat.cs">
<Link>Drawing\ImageOutputFormat.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\AlternateVersionInfo.cs">
<Link>Dto\AlternateVersionInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\BaseItemDto.cs">
<Link>Dto\BaseItemDto.cs</Link>
</Compile>
@ -127,6 +124,9 @@
<Compile Include="..\MediaBrowser.Model\Dto\ItemIndex.cs">
<Link>Dto\ItemIndex.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\MediaVersionInfo.cs">
<Link>Dto\MediaVersionInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\RecommendationDto.cs">
<Link>Dto\RecommendationDto.cs</Link>
</Compile>

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace MediaBrowser.Model.Dto
{
public class AlternateVersionInfo
public class MediaVersionInfo
{
public string Id { get; set; }

@ -76,7 +76,7 @@
<Compile Include="Dto\ItemCounts.cs" />
<Compile Include="Dto\ItemIndex.cs" />
<Compile Include="Dto\RecommendationDto.cs" />
<Compile Include="Dto\AlternateVersionInfo.cs" />
<Compile Include="Dto\MediaVersionInfo.cs" />
<Compile Include="Entities\PackageReviewInfo.cs" />
<Compile Include="FileOrganization\FileOrganizationResult.cs" />
<Compile Include="FileOrganization\FileOrganizationQuery.cs" />

@ -35,6 +35,8 @@ namespace MediaBrowser.Server.Implementations.Library
var inputItems = user.RootFolder.GetRecursiveChildren(user, null).Where(i => !(i is ICollectionFolder));
inputItems = _libraryManager.ReplaceVideosWithPrimaryVersions(inputItems);
var results = await GetSearchHints(inputItems, query).ConfigureAwait(false);
// Include item types

@ -119,11 +119,9 @@ namespace MediaBrowser.ServerApplication
var subFolder = item as Folder;
if (subFolder != null)
{
var prefs = _displayPreferencesManager.GetDisplayPreferences(subFolder.DisplayPreferencesId, user.Id, "LibraryExplorer");
var subChildren = isPhysical ? subFolder.Children : subFolder.GetChildren(_currentUser, true);
AddChildren(node, OrderBy(subChildren, user, prefs.SortBy), user, isPhysical);
AddChildren(node, OrderBy(subChildren, user, ItemSortBy.SortName), user, isPhysical);
node.Text = item.Name + " (" + node.Nodes.Count + ")";
}
else

Loading…
Cancel
Save