Last active
April 29, 2019 15:03
-
-
Save wrouesnel/9fb8a5d5ca15a2ecb40637ff6db2a854 to your computer and use it in GitHub Desktop.
Prototype code to mirror the VSCode extension repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Script to mirror the VSCode extensions repository | |
# Sample download URL of a package: | |
# https://marketplace.visualstudio.com/_apis/public/gallery/publishers/rebornix/vsextensions/Ruby/0.22.3/vspackage | |
# transliterated: https://marketplace.visualstudio.com/_apis/public/gallery/publishers/{publisherName}/vsextensions/{name}/{version}/vspackage | |
from pprint import pprint | |
import requests | |
from collections import defaultdict | |
s = requests.Session() | |
def extqry(pageNumber): | |
return { | |
"assetTypes": [], | |
"filters": [ | |
{ | |
"criteria": [ | |
{ | |
"filterType": 8, | |
"value": "Microsoft.VisualStudio.Code" | |
}, | |
{ | |
"filterType": 10, | |
"value": "target:\"Microsoft.VisualStudio.Code\" " | |
}, | |
{ | |
"filterType": 12, | |
"value": "37888" | |
} | |
], | |
"direction": 2, | |
"pageSize": 54, | |
"pageNumber": pageNumber, | |
"sortBy": 10, | |
"sortOrder": 0, | |
"pagingToken": None | |
} | |
], | |
"flags": 870 | |
} | |
pageNumber = 1 | |
params = { | |
"api-version" : "5.1-preview.1" | |
} | |
r = s.post("https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery", params=params, json=extqry(pageNumber)) | |
extensions = defaultdict(list) | |
while "results" in r.json(): | |
for i in r.json()["results"][0]["extensions"]: | |
for version in i["versions"]: | |
extensions[(i["publisher"]["publisherName"],i["extensionName"])].append(version["version"]) | |
pageNumber += 1 | |
r = s.post("https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery", params=params, json=extqry(pageNumber)) | |
pprint(r.json()) | |
print("Got {} extensions".format(len(extensions))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment