mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-23 10:34:43 +01:00
Merge pull request #9762 from crobibero/media-type
Convert string MediaType to enum MediaType
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
@@ -227,9 +228,12 @@ namespace MediaBrowser.Model.Dlna
|
||||
/// The GetSupportedMediaTypes.
|
||||
/// </summary>
|
||||
/// <returns>The .</returns>
|
||||
public string[] GetSupportedMediaTypes()
|
||||
public MediaType[] GetSupportedMediaTypes()
|
||||
{
|
||||
return ContainerProfile.SplitValue(SupportedMediaTypes);
|
||||
return ContainerProfile.SplitValue(SupportedMediaTypes)
|
||||
.Select(m => Enum.TryParse<MediaType>(m, out var parsed) ? parsed : MediaType.Unknown)
|
||||
.Where(m => m != MediaType.Unknown)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -591,7 +591,7 @@ namespace MediaBrowser.Model.Dto
|
||||
/// Gets or sets the type of the media.
|
||||
/// </summary>
|
||||
/// <value>The type of the media.</value>
|
||||
public string MediaType { get; set; }
|
||||
public MediaType MediaType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the end date.
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
namespace MediaBrowser.Model.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Class MediaType.
|
||||
/// </summary>
|
||||
public static class MediaType
|
||||
{
|
||||
/// <summary>
|
||||
/// The video.
|
||||
/// </summary>
|
||||
public const string Video = "Video";
|
||||
|
||||
/// <summary>
|
||||
/// The audio.
|
||||
/// </summary>
|
||||
public const string Audio = "Audio";
|
||||
|
||||
/// <summary>
|
||||
/// The photo.
|
||||
/// </summary>
|
||||
public const string Photo = "Photo";
|
||||
|
||||
/// <summary>
|
||||
/// The book.
|
||||
/// </summary>
|
||||
public const string Book = "Book";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Model.Playlists;
|
||||
@@ -22,7 +23,7 @@ public class PlaylistCreationRequest
|
||||
/// <summary>
|
||||
/// Gets or sets the media type.
|
||||
/// </summary>
|
||||
public string? MediaType { get; set; }
|
||||
public MediaType? MediaType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace MediaBrowser.Model.Search
|
||||
{
|
||||
Name = string.Empty;
|
||||
MatchedTerm = string.Empty;
|
||||
MediaType = string.Empty;
|
||||
MediaType = Jellyfin.Data.Enums.MediaType.Unknown;
|
||||
Artists = Array.Empty<string>();
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace MediaBrowser.Model.Search
|
||||
/// Gets or sets the type of the media.
|
||||
/// </summary>
|
||||
/// <value>The type of the media.</value>
|
||||
public string MediaType { get; set; }
|
||||
public MediaType MediaType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the start date.
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace MediaBrowser.Model.Search
|
||||
IncludePeople = true;
|
||||
IncludeStudios = true;
|
||||
|
||||
MediaTypes = Array.Empty<string>();
|
||||
MediaTypes = Array.Empty<MediaType>();
|
||||
IncludeItemTypes = Array.Empty<BaseItemKind>();
|
||||
ExcludeItemTypes = Array.Empty<BaseItemKind>();
|
||||
}
|
||||
@@ -55,7 +55,7 @@ namespace MediaBrowser.Model.Search
|
||||
|
||||
public bool IncludeArtists { get; set; }
|
||||
|
||||
public string[] MediaTypes { get; set; }
|
||||
public MediaType[] MediaTypes { get; set; }
|
||||
|
||||
public BaseItemKind[] IncludeItemTypes { get; set; }
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
|
||||
namespace MediaBrowser.Model.Session
|
||||
@@ -11,12 +12,12 @@ namespace MediaBrowser.Model.Session
|
||||
{
|
||||
public ClientCapabilities()
|
||||
{
|
||||
PlayableMediaTypes = Array.Empty<string>();
|
||||
PlayableMediaTypes = Array.Empty<MediaType>();
|
||||
SupportedCommands = Array.Empty<GeneralCommandType>();
|
||||
SupportsPersistentIdentifier = true;
|
||||
}
|
||||
|
||||
public IReadOnlyList<string> PlayableMediaTypes { get; set; }
|
||||
public IReadOnlyList<MediaType> PlayableMediaTypes { get; set; }
|
||||
|
||||
public IReadOnlyList<GeneralCommandType> SupportedCommands { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user