From 3952706ae59d39773f175434204fa3c4b5f9f7e4 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 29 Apr 2021 21:03:02 +1000 Subject: [PATCH] ci: create patreon list --- .github/workflows/ci.yml | 24 ++++++++++++++++++++++++ app/dialog/about/patreon.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 app/dialog/about/patreon.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cafc07df8..95bb9ee90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,14 @@ jobs: - name: Checkout Source Code uses: actions/checkout@v2 + - name: Generate Patreon List + env: + PATREON_KEY: ${{ secrets.PATREON_KEY }} + run: | + cd $GITHUB_WORKSPACE/app/dialog/about + python3 patreon.py + if: github.event_name == 'push' + - name: Configure CMake run: | mkdir build @@ -179,6 +187,14 @@ jobs: $DOWNLOAD_TOOL https://github.com/olive-editor/dependencies/releases/download/continuous/olive-dep-win32.tar.gz tar xzf olive-dep-win32.tar.gz + - name: Generate Patreon List + env: + PATREON_KEY: ${{ secrets.PATREON_KEY }} + run: | + cd $GITHUB_WORKSPACE/app/dialog/about + python3 patreon.py + if: github.event_name == 'push' + - name: Configure CMake shell: bash env: @@ -322,6 +338,14 @@ jobs: $DOWNLOAD_TOOL https://github.com/olive-editor/dependencies/releases/download/continuous/olive-dep-mac-x86_64.tar.gz sudo tar xzf olive-dep-mac-x86_64.tar.gz -C / + - name: Generate Patreon List + env: + PATREON_KEY: ${{ secrets.PATREON_KEY }} + run: | + cd $GITHUB_WORKSPACE/app/dialog/about + python3 patreon.py + if: github.event_name == 'push' + - name: Configure CMake shell: bash working-directory: ${{ runner.workspace }}/build diff --git a/app/dialog/about/patreon.py b/app/dialog/about/patreon.py new file mode 100644 index 000000000..78fe9a059 --- /dev/null +++ b/app/dialog/about/patreon.py @@ -0,0 +1,32 @@ +import json +import requests +import os + +url = 'https://www.patreon.com/api/oauth2/v2/campaigns/1478705/members?include=currently_entitled_tiers&fields%5Bmember%5D=full_name' +name_list = '' + +while True: + member_data = requests.get(url, headers = {"authorization": "Bearer " + os.environ.get('PATREON_KEY')}) + member_data_decoded = json.loads(member_data.text) + + for member in member_data_decoded["data"]: + if len(member["relationships"]["currently_entitled_tiers"]["data"]) > 0: + if member["relationships"]["currently_entitled_tiers"]["data"][0]["id"] == "3952333": + if len(name_list) > 0: + name_list += ',\n' + name = member["attributes"]["full_name"] + name_list += " QStringLiteral(\"" + name_list += name.translate(str.maketrans({ + "\"": "\\\"", + "\\": "\\\\" + })) + name_list += "\")" + + if "links" in member_data_decoded: + url = member_data_decoded["links"]["next"] + else: + break + +text_file = open("patreon.h", "w") +text_file.write("#ifndef PATREON_H\n#define PATREON_H\n\n#include \n\nQStringList patrons = {\n%s\n};\n\n#endif // PATREON_H\n" % name_list) +text_file.close()