diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 1a6ffd6..213adb1 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -16,6 +16,7 @@ services: image: ghcr.io/alexandreteles/revanced-releases-api:latest environment: - GITHUB_TOKEN=YOUR_GITHUB_TOKEN + - PASTE_EE_KEY=YOUR_PASTE_EE_KEY - REDIS_URL=revanced-releases-api-redis - REDIS_PORT=6379 - HYPERCORN_HOST=0.0.0.0 diff --git a/deploy/portainer-stack.yml b/deploy/portainer-stack.yml index 87fd47e..175d55a 100644 --- a/deploy/portainer-stack.yml +++ b/deploy/portainer-stack.yml @@ -17,6 +17,7 @@ services: image: ghcr.io/alexandreteles/revanced-releases-api:latest environment: - GITHUB_TOKEN=YOUR_GITHUB_TOKEN + - PASTE_EE_KEY=YOUR_PASTE_EE_KEY - REDIS_URL=revanced-releases-api-redis - REDIS_PORT=6379 - HYPERCORN_HOST=0.0.0.0 diff --git a/poetry.lock b/poetry.lock index e7ed19d..c77f150 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1886,6 +1886,21 @@ files = [ cryptography = ">=35.0.0" types-pyOpenSSL = "*" +[[package]] +name = "types-requests" +version = "2.28.11.16" +description = "Typing stubs for requests" +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "types-requests-2.28.11.16.tar.gz", hash = "sha256:9d4002056df7ebc4ec1f28fd701fba82c5c22549c4477116cb2656aa30ace6db"}, + {file = "types_requests-2.28.11.16-py3-none-any.whl", hash = "sha256:a86921028335fdcc3aaf676c9d3463f867db6af2303fc65aa309b13ae1e6dd53"}, +] + +[package.dependencies] +types-urllib3 = "<1.27" + [[package]] name = "types-toml" version = "0.10.8.5" @@ -1898,6 +1913,18 @@ files = [ {file = "types_toml-0.10.8.5-py3-none-any.whl", hash = "sha256:2432017febe43174af0f3c65f03116e3d3cf43e7e1406b8200e106da8cf98992"}, ] +[[package]] +name = "types-urllib3" +version = "1.26.25.9" +description = "Typing stubs for urllib3" +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "types-urllib3-1.26.25.9.tar.gz", hash = "sha256:160727879bdbe52f11f5feeca092a473f38d68ed3be88abb461b59cda40fb9bc"}, + {file = "types_urllib3-1.26.25.9-py3-none-any.whl", hash = "sha256:b327d360ba4a9edd80ea82f5990ba19e76175a20b5b64be4b4813d9a1c424caa"}, +] + [[package]] name = "typing-extensions" version = "4.5.0" @@ -2272,4 +2299,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "f4b473705cc1919095b7dbf598ca330ebf33ac4c5056a30d802dd853da82bc0f" +content-hash = "13662d8d9b4ef5113de76308f22bbe61a65a515bd2d9a315070ba4c241dbfe32" diff --git a/pyproject.toml b/pyproject.toml index 20c1f7f..83a072f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ aiofiles = ">=22.1.0" uvicorn = ">=0.18.3" gunicorn = ">=20.1.0" requests = "^2.28.2" +types-requests = "^2.28.11.16" [tool.poetry.dev-dependencies] mypy = ">=0.991" diff --git a/requirements.txt b/requirements.txt index 1503280..891ad39 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ async-timeout==4.0.2 ; python_version >= "3.10" and python_version < "4.0" attrs==22.2.0 ; python_version < "4.0" and python_version >= "3.10" certifi==2022.12.7 ; python_version >= "3.10" and python_version < "4.0" cffi==1.15.1 ; python_version >= "3.10" and python_version < "4.0" -charset-normalizer==3.1.0 ; python_version >= "3.11" and python_version < "4.0" +charset-normalizer==3.1.0 ; python_version < "4.0" and python_version >= "3.10" click==8.1.3 ; python_version >= "3.10" and python_version < "4.0" colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32" or python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows" cryptography==37.0.4 ; python_version >= "3.10" and python_version < "4.0" @@ -49,6 +49,7 @@ pyseto==1.6.10 ; python_version >= "3.10" and python_version < "4.0" python-dateutil==2.8.2 ; python_version >= "3.10" and python_version < "4.0" pytzdata==2020.1 ; python_version >= "3.10" and python_version < "4.0" redis==4.5.3 ; python_version >= "3.10" and python_version < "4.0" +requests==2.28.2 ; python_version >= "3.10" and python_version < "4" rfc3986[idna2008]==1.5.0 ; python_version >= "3.10" and python_version < "4.0" sentry-sdk==1.17.0 ; python_version >= "3.10" and python_version < "4.0" setuptools==67.6.0 ; python_version >= "3.10" and python_version < "4.0" @@ -58,6 +59,8 @@ sniffio==1.3.0 ; python_version >= "3.10" and python_version < "4.0" starlette==0.20.4 ; python_version >= "3.10" and python_version < "4.0" toml==0.10.2 ; python_version >= "3.10" and python_version < "4.0" toolz==0.12.0 ; python_version >= "3.10" and python_version < "4.0" +types-requests==2.28.11.16 ; python_version >= "3.10" and python_version < "4.0" +types-urllib3==1.26.25.9 ; python_version >= "3.10" and python_version < "4.0" typing-extensions==4.5.0 ; python_version >= "3.10" and python_version < "4.0" ujson==5.7.0 ; python_version >= "3.10" and python_version < "4.0" urllib3==1.26.15 ; python_version >= "3.10" and python_version < "4.0" diff --git a/vote_count.py b/vote_count.py index 3184c17..1adcff8 100644 --- a/vote_count.py +++ b/vote_count.py @@ -1,7 +1,9 @@ import os import redis import requests -from pprint import pprint +from pprint import pformat + +paste_url: str = "https://api.paste.ee/v1/pastes" db = redis.StrictRedis( host=os.environ["REDIS_URL"], port=os.environ["REDIS_PORT"], db=3 @@ -18,11 +20,40 @@ for key in db.scan_iter("*"): else: votes[entry["cid"]] = 1 -raw_votes: str = pprint.pformat(votes) -sorted_votes: str = pprint.pformat( - dict(sorted(votes.items(), key=lambda item: item[1], reverse=True)) -) +raw_votes: str = pformat(votes) +sorted_votes: str = pformat(sorted(votes)) + +text: list = [ + 'Raw votes:\n\n', + raw_votes, + '\n\nSorted votes:\n\n', + sorted_votes +] with open("votes.txt", "w") as f: - f.write(raw_votes) - f.write(sorted_votes) + f.writelines(text) + +payload: dict = { + "description": "ReVanced Poll Results", + "sections": [ + { + "name": "Raw Votes", + "syntax": "autodetect", + "contents": raw_votes + }, + { + "name": "Sorted Votes", + "syntax": "autodetect", + "contents": sorted_votes + } + ] +} + +headers = { + "Content-Type": "application/json", + "X-Auth-Token": os.environ["PASTE_EE_KEY"] +} + +response: dict = requests.post(paste_url, json=payload, headers=headers).json() + +print(f'Upload response: {response["link"]}')