当前位置: 首页>>代码示例>>C#>>正文


C# SessionEventArgs.SetResponseBodyString方法代码示例

本文整理汇总了C#中SessionEventArgs.SetResponseBodyString方法的典型用法代码示例。如果您正苦于以下问题:C# SessionEventArgs.SetResponseBodyString方法的具体用法?C# SessionEventArgs.SetResponseBodyString怎么用?C# SessionEventArgs.SetResponseBodyString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SessionEventArgs的用法示例。


在下文中一共展示了SessionEventArgs.SetResponseBodyString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnResponse

 // When we receive the result, we need to check if it needs to be modified.
 private static void OnResponse(object sender, SessionEventArgs e)
 {
     if (e.ResponseStatusCode == HttpStatusCode.OK)
     {
         // Most APIs are returned in text/plain but serach songs page is returned in JSON. Don't forget this!
         if (e.ResponseContentType.Trim().ToLower().Contains("text/plain") ||
             e.ResponseContentType.Trim().ToLower().Contains("application/json"))
         {
             if (Configuration.Verbose)
             {
                 Console.WriteLine($"Accessing URL {e.RequestUrl}");
             }
             // It should include album / playlist / artist / search pages.
             if (e.RequestUrl.Contains("/eapi/v3/song/detail/") || e.RequestUrl.Contains("/eapi/v1/album/") || e.RequestUrl.Contains("/eapi/v3/playlist/detail") ||
                 e.RequestUrl.Contains("/eapi/batch") || e.RequestUrl.Contains("/eapi/cloudsearch/pc") || e.RequestUrl.Contains("/eapi/v1/artist"))
             {
                 string modified = ModifyDetailApi(e.GetResponseBodyAsString());
                 e.SetResponseBodyString(modified);
             }
             // This is called when player tries to get the URL for a song.
             else if (e.RequestUrl.Contains("/eapi/song/enhance/player/url"))
             {
                 if (string.IsNullOrEmpty(Configuration.ForcePlaybackBitrate))
                 {
                     SetPlaybackMusicQuality(e.GetResponseBodyAsString());
                 }
                 else
                 {
                     Console.WriteLine($"Plackback bitrate is forced set to {Configuration.ForcePlaybackBitrate}");
                     Configuration.PlaybackBitrate = Configuration.ForcePlaybackBitrate;
                     Configuration.PlaybackQuality = ParseBitrate(Configuration.ForcePlaybackBitrate);
                 }
                 string modified = ModifyPlayerApi(e.GetResponseBodyAsString());
                 e.SetResponseBodyString(modified);
             }
             // When we try to download a song, the API tells whether it exceeds the limit. Of course no!
             else if (e.RequestUrl.Contains("/eapi/song/download/limit"))
             {
                 string modified = ModifyDownloadLimitApi();
                 e.SetResponseBodyString(modified);
             }
             // Similar to the player URL API, but used for download.
             else if (e.RequestUrl.Contains("/eapi/song/enhance/download/url"))
             {
                 string modified = e.GetResponseBodyAsString();
                 if (string.IsNullOrEmpty(Configuration.ForceDownloadBitrate))
                 {
                     SetDownloadMusicQuality(modified);
                 }
                 else
                 {
                     Console.WriteLine($"Download bitrate is forced set to {Configuration.ForceDownloadBitrate}");
                     Configuration.DownloadBitrate = Configuration.ForceDownloadBitrate;
                     Configuration.DownloadQuality = ParseBitrate(Configuration.ForceDownloadBitrate);
                 }
                 modified = ModifyDownloadApi(modified);
                 e.SetResponseBodyString(modified);
             }
         }
     }
 }
开发者ID:wzymmy,项目名称:Unblock163MusicClient,代码行数:62,代码来源:Program.cs


注:本文中的SessionEventArgs.SetResponseBodyString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。