MS-Store-API icon indicating copy to clipboard operation
MS-Store-API copied to clipboard

Generate direct downloadable link

Open Howard20181 opened this issue 2 years ago • 20 comments

Any way to get package download links from the catalogId?

Howard20181 avatar Jul 20 '22 13:07 Howard20181

Curious about how store.rg-adguard.net works.

Howard20181 avatar Jul 20 '22 13:07 Howard20181

Not sure, but maybe this may slightly help? What I was able to find about project it is able to find and download Windows ISOs from MS download sides. But as I'm not much good in reading batch scripts I'm not sure if it may help or mot. At least there was, in several batch or php files, some POST queries to MS sites to return ISO download link. Maybe someone who has more time and knowledge than me can bring some light to it? https://github.com/hitdn110/docs/tree/3bcdfdeac30aabec6049997d5de90e15ea8a6d45/windows/uupdl-master

Caesar008 avatar Jul 29 '22 10:07 Caesar008

Would like to have this too!

CE1CECL avatar Aug 10 '22 18:08 CE1CECL

Curious about how store.rg-adguard.net works.

Looks it rely on WuCategoryID returned by https://storeedgefd.dsx.mp.microsoft.com/v9.0/pages/searchResults

Example result (only related line) from query to search for DisneyPlus

"FulfillmentData": "{"ProductId":"9NXQXXLFST89","WuBundleId":"7f0fccd4-7e32-4973-9158-69f0072bd051","WuCategoryId":"22e0ce7f-427a-40fa-bfa6-0de7b8554840","PackageFamilyName":"Disney.37853FC22B2CE_6rarf9sa4v8jt","SkuId":"0010","Content":null,"PackageFeatures":null}",

When result does not return WuCategoryID, for example GIMP, it is not able to find any download link. Unfortunately I did not find way how to get links by WuCategoryID yet.

Caesar008 avatar Aug 31 '22 08:08 Caesar008

https://github.com/LSPosed/MagiskOnWSALocal/blob/main/scripts/generateWSALinks.py

Howard20181 avatar Aug 31 '22 08:08 Howard20181

Found something @Caesar008 @Howard20181 https://github.com/StoreDev/StoreLib

CE1CECL avatar Aug 31 '22 17:08 CE1CECL

Found something @Caesar008 @Howard20181 https://github.com/StoreDev/StoreLib

Great, this looks very promising and looks as what we are looking for. I can see it uses same xml files as in https://github.com/LSPosed/MagiskOnWSALocal/blob/main/scripts/generateWSALinks.py found by Howard and does practically same things, but looks more robust/complex. It also does similar queries to URIs I was testing yesterday based on that .py script. It uses APIs v7, so maybe it is bit older, as it looks v9 is available. Once I will have more free time (people at work/customers gets crazy after summer vacations) I will play with this and will check if it is capable to also find/generate links for apps without category ID in our results and which store.rg-adguard is not able to find (e.g. GIMP - XPDM27W10192Q0) and how it handles msix/msixbundle extension.

Caesar008 avatar Sep 01 '22 05:09 Caesar008

Looks StoreLib has problems with some apps as GIMP as well. It also does not return file extension, or I did not find where it is stored.

Caesar008 avatar Sep 01 '22 12:09 Caesar008

So for apps with WUCategoryID it works in this way (example on Speedtest by Ookla):

First get JSON from MS using GET on link https://storeedgefd.dsx.mp.microsoft.com/v9.0/products/9NBLGGH4Z1JC?market=US&locale=en-us&deviceFamily=Windows.Desktop

between "products/" and "?market" is application ID - you can get it from link to MS store app (by search with google for example if no MS store app is available to get link to app)

Next step is to obtain encrypted data from MS which are required in following step. It is done by sending POST with XML file as this: https://github.com/LSPosed/MagiskOnWSALocal/blob/main/xml/GetCookie.xml and POST is sent to https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx You will receive XML where you search for node "EncryptedData". its content is used in next step.

Another POST is sent to https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx it contains new XML which is created from https://github.com/LSPosed/MagiskOnWSALocal/blob/main/xml/WUIDRequest.xml In this XML you need to fill content of EncryptedData node from previous request into node "EncryptedData". Then you need to fill WUCategoryID, you obtained in first step, to node FilterAppCategoryIds/CategoryIdentifier/Id And requred ring in "DeviceAttributes" tag, data "BranchReadinessLevel=CB;CurrentBranch=rs_prerelease;OEMModel=Virtual Machine;FlightRing={ring here without bracets}; ...". Accepts "retail", "RP", "WIS" and "WIF".

You will receive another XML where is list of appx/appxbundle/msix/msixbundle files. You will need data from "FileName" attribute inside "File" node to know what file extension it has (appx/appxbundle/msix/msixbundle). Then you need to get "RevisonNumber" and "UpdateId" attributes from "UpdateIdentity" node. Also search for "SecuredFragment" node near "UpdateIdentity" node - it indicates that URL for file is available.

And final step which requires another XML file in POST data to https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured: https://github.com/LSPosed/MagiskOnWSALocal/blob/main/xml/FE3FileUrl.xml In this file you need to fill data in "RevisionNumber" and "UpdateID" nodes and again select correct ring in "DeviceAttributes" tag, dataBranchReadinessLevel=CB;CurrentBranch=rs_prerelease;OEMModel=Virtual Machine;FlightRing={ring here without bracets}; ...". Accepts "retail", "RP", "WIS" and "WIF".

After all of this you finally receive XML response with generated download link which is inside "Url" tag.

But it works only for apps which in first step return JSON where WUCategoryID is specified. Still do not know how to get link for apps without WUCategoryID, for example GIMP, AppID XPDM27W10192Q0

Caesar008 avatar Sep 02 '22 08:09 Caesar008

@Caesar008 You can use https://storeedgefd.dsx.mp.microsoft.com/v9.0/packageManifests/XPDM27W10192Q0?Market=US to get the installer for the app start with x which is not appx/msix package

youxiaohou avatar Sep 05 '22 05:09 youxiaohou

@Caesar008 You can use https://storeedgefd.dsx.mp.microsoft.com/v9.0/packageManifests/XPDM27W10192Q0?Market=US to get the installer for the app start with x which is not appx/msix package

Thanks, I didn't noticed URL there when searching for this kind of apps when testing endpoints in this repo. Get to https://storeedgefd.dsx.mp.microsoft.com/v9.0/packageManifests/XPDM27W10192Q0 will receive JSON, search for "InstallerUrl"

Caesar008 avatar Sep 05 '22 07:09 Caesar008

Would this also work with xbox games? As the app id starts with a 9 instead of an X but doesn't seem to return anything?

FranzFischer78 avatar Feb 08 '23 17:02 FranzFischer78

Would this also work with xbox games? As the app id starts with a 9 instead of an X but doesn't seem to return anything?

https://github.com/skydevil88/XboxDownload ??

CE1CECL avatar Feb 25 '23 02:02 CE1CECL

@CE1CECL Very suspicious to me https://github.com/skydevil88/XboxDownload/blob/master/XboxDownload/ClassMbr.cs ???

What does this class have to do with msstore stuff?

FranzFischer78 avatar Mar 05 '23 10:03 FranzFischer78

@CE1CECL Very suspicious to me https://github.com/skydevil88/XboxDownload/blob/master/XboxDownload/ClassMbr.cs ???

What does this class have to do with msstore stuff?

Probably nothing. It looks it reads and overwrites master boot record (file read/write offset 0, length 512) through kernel libraries.

Caesar008 avatar Mar 05 '23 11:03 Caesar008

@CE1CECL Very suspicious to me https://github.com/skydevil88/XboxDownload/blob/master/XboxDownload/ClassMbr.cs ??? What does this class have to do with msstore stuff?

Probably nothing. It looks it reads and overwrites master boot record (file read/write offset 0, length 512) through kernel libraries.

There is also this website: https://xbox.skydevil.xyz/

CE1CECL avatar Mar 05 '23 15:03 CE1CECL

https://github.com/ThomasPe/MS-Store-API/issues/9#issue-1311148931

https://github.com/microsoft/winget-cli/issues/578#event-13383463152 might be noteworthy - I assume that there is now a publicly documented API for downloading specific .AppX and .MSIX packages from msstore, although not specific versions of them.

RokeJulianLockhart avatar Jul 03 '24 18:07 RokeJulianLockhart