diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-13 16:53:46 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-13 16:53:46 -0400 |
| commit | 93fdbc17d8e3dde88647b8baad20d664374d4a35 (patch) | |
| tree | 4985bac40bca83c2eda21de949771b6d7bf52781 | |
| parent | b07a1e67c26a595b906dccc135dfff62d9883e65 (diff) | |
Added video bitrate sort order
4 files changed, 52 insertions, 6 deletions
diff --git a/MediaBrowser.Model/Querying/ItemSortBy.cs b/MediaBrowser.Model/Querying/ItemSortBy.cs index deb0ce51d..f2c9ece32 100644 --- a/MediaBrowser.Model/Querying/ItemSortBy.cs +++ b/MediaBrowser.Model/Querying/ItemSortBy.cs @@ -82,5 +82,6 @@ namespace MediaBrowser.Model.Querying public const string AlbumCount = "AlbumCount"; public const string MusicVideoCount = "MusicVideoCount"; public const string SeriesSortName = "SeriesSortName"; + public const string VideoBitRate = "VideoBitRate"; } } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 6be7487ad..fed6dad82 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -210,6 +210,7 @@ <Compile Include="Persistence\SqliteUserDataRepository.cs" /> <Compile Include="Persistence\SqliteUserRepository.cs" /> <Compile Include="Sorting\TrailerCountComparer.cs" /> + <Compile Include="Sorting\VideoBitRateComparer.cs" /> <Compile Include="Udp\UdpMessageReceivedEventArgs.cs" /> <Compile Include="Udp\UdpServer.cs" /> <Compile Include="WebSocket\AlchemyServer.cs" /> diff --git a/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs index 33da4cec3..f8c8c4bce 100644 --- a/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Sorting; diff --git a/MediaBrowser.Server.Implementations/Sorting/VideoBitRateComparer.cs b/MediaBrowser.Server.Implementations/Sorting/VideoBitRateComparer.cs new file mode 100644 index 000000000..469eb5d6a --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/VideoBitRateComparer.cs @@ -0,0 +1,49 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Querying; +using System.Linq; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + class VideoBitRateComparer : IBaseItemComparer + { + /// <summary> + /// Compares the specified x. + /// </summary> + /// <param name="x">The x.</param> + /// <param name="y">The y.</param> + /// <returns>System.Int32.</returns> + public int Compare(BaseItem x, BaseItem y) + { + return GetValue(x).CompareTo(GetValue(y)); + } + + private int GetValue(BaseItem item) + { + var video = item as IHasMediaStreams; + + if (video != null) + { + var videoStream = video.MediaStreams + .FirstOrDefault(i => i.Type == MediaStreamType.Video); + + if (videoStream != null) + { + return videoStream.BitRate ?? 0; + } + } + + return 0; + } + + /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + public string Name + { + get { return ItemSortBy.VideoBitRate; } + } + } +} |
