/// <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> /// 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 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 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(); } dict.AddIfNotNull("IsPlayed", query.IsPlayed); 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("MediaTypes", query.MediaTypes); dict.AddIfNotNull("ExcludeItemTypes", query.ExcludeItemTypes); dict.AddIfNotNull("IncludeItemTypes", query.IncludeItemTypes); dict.AddIfNotNullOrEmpty("NameLessThan", query.NameLessThan); dict.AddIfNotNullOrEmpty("NameStartsWithOrGreater", query.NameStartsWithOrGreater); 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(type, dict)); }
/// <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 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> 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 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)); }
/// <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)); }
/// <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> /// 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.CollapseBoxSetItems.HasValue && query.CollapseBoxSetItems == true) { dict["GroupItemsIntoCollections"] = "true"; } 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("genreIds", 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("artistIds", query.ArtistIds); 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> /// 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)); }
/// <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)); }