diff --git a/codeforces_api/api_requests.py b/codeforces_api/api_requests.py index aa2af32..7b904cc 100644 --- a/codeforces_api/api_requests.py +++ b/codeforces_api/api_requests.py @@ -366,7 +366,7 @@ def user_rating(self, handle): ) ] - def user_status(self, handle, start=-1, count=-1): + def user_status(self, handle, start=-1, count=-1, include_sources=False): """ Get user.status. @@ -376,6 +376,8 @@ def user_status(self, handle, start=-1, count=-1): count is the number of attempts to return. + include_sources is used to include sources in the response, must be your own handle. + Returns parsed response from codeforces.com. """ parameters = { @@ -385,6 +387,8 @@ def user_status(self, handle, start=-1, count=-1): parameters["from"] = str(start) if count != -1: parameters["count"] = str(count) + if include_sources: + parameters["includeSources"] = "true" return [ Submission.de_json(submission) for submission in self._make_request("user.status", **parameters) diff --git a/codeforces_api/types.py b/codeforces_api/types.py index 2b69d2c..00a7392 100644 --- a/codeforces_api/types.py +++ b/codeforces_api/types.py @@ -17,7 +17,7 @@ """ import json - +import base64 class Dictionaryable(object): """ @@ -661,6 +661,7 @@ def de_json(cls, json_string): contest_id = obj.get("contestId") verdict = obj.get("verdict") points = obj.get("points") + source_code = obj.get("sourceBase64") return cls( identifier, creation_time_seconds, @@ -675,6 +676,7 @@ def de_json(cls, json_string): contest_id, verdict, points, + base64.b64decode(source_code).decode() if source_code else None, ) def __init__( @@ -692,6 +694,7 @@ def __init__( contest_id=None, verdict=None, points=None, + source_code=None, ): self.id = identifier self.creation_time_seconds = creation_time_seconds @@ -706,6 +709,7 @@ def __init__( self.contest_id = contest_id self.verdict = verdict self.points = points + self.source_code = source_code def to_dict(self): return { @@ -722,6 +726,7 @@ def to_dict(self): "contest_id": self.contest_id, "verdict": self.verdict, "points": self.points, + "source_code": self.source_code }