Skip to content

Commit

Permalink
修复播放直播时的 Format 问题 (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richasy authored Jan 5, 2024
1 parent 6721f45 commit ef3ce93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/Libs/Libs.Provider/HttpProvider/HttpProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static async Task<HttpRequestMessage> GetRequestMessageAsync(
{
HttpRequestMessage requestMessage;

if (method == HttpMethod.Get && needCookie)
if (method == HttpMethod.Get && (needCookie || needAppKey))
{
if (needAppKey)
{
Expand All @@ -66,7 +66,10 @@ public static async Task<HttpRequestMessage> GetRequestMessageAsync(

requestMessage = new HttpRequestMessage(method, url);
var cookie = AuthorizeProvider.GetCookieString();
requestMessage.Headers.Add("Cookie", cookie);
if (!string.IsNullOrEmpty(cookie))
{
requestMessage.Headers.Add("Cookie", cookie);
}
}
else if (method == HttpMethod.Get || method == HttpMethod.Delete)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Libs/Libs.Provider/LiveProvider/LiveProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public static async Task<LiveMediaInformation> GetLiveMediaInformationAsync(stri
{ Query.NoPlayUrl, "0" },
{ Query.Qn, quality.ToString() },
{ Query.Codec, Uri.EscapeDataString("0,1") },
{ Query.Device, "pad" },
{ Query.DeviceName, Uri.EscapeDataString("iPad Pro") },
{ Query.Device, "phone" },
{ Query.DeviceName, Uri.EscapeDataString("iphone 14 pro max") },
{ Query.Dolby, "1" },
{ Query.Format, Uri.EscapeDataString("0,1,2") },
{ Query.Http, "1" },
Expand All @@ -76,7 +76,7 @@ public static async Task<LiveMediaInformation> GetLiveMediaInformationAsync(stri
{ Query.PlayType, "0" },
};

var request = await HttpProvider.GetRequestMessageAsync(HttpMethod.Get, Live.WebPlayInformation, queryParameter, RequestClientType.Web, needCookie: true, needAppKey: true);
var request = await HttpProvider.GetRequestMessageAsync(HttpMethod.Get, Live.WebPlayInformation, queryParameter, RequestClientType.Web, needAppKey: true);
var response = await HttpProvider.Instance.SendAsync(request);
var result = await HttpProvider.ParseAsync<ServerResponse<LiveAppPlayInformation>>(response);
return LiveAdapter.ConvertToLiveMediaInformation(result.Data);
Expand Down

0 comments on commit ef3ce93

Please sign in to comment.