Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions xbox/webapi/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Basic factory that stores :class:`XboxLiveLanguage`, User authorization data
and available `Providers`
"""

import logging
from typing import Any

Expand Down Expand Up @@ -64,9 +65,9 @@ async def request(
# Ensure tokens valid
await self._auth_mgr.refresh_tokens()
# Set auth header
headers[
"Authorization"
] = self._auth_mgr.xsts_token.authorization_header_value
headers["Authorization"] = (
self._auth_mgr.xsts_token.authorization_header_value
)

if include_cv:
headers["MS-CV"] = self._cv.increment()
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/achievements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Get Xbox 360 and Xbox One Achievement data
"""

from xbox.webapi.api.provider.achievements.models import (
Achievement360ProgressResponse,
Achievement360Response,
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/catalog/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Store Catalog - Lookup Product Information
"""

from typing import List

from xbox.webapi.api.provider.baseprovider import BaseProvider
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/catalog/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Web API Constants."""

from xbox.webapi.api.provider.catalog.models import AlternateIdType

HOME_APP_IDS = {
Expand Down
5 changes: 4 additions & 1 deletion xbox/webapi/api/provider/catalog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class Image(PascalCaseModel):
height: int
image_position_info: Optional[str] = None
image_purpose: str
unscaled_image_sha256_hash: Optional[str] = Field(None, alias="UnscaledImageSHA256Hash")
unscaled_image_sha256_hash: Optional[str] = Field(
None, alias="UnscaledImageSHA256Hash"
)
uri: str
width: int

Expand Down Expand Up @@ -251,6 +253,7 @@ class SkuProperties(PascalCaseModel):
def validator(x):
return x or None


class Sku(PascalCaseModel):
last_modified_date: datetime
localized_properties: List[SkuLocalizedProperty]
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/cqs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Used for download stump (TV Streaming) data
(RemoteTVInput ServiceChannel on Smartglass)
"""

from xbox.webapi.api.provider.baseprovider import BaseProvider
from xbox.webapi.api.provider.cqs.models import (
CqsChannelListResponse,
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/gameclips/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Gameclips - Get gameclip info
"""

from xbox.webapi.api.provider.baseprovider import BaseProvider
from xbox.webapi.api.provider.gameclips.models import GameclipsResponse

Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/lists/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
EPLists - Mainly used for XBL Pins
"""

from xbox.webapi.api.provider.baseprovider import BaseProvider
from xbox.webapi.api.provider.lists.models import ListMetadata, ListsResponse

Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/mediahub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Mediahub - Fetch screenshots and gameclips
"""

from xbox.webapi.api.provider.baseprovider import BaseProvider
from xbox.webapi.api.provider.mediahub.models import (
MediahubGameclips,
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

TODO: Support group messaging
"""

from xbox.webapi.api.provider.baseprovider import BaseProvider
from xbox.webapi.api.provider.message.models import (
ConversationResponse,
Expand Down
14 changes: 11 additions & 3 deletions xbox/webapi/api/provider/people/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
if TYPE_CHECKING:
from xbox.webapi.api.client import XboxLiveClient


class PeopleProvider(RateLimitedProvider):
SOCIAL_URL = "https://social.xboxlive.com"
HEADERS_SOCIAL = {"x-xbl-contract-version": "2"}
Expand Down Expand Up @@ -63,7 +64,10 @@ async def get_friends_own(
return PeopleResponse(**resp.json())

async def get_friends_by_xuid(
self, xuid: str, decoration_fields: list[PeopleDecoration] | None = None, **kwargs
self,
xuid: str,
decoration_fields: list[PeopleDecoration] | None = None,
**kwargs,
) -> PeopleResponse:
"""
Get friendlist of own profile
Expand Down Expand Up @@ -116,7 +120,9 @@ async def get_friends_own_batch(
resp.raise_for_status()
return PeopleResponse(**resp.json())

async def get_friend_recommendations(self, decoration_fields: list[PeopleDecoration] | None = None, **kwargs) -> PeopleResponse:
async def get_friend_recommendations(
self, decoration_fields: list[PeopleDecoration] | None = None, **kwargs
) -> PeopleResponse:
"""
Get recommended friends

Expand All @@ -127,7 +133,9 @@ async def get_friend_recommendations(self, decoration_fields: list[PeopleDecorat
decoration_fields = [PeopleDecoration.DETAIL]
decoration = self.SEPERATOR.join(decoration_fields)

url = f"{self.PEOPLE_URL}/users/me/people/recommendations/decoration/{decoration}"
url = (
f"{self.PEOPLE_URL}/users/me/people/recommendations/decoration/{decoration}"
)
resp = await self.client.session.get(url, headers=self._headers, **kwargs)
resp.raise_for_status()
return PeopleResponse(**resp.json())
Expand Down
18 changes: 10 additions & 8 deletions xbox/webapi/api/provider/people/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from __future__ import annotations

from datetime import datetime
Expand Down Expand Up @@ -53,18 +52,21 @@ class Recommendation(PascalCaseModel):
type: str
reasons: list[str]


class SessionRef(CamelCaseModel):
scid: str
template_name: str
name: str


class PartyDetails(CamelCaseModel):
session_ref: SessionRef
status: str
visibility: str
join_restriction: str
accepted: int


class MultiplayerSummary(CamelCaseModel):
in_multiplayer_session: int | None = None
in_party: int
Expand All @@ -79,7 +81,7 @@ class RecentPlayer(CamelCaseModel):

class Follower(CamelCaseModel):
text: str | None = None
followed_date_time_utc: datetime | None = None
followed_date_time_utc: datetime | None = None


class PreferredColor(CamelCaseModel):
Expand Down Expand Up @@ -139,7 +141,7 @@ class SocialManager(CamelCaseModel):


class Avatar(CamelCaseModel):
update_time_offset: datetime | None = None
update_time_offset: datetime | None = None
spritesheet_metadata: Any | None = None


Expand All @@ -157,7 +159,7 @@ class Person(CamelCaseModel):
is_following_caller: bool
is_followed_by_caller: bool
is_identity_shared: bool
added_date_time_utc: datetime | None = None
added_date_time_utc: datetime | None = None
display_name: str | None = None
real_name: str
display_pic_raw: str
Expand All @@ -175,7 +177,7 @@ class Person(CamelCaseModel):
is_cloaked: bool | None = None
is_quarantined: bool
is_xbox_360_gamerpic: bool
last_seen_date_time_utc: datetime | None = None
last_seen_date_time_utc: datetime | None = None
suggestion: Suggestion | None = None
recommendation: Recommendation | None = None
search: Any | None = None
Expand All @@ -202,7 +204,6 @@ class Person(CamelCaseModel):
is_friend: bool
is_friend_request_received: bool
is_friend_request_sent: bool



class RecommendationSummary(CamelCaseModel):
Expand All @@ -214,7 +215,6 @@ class RecommendationSummary(CamelCaseModel):
steam_friend: int
promote_suggestions: bool
community_suggestion: int



class FriendFinderState(CamelCaseModel):
Expand All @@ -239,12 +239,14 @@ class FriendFinderState(CamelCaseModel):
you_tube_opt_in_status: str
you_tube_token_status: str


class FriendRequestSummary(CamelCaseModel):
friend_requests_received_count: int


class PeopleResponse(CamelCaseModel):
people: list[Person]
recommendation_summary: RecommendationSummary | None = None
friend_finder_state: FriendFinderState | None = None
account_link_details: list[LinkedAccount] | None = None
friend_request_summary: FriendRequestSummary | None = None
friend_request_summary: FriendRequestSummary | None = None
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/presence/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Presence - Get online status of friends
"""

from typing import List

from xbox.webapi.api.provider.baseprovider import BaseProvider
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/profile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Get Userprofiles by XUID or Gamertag
"""

from typing import List

from xbox.webapi.api.provider.ratelimitedprovider import RateLimitedProvider
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/screenshots/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Screenshots - Get screenshot info
"""

from xbox.webapi.api.provider.baseprovider import BaseProvider
from xbox.webapi.api.provider.screenshots.models import ScreenshotResponse

Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/smartglass/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
SmartGlass - Control Registered Devices
"""

from typing import List, Optional
from uuid import uuid4

Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/titlehub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Titlehub - Get Title history and info
"""

from typing import List, Optional

from xbox.webapi.api.provider.baseprovider import BaseProvider
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/usersearch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Usersearch - Search for gamertags / userprofiles
"""

from xbox.webapi.api.provider.baseprovider import BaseProvider
from xbox.webapi.api.provider.usersearch.models import UserSearchResponse

Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/api/provider/userstats/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Userstats - Get game statistics
"""

from typing import List, Optional

from xbox.webapi.api.provider.ratelimitedprovider import RateLimitedProvider
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/authentication/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Authenticate with Windows Live Server and Xbox Live.
"""

import logging
from typing import List, Optional

Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/authentication/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Authentication Models."""

from datetime import datetime, timedelta, timezone
from typing import Dict, List, Optional

Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/authentication/xal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Authenticate with Windows Live Server and Xbox Live (used by mobile Xbox Apps)
"""

import base64
import hashlib
import logging
Expand Down
1 change: 0 additions & 1 deletion xbox/webapi/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Special Exception subclasses
"""


from xbox.webapi.common.ratelimits import RateLimit


Expand Down
4 changes: 2 additions & 2 deletions xbox/webapi/common/filetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Tools to convert between Python datetime instances and Microsoft times.
"""
"""Tools to convert between Python datetime instances and Microsoft times."""

from calendar import timegm
from datetime import datetime, timezone, tzinfo, timedelta

Expand Down
13 changes: 10 additions & 3 deletions xbox/webapi/common/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base Models."""

from pydantic import ConfigDict, BaseModel


Expand All @@ -16,12 +17,18 @@ def to_lower(string):


class PascalCaseModel(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, alias_generator=to_pascal)
model_config = ConfigDict(
arbitrary_types_allowed=True, populate_by_name=True, alias_generator=to_pascal
)


class CamelCaseModel(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, alias_generator=to_camel)
model_config = ConfigDict(
arbitrary_types_allowed=True, populate_by_name=True, alias_generator=to_camel
)


class LowerCaseModel(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, alias_generator=to_lower)
model_config = ConfigDict(
arbitrary_types_allowed=True, populate_by_name=True, alias_generator=to_lower
)
1 change: 1 addition & 0 deletions xbox/webapi/common/request_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Employed for generating the "Signature" header in authentication requests.
"""

import base64
from datetime import datetime, timezone
import hashlib
Expand Down
2 changes: 1 addition & 1 deletion xbox/webapi/common/signed_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class SignedSession(httpx.AsyncClient):
def __init__(self, request_signer=None, ssl_context: SSLContext=None):
def __init__(self, request_signer=None, ssl_context: SSLContext = None):
super().__init__(verify=ssl_context if ssl_context is not None else True)

self.request_signer = request_signer or RequestSigner()
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/scripts/authenticate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Example scripts that performs XBL authentication
"""

import argparse
import asyncio
import http.server
Expand Down
1 change: 1 addition & 0 deletions xbox/webapi/scripts/change_gamertag.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Example script that enables using your one-time-free gamertag change
"""

import argparse
import asyncio
import os
Expand Down
Loading
Loading