Giter Site home page Giter Site logo

cndrd / siegeapi Goto Github PK

View Code? Open in Web Editor NEW
45.0 2.0 2.0 224 KB

Rainbow Six Siege Python API Interface

Home Page: https://cndrd.github.io/siegeapi/

License: MIT License

Python 100.00%
rainbow-six-siege api python interface python3 ubisoft ubisoft-api r6 r6s

siegeapi's Introduction

siegeapi's People

Contributors

cndrd avatar ken-miles avatar xample33 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

siegeapi's Issues

Ranked 2.0

At the moment siegeapi is missing a MMR/Ranked Points endpoint..
I want to add this as soon as possible, but I'm unable to get it to work.
I'm not smart enough to make it work on my own (anything i try to do just spits out a shitload of errors..) and I will have to wait until someone makes a working version for another language so I can take that one apart and try to understand it..

I've even spent a solid few hours trying to go step-by-step, copying what Daniel has done in r6api.js
Too dumb to make that work too..

So until the time comes, when there's a working usable library, siegeapi is fucked ๐Ÿ˜ฅ

Support for Y7S4?

Thx for your amazing siegeapi! I have checked the commit history, seems like that some work for Y7S4 is ongoing, but I've tried the latest version, Y7S4 stats seems unavailable currently.

Exception when trying to run the example code

When running the example code (Windows, Python 3.8.12), I get an exception. Here's the final part of it:

C:\usr\Miniconda3\lib\site-packages\siegeapi\player.py in <module>
      6 from .url_builder import UrlBuilder
      7 from .operators import Operators
----> 8 from .weapons import Weapons
      9 from .trends import Trends
     10 from .ranks import Rank

C:\usr\Miniconda3\lib\site-packages\siegeapi\weapons.py in <module>
     29
     30
---> 31 class WeaponsGameMode:
     32     def __init__(self, data: dict):
     33         self.primary: list = self._get_weapons_list(data.get("weaponSlots", {}).get("primary
Weapons", {}).get("weaponTypes", [{}])[0].get("weapons", []))

C:\usr\Miniconda3\lib\site-packages\siegeapi\weapons.py in WeaponsGameMode()
     35
     36     @staticmethod
---> 37     def _get_weapons_list(data: List[dict] | None) -> List[Weapon] | None:
     38         return None if not data else [Weapon(weapon) for weapon in data]
     39

TypeError: unsupported operand type(s) for |: '_GenericAlias' and 'NoneType'

Any thoughts?

HTTP 401: Invalid credentials

I modified the mail, password and uid according to the demo code on the homepage of the repo, but after running the code, I got the following error

Traceback (most recent call last):
  File "d:\project\demo\main.py", line 28, in <module>
    asyncio.run(sample())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "d:\project\demo\main.py", line 6, in sample
    player = await auth.get_player(uid="2ebxxx157")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\project\demo\Lib\site-packages\siegeapi\auth.py", line 288, in get_player
    results = await self._find_players(name=name, platform=platform, uid=uid)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\project\demo\Lib\site-packages\siegeapi\auth.py", line 80, in _find_players
    data = await self.get(f"https://public-ubiservices.ubi.com/v3/users/{uid}/profiles?"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\project\demo\Lib\site-packages\siegeapi\auth.py", line 236, in get
    raise last_error
  File "d:\project\demo\Lib\site-packages\siegeapi\auth.py", line 227, in get
    await self.connect()
  File "d:\project\demo\Lib\site-packages\siegeapi\auth.py", line 212, in connect
    raise FailedToConnect(message)
siegeapi.exceptions.FailedToConnect: HTTP 401: Invalid credentials

Quick question: does load general return quick match stats as well?

I'm somewhat new to the game and the api works fine but when I tried loading general stats everything is 0. I also tried it with a friend and his returns a bunch of info. Is this because it only returns unranked stats and is there a method to return quick match stats?

Cannot query user

File "/home/avien/.local/lib/python3.9/site-packages/siegeapi/auth.py", line 286, in get_player results = await self._find_players(name=name, platform=platform, uid=uid) File "/home/avien/.local/lib/python3.9/site-packages/siegeapi/auth.py", line 77, in _find_players data = await self.get(f"https://public-ubiservices.ubi.com/v3/profiles?" File "/home/avien/.local/lib/python3.9/site-packages/siegeapi/auth.py", line 234, in get raise last_error File "/home/avien/.local/lib/python3.9/site-packages/siegeapi/auth.py", line 225, in get await self.connect() File "/home/avien/.local/lib/python3.9/site-packages/siegeapi/auth.py", line 210, in connect raise FailedToConnect(message) siegeapi.exceptions.FailedToConnect: HTTP 400: The Ubi-AppId header is invalid

I am getting the above error while trying to get user stats

Search function?

Would it be possible to make a search function instead of using the email and password?

Auth.get_player_batch(names, uids, platform)

If I call get_player_batch with names param,could it return a dictionary whose key is name like player[player.name]? player[player.id] is not easy to use the key for mapping.

Some little features/improvements

I have added some very simple features that add new variables and makes the traceback cleaner.

  1. In player.py: load_playtime a new variable called total_time_played_hours (self explanatory):
async def load_playtime(self) -> None:
        data = await self._auth.get(self._url_builder.playtime())
        stats = data.get("profiles", [])[0].get("stats", {})

        self.level = int(stats.get("PClearanceLevel", {}).get("value", 0))
        self.pvp_time_played = int(stats.get("PPvPTimePlayed", {}).get("value", 0))
        self.pve_time_played = int(stats.get("PPvETimePlayed", {}).get("value", 0))
        self.total_time_played = int(stats.get("PTotalTimePlayed", {}).get("value", 0))
        self.total_time_played_hours = self.total_time_played // 3600 if self.total_time_played else 0

  1. In auth.py: _find_players in case of no results, close the connection before raising InvalidRequest to avoid Unclosed connector exception in the traceback: (this can be applied to every raise in _find_players and maybe other methods)
async def _find_players(self, name: str, platform: str, uid: str) -> list[Player]:
        . . .
        . . .
        . . .

        if "profiles" in data:
            results = [Player(self, x) for x in data["profiles"] if x.get("platformType", "") == platform]
            if len(results) == 0:
                await self.close()
                raise InvalidRequest("No results")
            return results
        else:
            raise InvalidRequest(f"Missing key profiles in returned JSON object {str(data)}")

Maybe these are worth or useful, lmk what you think

How can I avoid HTTP 429 situation?

I have enabled multiple Ubisoft accounts to obtain data on many players. However, in addition to being able to successfully search for players, these accounts now have 429 too many requests for summary and other subsequent steps. It may be that I only use Is it the reason for a normal request request instead of a session conversation?

Trends are fucked up

Yeah so Ubi, once again, have changed how their shit works
Now this time it's a bit on me, since I missed this one and expected these stats to just hide behind a different endpoint
How silly of me..

Instead of having a per-day / per-week / per-month datapoints we now get per-match "actuals" & "trend"
At least it looks nice when on a chart..

Can I get past ranks?

Is it possible to get rank information for past seasons using load_ranked_v2()?
If I can't do it, is there any other way to get it?
(I would like to get rank on Y7S4 and Y8S1.)

Xbl and psn compatibility

Hi, I wanted to ask if this api wrapper is compatible with Playstation and Xbox id's?,

I tried Xbox id with platform=xbl but it doesn't seem to be working..

New new api

Seems like Ubisoft has, in their infinite wisdom, came up with yet another API..

I'll analyze the state of things, and I will try to get a version 4 out as soon as humanly possible lmao
Hoping to get it done by the end of the week tho

"bug" in player.max_mmr

Suppose having this function:

async def test():
    auth = Auth('email', 'password')
    player = await auth.get_player(name='xxx')
    ranked = await player.load_ranked()
    
    print(f'max mmr: {ranked.max_mmr}')
    # max_mmr: -1
    await auth.close()

and the player has played only one ranked game in current season, the value of ranked.max_mmr is -1
i think that this is not supposed to be -1 but at most 0 because with one single match, the mmr cannot be calculated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.