/// <summary> /// Creates the get recommended channels URI. /// </summary> /// <param name="connection">The server connection.</param> /// <returns></returns> public static Uri CreateGetRecommendedChannelsUri(this IServerConnection connection) { var uriBuilder = new UriBuilder("https://api.douban.com/v2/fm/app_channels"); uriBuilder.AppendUsageCommonFields(connection); // ReSharper disable once StringLiteralTypo uriBuilder.AppendQuery(StringTable.IconCategory, "xlarge"); return uriBuilder.Uri; }
/// <summary> /// Creates the get play list URI. /// </summary> /// <param name="connection">The server connection.</param> /// <param name="channelId">The channel ID.</param> /// <param name="type">The report type.</param> /// <param name="sid">The SID of current song.</param> /// <param name="start">The start song code.</param> /// <param name="formats">The format of music file.</param> /// <param name="kbps">The bit rate of music file.</param> /// <param name="playedTime">The played time of current song.</param> /// <param name="mode">The mode.</param> /// <param name="excludedSids">The excluded SIDs.</param> /// <param name="max">The maximum size of returned play list.</param> /// <returns></returns> public static Uri CreateGetPlayListUri(this IServerConnection connection, int channelId, ReportType type, string sid, string start, string formats, int? kbps, double? playedTime, string mode, IEnumerable<string> excludedSids, int? max) { var uriBuilder = new UriBuilder("https://api.douban.com/v2/fm/playlist"); uriBuilder.AppendUsageCommonFields(connection); uriBuilder.AppendQuery(StringTable.Channel, channelId.ToString(CultureInfo.InvariantCulture)); uriBuilder.AppendQuery(StringTable.Type, ReportTypeString.GetString(type)); uriBuilder.AppendQuery(StringTable.Sid, sid); uriBuilder.AppendQuery(StringTable.Start, start); // If start song code is not empty, then the first song returned will always be the same one. uriBuilder.AppendQuery(StringTable.Formats, formats); uriBuilder.AppendQuery(StringTable.Kbps, kbps?.ToString(CultureInfo.InvariantCulture)); uriBuilder.AppendQuery(StringTable.PlayedTime, playedTime?.ToString("F1", CultureInfo.InvariantCulture)); uriBuilder.AppendQuery(StringTable.Mode, mode); uriBuilder.AppendQuery(StringTable.Exclude, excludedSids == null ? null : String.Join(",", excludedSids)); uriBuilder.AppendQuery(StringTable.Max, max?.ToString(CultureInfo.InvariantCulture)); return uriBuilder.Uri; }
/// <summary> /// Creates the get channel info URI. /// </summary> /// <param name="connection">The server connection.</param> /// <param name="channelId">The channel ID.</param> /// <returns></returns> public static Uri CreateGetChannelInfoUri(this IServerConnection connection, int channelId) { var uriBuilder = new UriBuilder("https://api.douban.com/v2/fm/channel_info"); uriBuilder.AppendUsageCommonFields(connection); uriBuilder.AppendQuery(StringTable.Id, channelId.ToString(CultureInfo.InvariantCulture)); return uriBuilder.Uri; }
/// <summary> /// Creates the get song URL URI. /// </summary> /// <param name="connection">The server connection.</param> /// <param name="sid">The SID of the song.</param> /// <param name="ssid">The SSID of the song.</param> /// <returns></returns> public static Uri CreateGetSongUrlUri(this IServerConnection connection, string sid, string ssid) { var uriBuilder = new UriBuilder("https://api.douban.com/v2/fm/song_url"); uriBuilder.AppendUsageCommonFields(connection); uriBuilder.AppendQuery(StringTable.Sid, sid); uriBuilder.AppendQuery(StringTable.Ssid, ssid); return uriBuilder.Uri; }
/// <summary> /// Creates the search channel URI. /// </summary> /// <param name="connection">The server connection.</param> /// <param name="query">The query.</param> /// <param name="start">The preferred index of the first channel in the returned channel array.</param> /// <param name="size">The max size of returned channel array.</param> /// <returns></returns> public static Uri CreateSearchChannelUri(this IServerConnection connection, string query, int start, int size) { var uriBuilder = new UriBuilder("https://api.douban.com/v2/fm/search/channel"); uriBuilder.AppendUsageCommonFields(connection); uriBuilder.AppendQuery(StringTable.Query, query); uriBuilder.AppendQuery(StringTable.Start, start.ToString(CultureInfo.InvariantCulture)); uriBuilder.AppendQuery(StringTable.Limit, size.ToString(CultureInfo.InvariantCulture)); return uriBuilder.Uri; }