mirror of
https://github.com/revanced/revanced-polling-api.git
synced 2025-04-29 22:24:26 +02:00
feat: add vote counting script
This commit is contained in:
parent
c458c7e095
commit
2f64118d1a
@ -16,6 +16,7 @@ services:
|
|||||||
image: ghcr.io/alexandreteles/revanced-releases-api:latest
|
image: ghcr.io/alexandreteles/revanced-releases-api:latest
|
||||||
environment:
|
environment:
|
||||||
- GITHUB_TOKEN=YOUR_GITHUB_TOKEN
|
- GITHUB_TOKEN=YOUR_GITHUB_TOKEN
|
||||||
|
- PASTE_EE_KEY=YOUR_PASTE_EE_KEY
|
||||||
- REDIS_URL=revanced-releases-api-redis
|
- REDIS_URL=revanced-releases-api-redis
|
||||||
- REDIS_PORT=6379
|
- REDIS_PORT=6379
|
||||||
- HYPERCORN_HOST=0.0.0.0
|
- HYPERCORN_HOST=0.0.0.0
|
||||||
|
@ -17,6 +17,7 @@ services:
|
|||||||
image: ghcr.io/alexandreteles/revanced-releases-api:latest
|
image: ghcr.io/alexandreteles/revanced-releases-api:latest
|
||||||
environment:
|
environment:
|
||||||
- GITHUB_TOKEN=YOUR_GITHUB_TOKEN
|
- GITHUB_TOKEN=YOUR_GITHUB_TOKEN
|
||||||
|
- PASTE_EE_KEY=YOUR_PASTE_EE_KEY
|
||||||
- REDIS_URL=revanced-releases-api-redis
|
- REDIS_URL=revanced-releases-api-redis
|
||||||
- REDIS_PORT=6379
|
- REDIS_PORT=6379
|
||||||
- HYPERCORN_HOST=0.0.0.0
|
- HYPERCORN_HOST=0.0.0.0
|
||||||
|
29
poetry.lock
generated
29
poetry.lock
generated
@ -1886,6 +1886,21 @@ files = [
|
|||||||
cryptography = ">=35.0.0"
|
cryptography = ">=35.0.0"
|
||||||
types-pyOpenSSL = "*"
|
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]]
|
[[package]]
|
||||||
name = "types-toml"
|
name = "types-toml"
|
||||||
version = "0.10.8.5"
|
version = "0.10.8.5"
|
||||||
@ -1898,6 +1913,18 @@ files = [
|
|||||||
{file = "types_toml-0.10.8.5-py3-none-any.whl", hash = "sha256:2432017febe43174af0f3c65f03116e3d3cf43e7e1406b8200e106da8cf98992"},
|
{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]]
|
[[package]]
|
||||||
name = "typing-extensions"
|
name = "typing-extensions"
|
||||||
version = "4.5.0"
|
version = "4.5.0"
|
||||||
@ -2272,4 +2299,4 @@ multidict = ">=4.0"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.10"
|
python-versions = "^3.10"
|
||||||
content-hash = "f4b473705cc1919095b7dbf598ca330ebf33ac4c5056a30d802dd853da82bc0f"
|
content-hash = "13662d8d9b4ef5113de76308f22bbe61a65a515bd2d9a315070ba4c241dbfe32"
|
||||||
|
@ -27,6 +27,7 @@ aiofiles = ">=22.1.0"
|
|||||||
uvicorn = ">=0.18.3"
|
uvicorn = ">=0.18.3"
|
||||||
gunicorn = ">=20.1.0"
|
gunicorn = ">=20.1.0"
|
||||||
requests = "^2.28.2"
|
requests = "^2.28.2"
|
||||||
|
types-requests = "^2.28.11.16"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
mypy = ">=0.991"
|
mypy = ">=0.991"
|
||||||
|
@ -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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
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"
|
urllib3==1.26.15 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import redis
|
import redis
|
||||||
import requests
|
import requests
|
||||||
from pprint import pprint
|
from pprint import pformat
|
||||||
|
|
||||||
|
paste_url: str = "https://api.paste.ee/v1/pastes"
|
||||||
|
|
||||||
db = redis.StrictRedis(
|
db = redis.StrictRedis(
|
||||||
host=os.environ["REDIS_URL"], port=os.environ["REDIS_PORT"], db=3
|
host=os.environ["REDIS_URL"], port=os.environ["REDIS_PORT"], db=3
|
||||||
@ -18,11 +20,40 @@ for key in db.scan_iter("*"):
|
|||||||
else:
|
else:
|
||||||
votes[entry["cid"]] = 1
|
votes[entry["cid"]] = 1
|
||||||
|
|
||||||
raw_votes: str = pprint.pformat(votes)
|
raw_votes: str = pformat(votes)
|
||||||
sorted_votes: str = pprint.pformat(
|
sorted_votes: str = pformat(sorted(votes))
|
||||||
dict(sorted(votes.items(), key=lambda item: item[1], reverse=True))
|
|
||||||
)
|
text: list = [
|
||||||
|
'Raw votes:\n\n',
|
||||||
|
raw_votes,
|
||||||
|
'\n\nSorted votes:\n\n',
|
||||||
|
sorted_votes
|
||||||
|
]
|
||||||
|
|
||||||
with open("votes.txt", "w") as f:
|
with open("votes.txt", "w") as f:
|
||||||
f.write(raw_votes)
|
f.writelines(text)
|
||||||
f.write(sorted_votes)
|
|
||||||
|
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"]}')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user