-
-
Save jneuendorf-i4h/d43e867f8a4895c76c10d8e1f7fe740e to your computer and use it in GitHub Desktop.
"""Based on https://stackoverflow.com/a/38866913/23325241""" | |
import re | |
# Attempt to import requests and handle if it's missing | |
try: | |
import requests | |
requests_available = True | |
except ImportError: | |
requests_available = False | |
def create_download_url(): | |
# Ask the user for the Marketplace URL | |
marketplace_url = input("Enter the VSCode Marketplace URL: ").strip() | |
version = input("Enter the version (leave empty for 'latest'): ").strip() or "latest" | |
# Extract publisher and extension name using regex | |
match = re.search(r"itemName=([^.]+)\.(.+)", marketplace_url) | |
if not match: | |
print("Invalid VSCode Marketplace URL format.") | |
return | |
publisher, extension_name = match.groups() | |
# Generate the download URL | |
download_url = ( | |
f"https://{publisher}.gallery.vsassets.io/_apis/public/gallery/publisher/" | |
f"{publisher}/extension/{extension_name}/{version}/" | |
"assetbyname/Microsoft.VisualStudio.Services.VSIXPackage" | |
) | |
print("\nDownload URL:") | |
print(download_url) | |
if not requests_available: | |
print("The 'requests' library is not installed. Skipping download functionality.") | |
return | |
# Ask the user if they want to download the file | |
download = input("Do you want to download the VSIX file? (yes/no): ").strip().lower() | |
if download == 'yes': | |
response = requests.get(download_url, stream=True) | |
if response.status_code == 200: | |
file_name = f"{extension_name}.vsix" | |
with open(file_name, "wb") as file: | |
for chunk in response.iter_content(chunk_size=8192): | |
file.write(chunk) | |
print(f"File downloaded successfully as '{file_name}'") | |
else: | |
print(f"Failed to download the file. HTTP Status Code: {response.status_code}") | |
else: | |
print("Download skipped.") | |
if __name__ == "__main__": | |
create_download_url() |
Didn't work with https://marketplace.visualstudio.com/items?itemName=GitHub.copilot. It generated https://GitHub.gallery.vsassets.io/_apis/public/gallery/publisher/GitHub/extension/copilot/latest/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage but the actual vsix can be found at https://marketplace.visualstudio.com/_apis/public/gallery/publishers/GitHub/vsextensions/copilot/1.257.1320/vspackage.
Didn't work with https://marketplace.visualstudio.com/items?itemName=GitHub.copilot. It generated https://GitHub.gallery.vsassets.io/_apis/public/gallery/publisher/GitHub/extension/copilot/latest/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage but the actual vsix can be found at https://marketplace.visualstudio.com/_apis/public/gallery/publishers/GitHub/vsextensions/copilot/1.257.1320/vspackage.
indeed, also the marketplace page do not have history tab so that might explains . how did you get the working link ? GitHub.copilot
became GitHub/vsextensions/copilot
?
Thanks for the feedback. I added the StackOverflow answer, I based the URL template on. The answer is very old so it might be outdated, but I couldn't find another one.
I checked if your suggested URL works for other packages, but GitHub Copilot was the only one that worked (from what I tried). If you find another URL template that works for all/most packages, let me know. In case, GitHub Copilot is one of very few exceptions, I could simply add the URL right on top ^^
thx. thoses ******** . grrrrrrrr .