From 9dcadb12bde93462277bc35348dcb199563ea4cf Mon Sep 17 00:00:00 2001 From: Xpl0itU <24777100+Xpl0itU@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:30:17 +0200 Subject: [PATCH] Use pycurl to fetch the title database --- .github/workflows/macos.yml | 6 +++++- .github/workflows/windows.yml | 2 +- Dockerfile.linux | 2 +- grabTitles.py | 23 ++++++++++++----------- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 00bf4f3..bfca484 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -17,7 +17,11 @@ jobs: submodules: 'recursive' - name: Install Dependencies run: | - brew install create-dmg dylibbundler gtk+3 + brew uninstall curl + brew uninstall openssl + brew uninstall curl-openssl + brew install create-dmg dylibbundler gtk+3 openssl curl + python3 -m pip install --compile --ignore-installed pycurl - name: Build run: | python3 grabTitles.py diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1d1e78b..89912b2 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -25,7 +25,7 @@ jobs: msystem: UCRT64 release: true update: true - install: zip git mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-python mingw-w64-ucrt-x86_64-gtk3 mingw-w64-ucrt-x86_64-pkg-config mingw-w64-ucrt-x86_64-go mingw-w64-ucrt-x86_64-ntldd-git + install: zip git mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-python mingw-w64-ucrt-x86_64-python-pycurl mingw-w64-ucrt-x86_64-gtk3 mingw-w64-ucrt-x86_64-pkg-config mingw-w64-ucrt-x86_64-go mingw-w64-ucrt-x86_64-ntldd-git - name: Build run: | python3 grabTitles.py diff --git a/Dockerfile.linux b/Dockerfile.linux index 9b45ab1..f83907b 100644 --- a/Dockerfile.linux +++ b/Dockerfile.linux @@ -13,7 +13,7 @@ RUN mkdir -p /usr/share/man/man1 /usr/share/man/man2 && \ RUN apt-fast -y --no-install-recommends update && \ apt-fast -y --no-install-recommends upgrade && \ - apt-fast install -y --no-install-recommends build-essential libgcrypt20-dev libgtk-3-dev libfuse2 libtool librsvg2-dev && \ + apt-fast install -y --no-install-recommends build-essential libgcrypt20-dev libgtk-3-dev libfuse2 libtool librsvg2-dev python3-pycurl && \ wget https://go.dev/dl/go1.22.1.linux-amd64.tar.gz && \ tar -C /usr/local -xzf go*.linux-amd64.tar.gz && \ chmod +x /usr/local/go/bin/go* && \ diff --git a/grabTitles.py b/grabTitles.py index 295896e..ca688e0 100644 --- a/grabTitles.py +++ b/grabTitles.py @@ -1,8 +1,7 @@ #!/bin/env python import os -import urllib.request -import ssl +import pycurl # Don't edit below this line @@ -11,14 +10,16 @@ def checkAndDeleteFile(file): print(f"Deleting {file}") os.remove(file) -# 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.1")] -urllib.request.install_opener(opener) +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() checkAndDeleteFile("db.go") -urllib.request.urlretrieve("https://napi.v10lator.de/db?t=go", "db.go") +cDownload("https://napi.v10lator.de/db?t=go", "db.go")