Ejemplo n.º 1
0
class Covers(Model):
    """
    https://osu.ppy.sh/docs/index.html#beatmapsetcompact-covers
    """
    cover: str
    cover_2x: str = Field(name="cover@2x")
    card: str
    card_2x: str = Field(name="card@2x")
    list: str
    list_2x: str = Field(name="list@2x")
    slimcover: str
    slimcover_2x: str = Field(name="slimcover@2x")
Ejemplo n.º 2
0
class Score(Model):
    """
    https://osu.ppy.sh/docs/index.html#score
    """
    id: int
    best_id: Optional[int]
    user_id: int
    accuracy: float
    mods: Mod
    score: int
    max_combo: int
    perfect: bool
    statistics: Statistics
    pp: Optional[float]
    rank: Grade
    created_at: Datetime
    mode: GameMode
    mode_int: int
    replay: bool
    passed: bool

    beatmap: Optional[Beatmap]
    beatmapset: Optional[BeatmapsetCompact]
    rank_country: Optional[int]
    rank_global: Optional[int]
    weight: Optional[Weight]
    _user: Optional[UserCompact] = Field(name="user")
    match: Optional[Match]

    def user(self) -> Union[UserCompact, User]:
        return self._fk_user(self.user_id, existing=self._user)
Ejemplo n.º 3
0
class Beatmap(BeatmapCompact):
    total_length: int
    version: str
    accuracy: float
    ar: float
    bpm: Optional[float]
    convert: bool
    count_circles: int
    count_sliders: int
    count_spinners: int
    cs: float
    deleted_at: Optional[Datetime]
    drain: float
    hit_length: int
    is_scoreable: bool
    last_updated: Datetime
    mode_int: int
    passcount: int
    playcount: int
    ranked: RankStatus
    url: str

    # overridden fields
    # -----------------
    _beatmapset: Optional[Beatmapset] = Field(name="beatmapset")

    def expand(self) -> Beatmap:
        return self

    def beatmapset(self) -> Beatmapset:
        return self._fk_beatmapset(self.beatmapset_id,
                                   existing=self._beatmapset)
Ejemplo n.º 4
0
class BeatmapCompact(Model):
    # required fields
    # ---------------
    difficulty_rating: float
    id: int
    mode: GameMode
    status: RankStatus
    total_length: int
    version: str
    user_id: int
    beatmapset_id: int

    # optional fields
    # ---------------
    _beatmapset: Optional[BeatmapsetCompact] = Field(name="beatmapset")
    checksum: Optional[str]
    failtimes: Optional[Failtimes]
    max_combo: Optional[int]

    def expand(self) -> Beatmap:
        return self._fk_beatmap(self.id)

    def user(self) -> User:
        return self._fk_user(self.user_id)

    def beatmapset(self) -> Union[Beatmapset, BeatmapsetCompact]:
        return self._fk_beatmapset(self.beatmapset_id,
                                   existing=self._beatmapset)
Ejemplo n.º 5
0
class BeatmapPlaycount(Model):
    beatmap_id: int
    _beatmap: Optional[BeatmapCompact] = Field(name="beatmap")
    beatmapset: Optional[BeatmapsetCompact]
    count: int

    def beatmap(self) -> Union[Beatmap, BeatmapCompact]:
        return self._fk_beatmap(self.beatmap_id, existing=self._beatmap)
Ejemplo n.º 6
0
class BeatmapsetDiscussion(Model):
    id: int
    beatmapset_id: int
    beatmap_id: Optional[int]
    user_id: int
    deleted_by_id: Optional[int]
    message_type: MessageType
    parent_id: Optional[int]
    # a point of time which is ``timestamp`` milliseconds into the map
    timestamp: Optional[int]
    resolved: bool
    can_be_resolved: bool
    can_grant_kudosu: bool
    created_at: Datetime
    # documented as non-optional, api.beatmapset_events() might give a null
    # response for this? but very rarely. need to find a repro case
    current_user_attributes: Any
    updated_at: Datetime
    deleted_at: Optional[Datetime]
    # similarly as for current_user_attributes, in the past this has been null
    # but can't find a repro case
    last_post_at: Datetime
    kudosu_denied: bool
    starting_post: Optional[BeatmapsetDiscussionPost]
    posts: Optional[List[BeatmapsetDiscussionPost]]
    _beatmap: Optional[BeatmapCompact] = Field(name="beatmap")
    _beatmapset: Optional[BeatmapsetCompact] = Field(name="beatmapset")

    def user(self) -> User:
        return self._fk_user(self.user_id)

    def deleted_by(self) -> Optional[User]:
        return self._fk_user(self.deleted_by_id)

    def beatmapset(self) -> Union[Beatmapset, BeatmapsetCompact]:
        return self._fk_beatmapset(self.beatmapset_id,
                                   existing=self._beatmapset)

    def beatmap(self) -> Union[Optional[Beatmap], BeatmapCompact]:
        return self._fk_beatmap(self.beatmap_id, existing=self._beatmap)
Ejemplo n.º 7
0
class BeatmapsetCompact(Model):
    """
    https://osu.ppy.sh/docs/index.html#beatmapsetcompact
    """
    # required fields
    # ---------------
    artist: str
    artist_unicode: str
    covers: Covers
    creator: str
    favourite_count: int
    id: int
    play_count: int
    preview_url: str
    source: str
    status: RankStatus
    title: str
    title_unicode: str
    user_id: int
    video: bool
    nsfw: bool
    # documented as being in ``Beatmapset`` only, but returned by
    # ``api.beatmapset_events`` which uses a ``BeatmapsetCompact``.
    hype: Optional[Hype]

    # optional fields
    # ---------------
    beatmaps: Optional[List[Beatmap]]
    converts: Optional[Any]
    current_user_attributes: Optional[Any]
    description: Optional[Any]
    discussions: Optional[Any]
    events: Optional[Any]
    genre: Optional[Any]
    has_favourited: Optional[bool]
    language: Optional[Any]
    nominations: Optional[Any]
    ratings: Optional[Any]
    recent_favourites: Optional[Any]
    related_users: Optional[Any]
    _user: Optional[UserCompact] = Field(name="user")
    # undocumented
    track_id: Optional[int]

    def expand(self) -> Beatmapset:
        return self._fk_beatmapset(self.id)

    def user(self) -> Union[UserCompact, User]:
        return self._fk_user(self.user_id, existing=self._user)
Ejemplo n.º 8
0
class Search(Model):
    users: Optional[SearchResult[UserCompact]] = Field(name="user")
    wiki_pages: Optional[SearchResult[WikiPage]] = Field(name="wiki_page")
Ejemplo n.º 9
0
class ChangelogSearch(Model):
    from_: Optional[str] = Field(name="from")
    limit: int
    max_id: Optional[int]
    stream: Optional[str]
    to: Optional[str]