/// <summary> /// Gets the image URL. /// </summary> /// <param name="baseUrl">The base URL.</param> /// <param name="options">The options.</param> /// <param name="queryParams">The query params.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">options</exception> private string GetImageUrl(string baseUrl, ImageOptions options, QueryStringDictionary queryParams) { if (options == null) { throw new ArgumentNullException("options"); } if (queryParams == null) { throw new ArgumentNullException("queryParams"); } if (options.ImageIndex.HasValue) { baseUrl += "/" + options.ImageIndex.Value; } queryParams.AddIfNotNull("Width", options.Width); queryParams.AddIfNotNull("Height", options.Height); queryParams.AddIfNotNull("MaxWidth", options.MaxWidth); queryParams.AddIfNotNull("MaxHeight", options.MaxHeight); queryParams.AddIfNotNull("Quality", options.Quality ?? ImageQuality); queryParams.AddIfNotNull("Tag", options.Tag); queryParams.AddIfNotNull("CropWhitespace", options.CropWhitespace); queryParams.Add("EnableImageEnhancers", options.EnableImageEnhancers); return(GetApiUrl(baseUrl, queryParams)); }
/// <summary> /// Gets the similar item list URL. /// </summary> /// <param name="query">The query.</param> /// <param name="type">The type.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException"> /// query /// or /// type /// </exception> protected string GetSimilarItemListUrl(SimilarItemsQuery query, string type) { if (query == null) { throw new ArgumentNullException("query"); } if (string.IsNullOrEmpty(type)) { throw new ArgumentNullException("type"); } var dict = new QueryStringDictionary { }; dict.Add("Id", query.Id); dict.AddIfNotNull("Limit", query.Limit); dict.AddIfNotNullOrEmpty("UserId", query.UserId); if (type == "Movies" && Config.Instance.ExcludeRemoteContentInSearch) { dict.Add("IncludeTrailers", false); } if (query.Fields != null) { dict.Add("fields", query.Fields.Select(f => f.ToString())); } return(GetApiUrl(type + "/" + query.Id + "/Similar", dict)); }
/// <summary> /// Gets the media stream URL. /// </summary> /// <param name="handler">The handler.</param> /// <param name="options">The options.</param> /// <param name="queryParams">The query params.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">handler</exception> private string GetMediaStreamUrl(string handler, StreamOptions options, QueryStringDictionary queryParams) { if (string.IsNullOrEmpty(handler)) { throw new ArgumentNullException("handler"); } if (options == null) { throw new ArgumentNullException("options"); } if (queryParams == null) { throw new ArgumentNullException("queryParams"); } queryParams.AddIfNotNullOrEmpty("audiocodec", options.AudioCodec); queryParams.AddIfNotNull("audiochannels", options.MaxAudioChannels); queryParams.AddIfNotNull("audiosamplerate", options.MaxAudioSampleRate); queryParams.AddIfNotNull("AudioBitRate", options.AudioBitRate); queryParams.AddIfNotNull("StartTimeTicks", options.StartTimeTicks); queryParams.AddIfNotNull("Static", options.Static); return(GetApiUrl(handler, queryParams)); }
/// <summary> /// Gets the instant mix URL. /// </summary> /// <param name="query">The query.</param> /// <param name="type">The type.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException"> /// query /// or /// type /// </exception> protected string GetInstantMixUrl(SimilarItemsQuery query, string type) { if (query == null) { throw new ArgumentNullException("query"); } if (string.IsNullOrEmpty(type)) { throw new ArgumentNullException("type"); } var dict = new QueryStringDictionary { }; dict.AddIfNotNull("Limit", query.Limit); dict.AddIfNotNullOrEmpty("UserId", query.UserId); if (query.Fields != null) { dict.Add("fields", query.Fields.Select(f => f.ToString())); } if (string.IsNullOrEmpty(query.Id)) { throw new ArgumentNullException("query"); } return(GetApiUrl(type + "/" + query.Id + "/InstantMix", dict)); }
/// <summary> /// Gets the image URL. /// </summary> /// <param name="baseUrl">The base URL.</param> /// <param name="options">The options.</param> /// <param name="queryParams">The query params.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">options</exception> public string GetImageUrl(string baseUrl, ImageOptions options, QueryStringDictionary queryParams) { if (options == null) { throw new ArgumentNullException("options"); } if (queryParams == null) { throw new ArgumentNullException("queryParams"); } if (options.ImageIndex.HasValue) { baseUrl += "/" + options.ImageIndex.Value; } queryParams.AddIfNotNull("width", options.Width); queryParams.AddIfNotNull("height", options.Height); queryParams.AddIfNotNull("maxWidth", options.MaxWidth); queryParams.AddIfNotNull("maxHeight", options.MaxHeight); queryParams.AddIfNotNull("Quality", options.Quality); queryParams.AddIfNotNullOrEmpty("tag", options.Tag); return(GetApiUrl(baseUrl, queryParams)); }
/// <summary> /// Gets the next up. /// </summary> /// <param name="query">The query.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">query</exception> protected string GetNextUpUrl(NextUpQuery query) { if (query == null) { throw new ArgumentNullException("query"); } var dict = new QueryStringDictionary { }; if (query.Fields != null) { dict.Add("fields", query.Fields.Select(f => f.ToString())); } dict.Add("ParentId", query.ParentId); dict.AddIfNotNull("Limit", query.Limit); dict.AddIfNotNull("StartIndex", query.StartIndex); dict.AddIfNotNullOrEmpty("SeriesId", query.SeriesId); dict.Add("UserId", query.UserId); dict.AddIfNotNull("EnableImages", query.EnableImages); if (query.EnableImageTypes != null) { dict.Add("EnableImageTypes", query.EnableImageTypes.Select(f => f.ToString())); } dict.AddIfNotNull("ImageTypeLimit", query.ImageTypeLimit); return(GetApiUrl("Shows/NextUp", dict)); }
/// <summary> /// Creates a url to return a list of items /// </summary> /// <param name="query">The query.</param> /// <param name="listType">The type of list to retrieve.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">query</exception> protected string GetItemListUrl(ItemQuery query, string listType = null) { if (query == null) { throw new ArgumentNullException("query"); } var dict = new QueryStringDictionary { }; dict.AddIfNotNullOrEmpty("listtype", listType); dict.AddIfNotNullOrEmpty("ParentId", query.ParentId); dict.AddIfNotNull("startindex", query.StartIndex); dict.AddIfNotNull("limit", query.Limit); dict.AddIfNotNull("sortBy", query.SortBy); dict.AddIfNotNull("IsPlayed", query.IsPlayed); dict.AddIfNotNull("CollapseBoxSetItems", query.CollapseBoxSetItems); if (query.SortOrder.HasValue) { dict["sortOrder"] = query.SortOrder.ToString(); } if (query.Fields != null) { dict.Add("fields", query.Fields.Select(f => f.ToString())); } if (query.Filters != null) { dict.Add("Filters", query.Filters.Select(f => f.ToString())); } if (query.ImageTypes != null) { dict.Add("ImageTypes", query.ImageTypes.Select(f => f.ToString())); } dict.Add("recursive", query.Recursive); dict.AddIfNotNull("genres", query.Genres); dict.AddIfNotNull("Ids", query.Ids); dict.AddIfNotNull("studioIds", query.StudioIds); dict.AddIfNotNull("ExcludeItemTypes", query.ExcludeItemTypes); dict.AddIfNotNull("IncludeItemTypes", query.IncludeItemTypes); dict.AddIfNotNull("ExcludeLocationTypes", query.ExcludeLocationTypes.Select(t => t.ToString())); dict.AddIfNotNull("personIds", query.PersonIds); dict.AddIfNotNull("personTypes", query.PersonTypes); dict.AddIfNotNull("years", query.Years); dict.AddIfNotNullOrEmpty("SearchTerm", query.SearchTerm); dict.AddIfNotNullOrEmpty("MaxOfficialRating", query.MaxOfficialRating); dict.AddIfNotNullOrEmpty("MinOfficialRating", query.MinOfficialRating); return(GetApiUrl("Users/" + query.UserId + "/Items", dict)); }
/// <summary> /// Gets the item by name list URL. /// </summary> /// <param name="type">The type.</param> /// <param name="query">The query.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">query</exception> protected string GetItemByNameListUrl(string type, ItemsByNameQuery query) { if (query == null) { throw new ArgumentNullException("query"); } var dict = new QueryStringDictionary { }; dict.AddIfNotNullOrEmpty("ParentId", query.ParentId); dict.Add("UserId", query.UserId); dict.AddIfNotNull("StartIndex", query.StartIndex); dict.AddIfNotNull("Limit", query.Limit); dict.AddIfNotNullOrEmpty("NameStartsWith", query.NameStartsWith); dict.AddIfNotNullOrEmpty("NameStartsWithOrGreater", query.NameStartsWithOrGreater); dict.AddIfNotNullOrEmpty("NameLessThan", query.NameLessThan); dict.AddIfNotNull("SortBy", query.SortBy); dict.AddIfNotNull("IsPlayed", query.IsPlayed); if (query.SortOrder.HasValue) { dict["sortOrder"] = query.SortOrder.ToString(); } if (query.Fields != null) { dict.Add("fields", query.Fields.Select(f => f.ToString())); } if (query.Filters != null) { dict.Add("Filters", query.Filters.Select(f => f.ToString())); } if (query.ImageTypes != null) { dict.Add("ImageTypes", query.ImageTypes.Select(f => f.ToString())); } var personQuery = query as PersonsQuery; if (personQuery != null && personQuery.PersonTypes != null) { dict.Add("PersonTypes", personQuery.PersonTypes.Select(f => f.ToString())); } dict.Add("recursive", query.Recursive); dict.AddIfNotNull("MediaTypes", query.MediaTypes); dict.AddIfNotNull("ExcludeItemTypes", query.ExcludeItemTypes); dict.AddIfNotNull("IncludeItemTypes", query.IncludeItemTypes); return(GetApiUrl(type, dict)); }
public PinExchangeResult ExchangePin(string pin, string deviceId) { var dict = new QueryStringDictionary { { "pin", pin }, { "deviceId", deviceId } }; var url = GetApiUrl("pin/authenticate"); return(Post <PinExchangeResult>(url, dict)); }
public PinCreationResult CreatePin(string deviceId) { var dict = new QueryStringDictionary { { "deviceId", deviceId } }; var url = GetApiUrl("pin"); return(Post <PinCreationResult>(url, dict)); }
public async Task <ConnectSignupResponse> SignupForConnect(string email, string username, string password) { if (string.IsNullOrWhiteSpace(email)) { throw new ArgumentNullException("email"); } if (string.IsNullOrWhiteSpace(username)) { throw new ArgumentNullException("username"); } if (string.IsNullOrWhiteSpace(password)) { throw new ArgumentNullException("password"); } if (password.Length < 8) { throw new ArgumentException("password must be at least 8 characters"); } var request = new HttpRequest { Url = GetConnectUrl("register"), Method = "POST" }; var dict = new QueryStringDictionary(); dict.Add("email", Uri.EscapeDataString(email)); dict.Add("userName", username); dict.Add("password", password); request.SetPostData(dict); request.RequestHeaders["X-Connect-Token"] = "CONNECT-REGISTER"; AddAppInfo(request, _appName, _appVersion); using (var response = await _httpClient.GetResponse(request, true).ConfigureAwait(false)) { var responseObject = JsonSerializer.DeserializeFromStream <RawConnectResponse>(response.Content); if (string.Equals(responseObject.Status, "SUCCESS", StringComparison.OrdinalIgnoreCase)) { return(ConnectSignupResponse.Success); } if (string.Equals(responseObject.Status, "USERNAME_IN_USE", StringComparison.OrdinalIgnoreCase)) { return(ConnectSignupResponse.UsernameInUser); } if (string.Equals(responseObject.Status, "EMAIL_IN_USE", StringComparison.OrdinalIgnoreCase)) { return(ConnectSignupResponse.EmailInUse); } return(ConnectSignupResponse.Failure); } }
/// <summary> /// Gets the API URL. /// </summary> /// <param name="handler">The handler.</param> /// <param name="queryString">The query string.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">handler</exception> public string GetApiUrl(string handler, QueryStringDictionary queryString) { if (string.IsNullOrEmpty(handler)) { throw new ArgumentNullException("handler"); } if (queryString == null) { throw new ArgumentNullException("queryString"); } return(queryString.GetUrl(ApiUrl + "/" + handler)); }
/// <summary> /// Creates a url to return a list of music genres /// </summary> /// <param name="query">The query.</param> /// <param name="listType">The type of list to retrieve.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">query</exception> protected string GetMusicGenreListUrl(ItemQuery query) { if (query == null) { throw new ArgumentNullException("query"); } var dict = new QueryStringDictionary { }; dict.AddIfNotNullOrEmpty("ParentId", query.ParentId); dict.AddIfNotNull("startindex", query.StartIndex); dict.AddIfNotNull("limit", query.Limit); dict.AddIfNotNull("sortBy", query.SortBy); dict.AddIfNotNull("IsPlayed", query.IsPlayed); if (query.SortOrder.HasValue) { dict["sortOrder"] = query.SortOrder.ToString(); } if (query.Fields != null) { dict.Add("fields", query.Fields.Select(f => f.ToString())); } if (query.Filters != null) { dict.Add("Filters", query.Filters.Select(f => f.ToString())); } if (query.UserId != null) { dict.Add("UserId", query.UserId); } dict.Add("recursive", query.Recursive); dict.AddIfNotNull("ExcludeItemTypes", query.ExcludeItemTypes); dict.AddIfNotNull("IncludeItemTypes", query.IncludeItemTypes); return(GetApiUrl("MusicGenres", dict)); }
public async Task <ConnectUser> GetConnectUser(ConnectUserQuery query, string accessToken, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrWhiteSpace(accessToken)) { throw new ArgumentNullException("accessToken"); } var dict = new QueryStringDictionary(); if (!string.IsNullOrWhiteSpace(query.Id)) { dict.Add("id", query.Id); } else if (!string.IsNullOrWhiteSpace(query.NameOrEmail)) { dict.Add("nameOrEmail", query.NameOrEmail); } else if (!string.IsNullOrWhiteSpace(query.Name)) { dict.Add("name", query.Name); } else if (!string.IsNullOrWhiteSpace(query.Email)) { dict.Add("email", query.Email); } else { throw new ArgumentException("Empty ConnectUserQuery supplied"); } var url = GetConnectUrl("user") + "?" + dict.GetQueryString(); var request = new HttpRequest { Method = "GET", Url = url, CancellationToken = cancellationToken }; AddUserAccessToken(request, accessToken); AddAppInfo(request, _appName, _appVersion); using (var stream = await _httpClient.SendAsync(request).ConfigureAwait(false)) { return(JsonSerializer.DeserializeFromStream <ConnectUser>(stream)); } }
public PinCreationResult CreatePin(string deviceId) { var dict = new QueryStringDictionary { { "deviceId", deviceId } }; var url = GetApiUrl("pin"); try { return(Post <PinCreationResult>(url, dict)); } catch (Exception e) { return(new PinCreationResult() { IsConfirmed = false, Pin = "Error: Could not retrieve PIN" }); } }
/// <summary> /// Gets the image URL. /// </summary> /// <param name="baseUrl">The base URL.</param> /// <param name="options">The options.</param> /// <param name="queryParams">The query params.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">options</exception> private string GetImageUrl(string baseUrl, ImageOptions options, QueryStringDictionary queryParams) { if (options == null) { throw new ArgumentNullException("options"); } if (queryParams == null) { throw new ArgumentNullException("queryParams"); } if (options.ImageIndex.HasValue) { baseUrl += "/" + options.ImageIndex.Value; } queryParams.AddIfNotNull("Width", options.Width); queryParams.AddIfNotNull("Height", options.Height); queryParams.AddIfNotNull("MaxWidth", options.MaxWidth); queryParams.AddIfNotNull("MaxHeight", options.MaxHeight); queryParams.AddIfNotNull("Quality", options.Quality ?? ImageQuality); queryParams.AddIfNotNullOrEmpty("Tag", options.Tag); queryParams.AddIfNotNull("CropWhitespace", options.CropWhitespace); queryParams.Add("EnableImageEnhancers", options.EnableImageEnhancers); if (options.Format.HasValue) { queryParams.Add("Format", options.Format.ToString()); } if (options.AddPlayedIndicator) { queryParams.Add("AddPlayedIndicator", true); } queryParams.AddIfNotNull("PercentPlayed", options.PercentPlayed); queryParams.AddIfNotNullOrEmpty("BackgroundColor", options.BackgroundColor); return(GetApiUrl(baseUrl, queryParams)); }
/// <summary> /// Gets the video stream URL. /// </summary> /// <param name="handler">The handler.</param> /// <param name="options">The options.</param> /// <returns>System.String.</returns> private string GetVideoStreamUrl(string handler, VideoStreamOptions options) { var queryParams = new QueryStringDictionary(); queryParams.AddIfNotNullOrEmpty("VideoCodec", options.VideoCodec); queryParams.AddIfNotNull("VideoBitRate", options.VideoBitRate); queryParams.AddIfNotNull("Width", options.Width); queryParams.AddIfNotNull("Height", options.Height); queryParams.AddIfNotNull("MaxWidth", options.MaxWidth); queryParams.AddIfNotNull("MaxHeight", options.MaxHeight); queryParams.AddIfNotNull("FrameRate", options.FrameRate); queryParams.AddIfNotNull("AudioStreamIndex", options.AudioStreamIndex); queryParams.AddIfNotNull("VideoStreamIndex", options.VideoStreamIndex); queryParams.AddIfNotNull("SubtitleStreamIndex", options.SubtitleStreamIndex); queryParams.AddIfNotNullOrEmpty("Profile", options.Profile); queryParams.AddIfNotNullOrEmpty("Level", options.Level); return(GetMediaStreamUrl(handler, options, queryParams)); }
public async Task <ConnectUserServer[]> GetServers(string userId, string accessToken, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrWhiteSpace(userId)) { throw new ArgumentNullException("userId"); } if (string.IsNullOrWhiteSpace(accessToken)) { throw new ArgumentNullException("accessToken"); } var dict = new QueryStringDictionary(); dict.Add("userId", userId); var url = GetConnectUrl("servers") + "?" + dict.GetQueryString(); var request = new HttpRequest { Method = "GET", Url = url, CancellationToken = cancellationToken }; AddUserAccessToken(request, accessToken); AddAppInfo(request, _appName, _appVersion); using (var stream = await _httpClient.SendAsync(request).ConfigureAwait(false)) { using (var reader = new StreamReader(stream)) { var json = await reader.ReadToEndAsync().ConfigureAwait(false); _logger.Debug("Connect servers response: {0}", json); return(JsonSerializer.DeserializeFromString <ConnectUserServer[]>(json)); } } }
public IEnumerable <ServerInfo> GetAvailableServers(string connectId) { var dict = new QueryStringDictionary { { "userId", connectId } }; var url = GetApiUrl("servers", dict); using (var stream = GetSerializedStream(url)) { var result = DeserializeFromStream <ConnectUserServer[]>(stream); if (result != null) { return(result.Select(s => new ServerInfo { AccessToken = s.AccessKey, Id = s.SystemId, Name = s.Name, LocalAddress = s.LocalAddress, ExchangeToken = s.AccessKey, UserLinkType = s.UserType == "Linked" ? UserLinkType.LinkedUser : UserLinkType.Guest, RemoteAddress = s.Url })); } else { return(null); } } }
public async Task <PinStatusResult> GetPinStatus(PinCreationResult pin) { var dict = new QueryStringDictionary(); dict.Add("deviceId", pin.DeviceId); dict.Add("pin", pin.Pin); var url = GetConnectUrl("pin") + "?" + dict.GetQueryString(); var request = new HttpRequest { Method = "GET", Url = url }; AddAppInfo(request, _appName, _appVersion); using (var stream = await _httpClient.SendAsync(request).ConfigureAwait(false)) { return(JsonSerializer.DeserializeFromStream <PinStatusResult>(stream)); } }
/// <summary> /// Gets the item by name list URL. /// </summary> /// <param name="type">The type.</param> /// <param name="query">The query.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">query</exception> protected string GetItemByNameListUrl(string type, ItemsByNameQuery query) { if (query == null) { throw new ArgumentNullException("query"); } var dict = new QueryStringDictionary { }; dict.AddIfNotNullOrEmpty("ParentId", query.ParentId); dict.Add("UserId", query.UserId); dict.AddIfNotNull("StartIndex", query.StartIndex); dict.AddIfNotNull("Limit", query.Limit); dict.AddIfNotNull("SortBy", query.SortBy); if (query.SortOrder.HasValue) { dict["sortOrder"] = query.SortOrder.ToString(); } if (query.Fields != null) { dict.Add("fields", query.Fields.Select(f => f.ToString())); } dict.Add("recursive", query.Recursive); dict.AddIfNotNull("MediaTypes", query.MediaTypes); dict.AddIfNotNull("ExcludeItemTypes", query.ExcludeItemTypes); dict.AddIfNotNull("IncludeItemTypes", query.IncludeItemTypes); return(GetApiUrl(type, dict)); }
/// <summary> /// Creates a url to return a list of items /// </summary> /// <param name="query">The query.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">query</exception> protected string GetItemListUrl(ItemQuery query) { if (query == null) { throw new ArgumentNullException("query"); } var dict = new QueryStringDictionary { }; dict.AddIfNotNullOrEmpty("ParentId", query.ParentId); dict.AddIfNotNull("StartIndex", query.StartIndex); dict.AddIfNotNull("Limit", query.Limit); dict.AddIfNotNull("SortBy", query.SortBy); if (query.SortOrder.HasValue) { dict["sortOrder"] = query.SortOrder.ToString(); } if (query.SeriesStatuses != null) { dict.Add("SeriesStatuses", query.SeriesStatuses.Select(f => f.ToString())); } if (query.Fields != null) { dict.Add("fields", query.Fields.Select(f => f.ToString())); } if (query.Filters != null) { dict.Add("Filters", query.Filters.Select(f => f.ToString())); } if (query.ImageTypes != null) { dict.Add("ImageTypes", query.ImageTypes.Select(f => f.ToString())); } dict.AddIfNotNull("Is3D", query.Is3D); if (query.VideoTypes != null) { dict.Add("VideoTypes", query.VideoTypes.Select(f => f.ToString())); } if (query.AirDays != null) { dict.Add("AirDays", query.AirDays.Select(f => f.ToString())); } dict.AddIfNotNullOrEmpty("MinOfficialRating", query.MinOfficialRating); dict.AddIfNotNullOrEmpty("MaxOfficialRating", query.MaxOfficialRating); dict.Add("recursive", query.Recursive); dict.AddIfNotNull("MediaTypes", query.MediaTypes); dict.AddIfNotNull("Genres", query.Genres); dict.AddIfNotNull("Ids", query.Ids); dict.AddIfNotNull("Studios", query.Studios); dict.AddIfNotNull("ExcludeItemTypes", query.ExcludeItemTypes); dict.AddIfNotNull("IncludeItemTypes", query.IncludeItemTypes); dict.AddIfNotNull("Artists", query.Artists); dict.AddIfNotNullOrEmpty("MinOfficialRating", query.MinOfficialRating); dict.AddIfNotNullOrEmpty("MaxOfficialRating", query.MaxOfficialRating); dict.AddIfNotNullOrEmpty("Person", query.Person); dict.AddIfNotNull("PersonTypes", query.PersonTypes); dict.AddIfNotNull("Years", query.Years); dict.AddIfNotNullOrEmpty("IndexBy", query.IndexBy); dict.AddIfNotNullOrEmpty("SearchTerm", query.SearchTerm); return(GetApiUrl("Users/" + query.UserId + "/Items", dict)); }
/// <summary> /// Creates a url to return a list of items /// </summary> /// <param name="query">The query.</param> /// <returns>System.String.</returns> /// <exception cref="System.ArgumentNullException">query</exception> protected string GetItemListUrl(ItemQuery query) { if (query == null) { throw new ArgumentNullException("query"); } var dict = new QueryStringDictionary { }; dict.AddIfNotNullOrEmpty("ParentId", query.ParentId); dict.AddIfNotNull("StartIndex", query.StartIndex); dict.AddIfNotNull("Limit", query.Limit); dict.AddIfNotNull("SortBy", query.SortBy); if (query.SortOrder.HasValue) { dict["sortOrder"] = query.SortOrder.ToString(); } if (query.SeriesStatuses != null) { dict.Add("SeriesStatuses", query.SeriesStatuses.Select(f => f.ToString())); } if (query.Fields != null) { dict.Add("fields", query.Fields.Select(f => f.ToString())); } if (query.Filters != null) { dict.Add("Filters", query.Filters.Select(f => f.ToString())); } if (query.ImageTypes != null) { dict.Add("ImageTypes", query.ImageTypes.Select(f => f.ToString())); } dict.AddIfNotNull("Is3D", query.Is3D); if (query.VideoTypes != null) { dict.Add("VideoTypes", query.VideoTypes.Select(f => f.ToString())); } if (query.AirDays != null) { dict.Add("AirDays", query.AirDays.Select(f => f.ToString())); } dict.AddIfNotNullOrEmpty("MinOfficialRating", query.MinOfficialRating); dict.AddIfNotNullOrEmpty("MaxOfficialRating", query.MaxOfficialRating); dict.Add("recursive", query.Recursive); dict.AddIfNotNull("MinIndexNumber", query.MinIndexNumber); dict.AddIfNotNull("EnableImages", query.EnableImages); if (query.EnableImageTypes != null) { dict.Add("EnableImageTypes", query.EnableImageTypes.Select(f => f.ToString())); } dict.AddIfNotNull("ImageTypeLimit", query.ImageTypeLimit); dict.AddIfNotNull("CollapseBoxSetItems", query.CollapseBoxSetItems); dict.AddIfNotNull("MediaTypes", query.MediaTypes); dict.AddIfNotNull("Genres", query.Genres, "|"); dict.AddIfNotNull("Ids", query.Ids); dict.AddIfNotNull("StudioIds", query.StudioIds, "|"); dict.AddIfNotNull("ExcludeItemTypes", query.ExcludeItemTypes); dict.AddIfNotNull("IncludeItemTypes", query.IncludeItemTypes); dict.AddIfNotNull("ArtistIds", query.ArtistIds); dict.AddIfNotNull("IsPlayed", query.IsPlayed); dict.AddIfNotNull("IsInBoxSet", query.IsInBoxSet); dict.AddIfNotNull("PersonIds", query.PersonIds); dict.AddIfNotNull("PersonTypes", query.PersonTypes); dict.AddIfNotNull("Years", query.Years); dict.AddIfNotNull("ParentIndexNumber", query.ParentIndexNumber); dict.AddIfNotNull("IsHD", query.IsHD); dict.AddIfNotNull("HasParentalRating", query.HasParentalRating); dict.AddIfNotNullOrEmpty("SearchTerm", query.SearchTerm); dict.AddIfNotNull("MinCriticRating", query.MinCriticRating); dict.AddIfNotNull("MinCommunityRating", query.MinCommunityRating); dict.AddIfNotNull("MinPlayers", query.MinPlayers); dict.AddIfNotNull("MaxPlayers", query.MaxPlayers); dict.AddIfNotNullOrEmpty("NameStartsWithOrGreater", query.NameStartsWithOrGreater); dict.AddIfNotNullOrEmpty("AlbumArtistStartsWithOrGreater", query.AlbumArtistStartsWithOrGreater); if (query.LocationTypes != null && query.LocationTypes.Length > 0) { dict.Add("LocationTypes", query.LocationTypes.Select(f => f.ToString())); } if (query.ExcludeLocationTypes != null && query.ExcludeLocationTypes.Length > 0) { dict.Add("ExcludeLocationTypes", query.ExcludeLocationTypes.Select(f => f.ToString())); } dict.AddIfNotNull("IsMissing", query.IsMissing); dict.AddIfNotNull("IsUnaired", query.IsUnaired); dict.AddIfNotNull("IsVirtualUnaired", query.IsVirtualUnaired); dict.AddIfNotNull("AiredDuringSeason", query.AiredDuringSeason); return(GetApiUrl("Users/" + query.UserId + "/Items", dict)); }