Skip to content

Commit

Permalink
Fix issues with invalid package ids, add info about other endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeFZ committed Jun 14, 2022
1 parent c4e2c84 commit 785b22c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
6 changes: 6 additions & 0 deletions MsixvcPackageDownloader/OtherEndpoints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

These are all of the endpoints I found relating to MSIXVC link generation:

- https://packagespc.xboxlive.com/GetBasePackage/<ContentId> | Get all available information about a given package (Latest base package, .phf files, multiple .xsp files)
- https://packagespc.xboxlive.com/GetSpecificBasePackage/<ContentId>/<UpdateId> | Get all available information about a given package and its update id. (Note: Does not return information about previous updates, at least from my testing.)
- https://updatespc.xboxlive.com/IsContentUpdateAvailable | POST: `{"ContentId": "<ContentId>", "UpdateId", "<UpdateId>", "UpdateMode": <UpdateMode enum int>}` | Returns information about available updates and their packages.
33 changes: 21 additions & 12 deletions MsixvcPackageDownloader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,21 @@ static async Task Main(string[] args)
if (!_updateToken.Valid)
{
if (!authService.UserToken.Valid || !authService.DeviceToken.Valid)
if (await authService.AuthenticateAsync())
await GetUpdateXSTSToken(authService.UserToken, authService.DeviceToken);
else
{
if (!await authService.AuthenticateAsync())
{
Console.WriteLine("Could not regenerate update token. Please restart the app and reauthenticate!");
return;
}
}

await GetUpdateXSTSToken(authService.UserToken, authService.DeviceToken);
}

var contentUuid = Guid.TryParse(contentId, out var contentGuid);
if (!contentUuid)
var isValidId = Guid.TryParse(contentId, out var contentGuid);
if (!isValidId)
{
Console.WriteLine("Error: You entered an invalid content id.");
continue;
}
else
{
Expand All @@ -90,21 +91,29 @@ static async Task Main(string[] args)

var updateResult = await updateHttpClient.SendAsync(updateRequest);
if (!updateResult.IsSuccessStatusCode)
Console.WriteLine(
$"Failed to fetch package information. Status Code: {updateResult.StatusCode}");
Console.WriteLine($"Failed to fetch package information. Status Code: {updateResult.StatusCode}");
else
{
try
{
var updateData = await updateResult.Content.ReadAsJsonAsync<GetBasePackageResponse>();
Console.WriteLine("Got response!");
foreach (var file in updateData.PackageFiles.Where(pred => !pred.FileName.EndsWith(".phf") && !pred.FileName.EndsWith(".xsp"))) // PC files have the .msixvc extension, Xbox files don't have any
Console.WriteLine(
$"{file.FileName} | Size: {file.FileSize} | Link: {file.CdnRootPaths[0] + file.RelativeUrl}");

if (updateData.PackageFound)
{
foreach (var file in updateData.PackageFiles.Where(pred => // PC files have the .msixvc extension, Xbox files don't have any
!pred.FileName.EndsWith(".phf") &&
!pred.FileName.EndsWith(".xsp")))
Console.WriteLine($"{file.FileName} | Size: {file.FileSize} | Link: {file.CdnRootPaths[0] + file.RelativeUrl}");
}
else
{
Console.WriteLine("Error: Server did not find requested package.");
}
}
catch (Exception e)
{
Console.WriteLine("Error while parsing server response.");
Console.WriteLine($"Error while parsing server response. {e}");
}
}
}
Expand Down

0 comments on commit 785b22c

Please sign in to comment.