Skip to content

Commit 5b3437c

Browse files
begin work on activitiy fetching
1 parent dd1bbd4 commit 5b3437c

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

utils/msl/activities.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,35 @@ async def create_activity() -> int:
173173
raise NotImplementedError
174174

175175

176-
async def fetch_activity(activity_id: int) -> dict[str, str]:
176+
async def fetch_activity(activity_id: int) -> Activity | None:
177177
"""Fetch a specific activity from the guild website."""
178+
data_fields, cookies = await get_msl_context(url=ALL_ACTIVITIES_URL)
179+
180+
form_data: dict[str, str] = {
181+
"__EVENTTARGET": "",
182+
"__EVENTARGUMENT": "",
183+
"__VIEWSTATEENCRYPTED": "",
184+
}
185+
186+
data_fields.update(form_data)
187+
188+
data_fields.pop("ctl00$ctl00$Main$AdminPageContent$fsFilter$btnCancel")
189+
190+
session_v2: aiohttp.ClientSession = aiohttp.ClientSession(
191+
headers=BASE_HEADERS,
192+
cookies=cookies,
193+
)
194+
async with (
195+
session_v2,
196+
session_v2.post(url=f"{INDIVIDUAL_ACTIVITIES_URL}/{activity_id}", data=data_fields) as http_response,
197+
):
198+
if http_response.status != 200:
199+
logger.debug("Returned a non 200 status code!!")
200+
logger.debug(http_response)
201+
return None
202+
203+
response_html: str = await http_response.text()
204+
205+
logger.debug(response_html)
206+
178207
raise NotImplementedError

0 commit comments

Comments
 (0)