Revert pycurl and add Accept-Encoding to build script

This commit is contained in:
Xpl0itU 2024-04-03 18:17:27 +02:00
parent d5efd04b77
commit 8e49371c84
4 changed files with 14 additions and 18 deletions

View file

@ -1,7 +1,8 @@
#!/bin/env python
import os
import pycurl
import urllib.request
import ssl
# Don't edit below this line
@ -10,16 +11,14 @@ def checkAndDeleteFile(file):
print(f"Deleting {file}")
os.remove(file)
def cDownload(url, file):
with open(file, 'wb') as f:
c = pycurl.Curl()
c.setopt(c.URL, url)
c.setopt(c.WRITEDATA, f)
c.setopt(c.FOLLOWLOCATION, True)
c.setopt(c.USERAGENT, "NUSspliBuilder/2.2")
c.setopt(c.ACCEPT_ENCODING, "")
c.perform()
c.close()
# Disable certificate verification
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
opener = urllib.request.build_opener(urllib.request.HTTPSHandler(context=ssl_context))
opener.addheaders = [("User-agent", "NUSspliBuilder/2.2"), ("Accept-Encoding", "gzip, deflate, br")]
urllib.request.install_opener(opener)
checkAndDeleteFile("db.go")
cDownload("https://napi.v10lator.de/db?t=go", "db.go")
urllib.request.urlretrieve("https://napi.v10lator.de/db?t=go", "db.go")