Skip to content

Commit

Permalink
Account for Twitch now returning 403 when trying to access sub-only V…
Browse files Browse the repository at this point in the history
…ODs without authorization
  • Loading branch information
ScrubN committed Jan 19, 2024
1 parent 3a4f386 commit f3cab4a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions TwitchDownloaderCore/TwitchHelper.cs
Expand Up @@ -84,6 +84,19 @@ public static async Task<string> GetVideoPlaylist(int videoId, string token, str
throw;
}
}

if (response.StatusCode == HttpStatusCode.Forbidden)
{
// Twitch returns 403 Forbidden for (some? all?) sub-only VODs when correct authorization is not provided
var forbiddenResponse = await response.Content.ReadAsStringAsync();
if (forbiddenResponse.Contains("vod_manifest_restricted") || forbiddenResponse.Contains("unauthorized_entitlements"))
{
// Return the error string so the caller can choose their error strategy
// TODO: We may want to eventually return all 403 responses so the error messages can be parsed and/or logged since more potential errors exist
return forbiddenResponse;
}
}

response.EnsureSuccessStatusCode();

return await response.Content.ReadAsStringAsync();
Expand Down

0 comments on commit f3cab4a

Please sign in to comment.