RcGcDb/src/wiki.py

28 lines
1.4 KiB
Python
Raw Normal View History

2020-07-09 23:58:25 +00:00
from dataclasses import dataclass
2020-07-10 13:38:36 +00:00
from src.session import session
2020-07-09 23:58:25 +00:00
@dataclass
2020-07-09 22:24:23 +00:00
class Wiki:
2020-07-10 13:38:36 +00:00
mw_messages: int = None
2020-07-09 23:58:25 +00:00
fail_times: int = 0 # corresponding to amount of times connection with wiki failed for client reasons (400-499)
2020-07-10 13:38:36 +00:00
async def fetch_wiki(self, extended, api_path):
url_path = api_path
amount = 20
if extended:
params = {"action": "query", "format": "json", "uselang": "content", "list": "tags|recentchanges",
"meta": "allmessages|siteinfo",
"utf8": 1, "tglimit": "max", "tgprop": "displayname",
"rcprop": "title|redirect|timestamp|ids|loginfo|parsedcomment|sizes|flags|tags|user",
"rclimit": amount, "rctype": "edit|new|log|external",
"ammessages": "recentchanges-page-added-to-category|recentchanges-page-removed-from-category|recentchanges-page-added-to-category-bundled|recentchanges-page-removed-from-category-bundled",
"amenableparser": 1, "amincludelocal": 1, "siprop": "namespaces"}
else:
params = {"action": "query", "format": "json", "uselang": "content", "list": "tags|recentchanges",
"utf8": 1,
"tglimit": "max", "tgprop": "displayname",
"rcprop": "title|redirect|timestamp|ids|loginfo|parsedcomment|sizes|flags|tags|user",
"rclimit": amount, "rctype": "edit|new|log|external", "siprop": "namespaces"}
try:
await session.get(url_path, params=params)