Skip to content

Commit 68d063a

Browse files
committed
Merge branch 'dev'
2 parents 6ce1faf + 10685ec commit 68d063a

37 files changed

+237
-205
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Renondedju
3+
Copyright (c) 2018-2019 Renondedju
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ This library is developed for [Uso! bot](https://github.com/Renondedju/Uso_Bot_V
66

77
## Requirements
88

9-
- Python 3.6+ *(python 3.7 is partially unsupported due to the changes to asyncio)*
10-
- The *aiohttp* library : [Install instructions](https://aiohttp.readthedocs.io/en/stable/)
9+
- Python 3.6+ *(anterior versions might be supported but haven't been tested.)*
10+
- The **aiohttp** library : [Install instructions](https://aiohttp.readthedocs.io/en/stable/)
1111
- An internet connexion
1212

1313
## Installation
@@ -22,6 +22,24 @@ Or from the source
2222
$ cd Osu.py
2323
$ pip install .
2424

25+
## Example
26+
27+
```py
28+
import asyncio
29+
from pyosu import OsuApi
30+
31+
async def main():
32+
33+
api = OsuApi('Your api key here')
34+
35+
bests = await api.get_user_bests('Renondedju')
36+
for best in bests:
37+
print(best.__dict__)
38+
39+
if __name__ == '__main__':
40+
asyncio.run(main())
41+
```
42+
2543
## Documentations
2644

2745
Link to the [docs](docs/index.md)
@@ -43,4 +61,4 @@ Thanks to @ppy for [the osu api](https://github.com/ppy/osu-api/wiki)
4361

4462
## License
4563

46-
Osu<span></span>.py is released under the [MIT License](http://www.opensource.org/licenses/MIT). Check [the license](LICENSE) for more details.
64+
Osu<span></span>.py is released under the [MIT License](http://www.opensource.org/licenses/MIT). Check [the license](LICENSE) for more details.

pyosu/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
# Copyright (c) 2018 Renondedju
3+
# Copyright (c) 2018-2019 Renondedju
44

55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
@@ -25,17 +25,17 @@
2525
~~~~~~~~~~~~~~~~~~~
2626
A basic wrapper for the Osu API.
2727
28-
:copyright: (c) 2018 Renondedju
28+
:copyright: (c) 2018-2019 Renondedju
2929
:license: MIT, see LICENSE for more details.
3030
"""
3131

3232
__title__ = 'osu.py'
3333
__author__ = 'Renondedju'
3434
__license__ = 'MIT'
35-
__copyright__ = 'Copyright 2018 Renondedju'
36-
__version__ = '0.5.0'
35+
__copyright__ = 'Copyright 2018-2019 Renondedju'
36+
__version__ = '0.5.1'
3737

38-
from .api import OsuApi
38+
from .api import OsuApi
3939

4040
from . import models
4141
from . import types

pyosu/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
# Copyright (c) 2018 Renondedju
3+
# Copyright (c) 2018-2019 Renondedju
44

55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
@@ -22,8 +22,8 @@
2222

2323
import asyncio
2424

25-
from .http import Route, Request
26-
from .models import (
25+
from pyosu.http import Route, Request
26+
from pyosu.models import (
2727
User,
2828
Score,
2929
Replay,
@@ -40,7 +40,7 @@
4040
UserBestCollection,
4141
UserRecentCollection,
4242
)
43-
from .exceptions import ReplayUnavailable
43+
from pyosu.exceptions import ReplayUnavailable
4444

4545

4646
class OsuApi():

pyosu/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
# Copyright (c) 2018 Renondedju
3+
# Copyright (c) 2018-2019 Renondedju
44

55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal

pyosu/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
# Copyright (c) 2018 Renondedju
3+
# Copyright (c) 2018-2019 Renondedju
44

55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal

pyosu/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
# Copyright (c) 2018 Renondedju
3+
# Copyright (c) 2018-2019 Renondedju
44

55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal

pyosu/models/base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
# Copyright (c) 2018 Renondedju
3+
# Copyright (c) 2018-2019 Renondedju
44

55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
@@ -20,8 +20,7 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
from abc import ABCMeta
24-
23+
from abc import ABCMeta
2524
from pyosu.exceptions import UnreferencedApi
2625

2726

pyosu/models/beatmap.py

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
# Copyright (c) 2018 Renondedju
3+
# Copyright (c) 2018-2019 Renondedju
44

55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
@@ -20,9 +20,10 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
from pyosu.types import BeatmapGenre, BeatmapApprovedState, GameMode, Language
23+
import datetime
2424

25-
from .base import BaseModel
25+
from pyosu.types import BeatmapGenre, BeatmapApprovedState, GameMode, Language
26+
from pyosu.models.base import BaseModel
2627

2728
class Beatmap(BaseModel):
2829
""" Beatmap model """
@@ -32,33 +33,33 @@ def __init__(self, *, api : 'OsuApi' = None, **data):
3233
super().__init__(api)
3334

3435
#Api data
35-
self.approved = data.get('approved' , BeatmapApprovedState.Pending)
36-
self.approved_date = data.get('approved_date' , "") # date ranked, UTC+8 for now
37-
self.last_update = data.get('last_update' , "") # last update date, timezone same as above. May be after approved_date if map was unranked and reranked.
38-
self.artist = data.get('artist' , "")
39-
self.beatmap_id = data.get('beatmap_id' , 0) # beatmap_id is per difficulty
40-
self.beatmapset_id = data.get('beatmapset_id' , 0) # beatmapset_id groups difficulties into a set
41-
self.bpm = data.get('bpm' , 0.0)
42-
self.creator = data.get('creator' , "")
43-
self.difficultyrating = data.get('difficultyrating', 0.0) # The amount of stars the map would have ingame and on the website
44-
self.diff_size = data.get('diff_size' , 0.0) # Circle size value (CS)
45-
self.diff_overall = data.get('diff_overall' , 0.0) # Overall difficulty (OD)
46-
self.diff_approach = data.get('diff_approach' , 0.0) # Approach Rate (AR)
47-
self.diff_drain = data.get('diff_drain' , 0.0) # Healthdrain (HP)
48-
self.hit_length = data.get('hit_length' , 0.0) # seconds from first note to last note not including breaks
49-
self.source = data.get('source' , "")
50-
self.genre_id = data.get('genre_id' , BeatmapGenre.Any)
51-
self.language_id = data.get('language_id' , Language.Any)
52-
self.title = data.get('title' , "") # song name
53-
self.total_length = data.get('total_length' , 0.0) # seconds from first note to last note including breaks
54-
self.version = data.get('version' , "") # difficulty name
55-
self.file_md5 = data.get('file_md5' , "") # md5 hash of the beatmap
56-
self.mode = data.get('mode' , GameMode.Osu) # game mode,
57-
self.tags = data.get('tags' , "") # Beatmap tags separated by spaces.
58-
self.favourite_count = data.get('favourite_count' , 0) # Number of times the beatmap was favourited.
59-
self.playcount = data.get('playcount' , 0) # Number of times the beatmap was played
60-
self.passcount = data.get('passcount' , 0) # Number of times the beatmap was passed, completed (the user didn't fail or retry)
61-
self.max_combo = data.get('max_combo' , 0) # The maximum combo a user can reach playing this beatmap.
36+
self.bpm = float(data.get('bpm' , 0.0))
37+
self.diff_size = float(data.get('diff_size' , 0.0)) # Circle size value (CS)
38+
self.diff_drain = float(data.get('diff_drain' , 0.0)) # Healthdrain (HP)
39+
self.hit_length = float(data.get('hit_length' , 0.0)) # seconds from first note to last note not including breaks
40+
self.diff_overall = float(data.get('diff_overall' , 0.0)) # Overall difficulty (OD)
41+
self.total_length = float(data.get('total_length' , 0.0)) # seconds from first note to last note including breaks
42+
self.diff_approach = float(data.get('diff_approach' , 0.0)) # Approach Rate (AR)
43+
self.difficultyrating = float(data.get('difficultyrating', 0.0)) # The amount of stars the map would have ingame and on the website
44+
self.mode = int(data.get('mode' , GameMode.Osu)) # game mode,
45+
self.approved = int(data.get('approved' , BeatmapApprovedState.Pending))
46+
self.genre_id = int(data.get('genre_id' , BeatmapGenre.Any))
47+
self.playcount = int(data.get('playcount' , 0)) # Number of times the beatmap was played
48+
self.passcount = int(data.get('passcount' , 0)) # Number of times the beatmap was passed, completed (the user didn't fail or retry)
49+
self.max_combo = int(data.get('max_combo' , 0)) # The maximum combo a user can reach playing this beatmap.
50+
self.beatmap_id = int(data.get('beatmap_id' , 0)) # beatmap_id is per difficulty
51+
self.language_id = int(data.get('language_id' , Language.Any))
52+
self.beatmapset_id = int(data.get('beatmapset_id' , 0)) # beatmapset_id groups difficulties into a set
53+
self.favourite_count = int(data.get('favourite_count' , 0)) # Number of times the beatmap was favourited.
54+
self.tags = data.get('tags' , "") # Beatmap tags separated by spaces.
55+
self.title = data.get('title' , "") # song name
56+
self.source = data.get('source' , "")
57+
self.artist = data.get('artist' , "")
58+
self.version = data.get('version' , "") # difficulty name
59+
self.creator = data.get('creator' , "")
60+
self.file_md5 = data.get('file_md5' , "") # md5 hash of the beatmap
61+
self.approved_date = datetime.datetime.strptime(data.get('approved_date' , "1970-01-01 00:00:00") , "%Y-%m-%d %H:%M:%S") # date ranked, UTC+8 for now
62+
self.last_update = datetime.datetime.strptime(data.get('last_update' , "1970-01-01 00:00:00") , "%Y-%m-%d %H:%M:%S") # last update date, timezone same as above. May be after approved_date if map was unranked and reranked.
6263

6364
async def get_beatmapset(self):
6465
""" Returns a beatmap collection with every beatmap of the beatmapset """

pyosu/models/beatmap_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
# Copyright (c) 2018 Renondedju
3+
# Copyright (c) 2018-2019 Renondedju
44

55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
@@ -22,7 +22,7 @@
2222

2323
import re
2424

25-
from .base import BaseModel
25+
from pyosu.models.base import BaseModel
2626

2727
class BeatmapFile(BaseModel):
2828
""" Beatmap file model.

0 commit comments

Comments
 (0)