jellyfin/MediaBrowser.Model/Dlna/SearchCriteria.cs

52 lines
2.0 KiB
C#
Raw Normal View History

using MediaBrowser.Model.Extensions;
using System;
2014-04-19 22:21:08 -07:00
namespace MediaBrowser.Model.Dlna
{
public class SearchCriteria
{
public SearchType SearchType { get; set; }
public SearchCriteria(string search)
{
if (string.IsNullOrEmpty(search))
{
throw new ArgumentNullException("search");
}
SearchType = SearchType.Unknown;
2014-08-16 22:38:13 -07:00
String[] factors = StringHelper.RegexSplit(search, "(and|or)");
foreach (String factor in factors)
2014-04-19 22:21:08 -07:00
{
2014-08-16 22:38:13 -07:00
String[] subFactors = StringHelper.RegexSplit(factor.Trim().Trim('(').Trim(')').Trim(), "\\s", 3);
if (subFactors.Length == 3)
2014-04-19 22:21:08 -07:00
{
2014-08-16 22:38:13 -07:00
if (StringHelper.EqualsIgnoreCase("upnp:class", subFactors[0]) &&
(StringHelper.EqualsIgnoreCase("=", subFactors[1]) || StringHelper.EqualsIgnoreCase("derivedfrom", subFactors[1])))
{
if (StringHelper.EqualsIgnoreCase("\"object.item.imageItem\"", subFactors[2]) || StringHelper.EqualsIgnoreCase("\"object.item.imageItem.photo\"", subFactors[2]))
{
SearchType = SearchType.Image;
}
else if (StringHelper.EqualsIgnoreCase("\"object.item.videoItem\"", subFactors[2]))
{
SearchType = SearchType.Video;
}
else if (StringHelper.EqualsIgnoreCase("\"object.container.playlistContainer\"", subFactors[2]))
{
SearchType = SearchType.Playlist;
}
else if (StringHelper.EqualsIgnoreCase("\"object.container.album.musicAlbum\"", subFactors[2]))
{
SearchType = SearchType.MusicAlbum;
}
}
2014-04-19 22:21:08 -07:00
}
}
}
}
}