diff --git a/xbox/webapi/api/client.py b/xbox/webapi/api/client.py index 4276685..8bdc249 100644 --- a/xbox/webapi/api/client.py +++ b/xbox/webapi/api/client.py @@ -4,6 +4,7 @@ Basic factory that stores :class:`XboxLiveLanguage`, User authorization data and available `Providers` """ + import logging from typing import Any @@ -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() diff --git a/xbox/webapi/api/provider/achievements/__init__.py b/xbox/webapi/api/provider/achievements/__init__.py index 27111ec..b2b6759 100644 --- a/xbox/webapi/api/provider/achievements/__init__.py +++ b/xbox/webapi/api/provider/achievements/__init__.py @@ -3,6 +3,7 @@ Get Xbox 360 and Xbox One Achievement data """ + from xbox.webapi.api.provider.achievements.models import ( Achievement360ProgressResponse, Achievement360Response, diff --git a/xbox/webapi/api/provider/catalog/__init__.py b/xbox/webapi/api/provider/catalog/__init__.py index 4e7b800..0eef81a 100644 --- a/xbox/webapi/api/provider/catalog/__init__.py +++ b/xbox/webapi/api/provider/catalog/__init__.py @@ -1,6 +1,7 @@ """ Store Catalog - Lookup Product Information """ + from typing import List from xbox.webapi.api.provider.baseprovider import BaseProvider diff --git a/xbox/webapi/api/provider/catalog/const.py b/xbox/webapi/api/provider/catalog/const.py index 1e480a2..f0143d7 100644 --- a/xbox/webapi/api/provider/catalog/const.py +++ b/xbox/webapi/api/provider/catalog/const.py @@ -1,4 +1,5 @@ """Web API Constants.""" + from xbox.webapi.api.provider.catalog.models import AlternateIdType HOME_APP_IDS = { diff --git a/xbox/webapi/api/provider/catalog/models.py b/xbox/webapi/api/provider/catalog/models.py index 187290d..a4c5a65 100644 --- a/xbox/webapi/api/provider/catalog/models.py +++ b/xbox/webapi/api/provider/catalog/models.py @@ -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 @@ -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] diff --git a/xbox/webapi/api/provider/cqs/__init__.py b/xbox/webapi/api/provider/cqs/__init__.py index c6f780a..b581eca 100644 --- a/xbox/webapi/api/provider/cqs/__init__.py +++ b/xbox/webapi/api/provider/cqs/__init__.py @@ -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, diff --git a/xbox/webapi/api/provider/gameclips/__init__.py b/xbox/webapi/api/provider/gameclips/__init__.py index 1d4342b..f8ce717 100644 --- a/xbox/webapi/api/provider/gameclips/__init__.py +++ b/xbox/webapi/api/provider/gameclips/__init__.py @@ -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 diff --git a/xbox/webapi/api/provider/lists/__init__.py b/xbox/webapi/api/provider/lists/__init__.py index 7bb6062..fcfb575 100644 --- a/xbox/webapi/api/provider/lists/__init__.py +++ b/xbox/webapi/api/provider/lists/__init__.py @@ -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 diff --git a/xbox/webapi/api/provider/mediahub/__init__.py b/xbox/webapi/api/provider/mediahub/__init__.py index 05e7cfd..9870dc4 100644 --- a/xbox/webapi/api/provider/mediahub/__init__.py +++ b/xbox/webapi/api/provider/mediahub/__init__.py @@ -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, diff --git a/xbox/webapi/api/provider/message/__init__.py b/xbox/webapi/api/provider/message/__init__.py index bb7dcab..78e73f3 100644 --- a/xbox/webapi/api/provider/message/__init__.py +++ b/xbox/webapi/api/provider/message/__init__.py @@ -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, diff --git a/xbox/webapi/api/provider/people/__init__.py b/xbox/webapi/api/provider/people/__init__.py index 1d19fe1..61b1984 100644 --- a/xbox/webapi/api/provider/people/__init__.py +++ b/xbox/webapi/api/provider/people/__init__.py @@ -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"} @@ -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 @@ -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 @@ -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()) diff --git a/xbox/webapi/api/provider/people/models.py b/xbox/webapi/api/provider/people/models.py index 83190be..3769952 100644 --- a/xbox/webapi/api/provider/people/models.py +++ b/xbox/webapi/api/provider/people/models.py @@ -1,4 +1,3 @@ - from __future__ import annotations from datetime import datetime @@ -53,11 +52,13 @@ 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 @@ -65,6 +66,7 @@ class PartyDetails(CamelCaseModel): join_restriction: str accepted: int + class MultiplayerSummary(CamelCaseModel): in_multiplayer_session: int | None = None in_party: int @@ -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): @@ -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 @@ -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 @@ -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 @@ -202,7 +204,6 @@ class Person(CamelCaseModel): is_friend: bool is_friend_request_received: bool is_friend_request_sent: bool - class RecommendationSummary(CamelCaseModel): @@ -214,7 +215,6 @@ class RecommendationSummary(CamelCaseModel): steam_friend: int promote_suggestions: bool community_suggestion: int - class FriendFinderState(CamelCaseModel): @@ -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 \ No newline at end of file + friend_request_summary: FriendRequestSummary | None = None diff --git a/xbox/webapi/api/provider/presence/__init__.py b/xbox/webapi/api/provider/presence/__init__.py index d2dc526..3faa7c4 100644 --- a/xbox/webapi/api/provider/presence/__init__.py +++ b/xbox/webapi/api/provider/presence/__init__.py @@ -1,6 +1,7 @@ """ Presence - Get online status of friends """ + from typing import List from xbox.webapi.api.provider.baseprovider import BaseProvider diff --git a/xbox/webapi/api/provider/profile/__init__.py b/xbox/webapi/api/provider/profile/__init__.py index 4cce30b..b86cb5f 100644 --- a/xbox/webapi/api/provider/profile/__init__.py +++ b/xbox/webapi/api/provider/profile/__init__.py @@ -3,6 +3,7 @@ Get Userprofiles by XUID or Gamertag """ + from typing import List from xbox.webapi.api.provider.ratelimitedprovider import RateLimitedProvider diff --git a/xbox/webapi/api/provider/screenshots/__init__.py b/xbox/webapi/api/provider/screenshots/__init__.py index 6e1c5ce..4ef3229 100644 --- a/xbox/webapi/api/provider/screenshots/__init__.py +++ b/xbox/webapi/api/provider/screenshots/__init__.py @@ -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 diff --git a/xbox/webapi/api/provider/smartglass/__init__.py b/xbox/webapi/api/provider/smartglass/__init__.py index bd9505d..9ae8f61 100644 --- a/xbox/webapi/api/provider/smartglass/__init__.py +++ b/xbox/webapi/api/provider/smartglass/__init__.py @@ -1,6 +1,7 @@ """ SmartGlass - Control Registered Devices """ + from typing import List, Optional from uuid import uuid4 diff --git a/xbox/webapi/api/provider/titlehub/__init__.py b/xbox/webapi/api/provider/titlehub/__init__.py index 70ffb5d..40d65ea 100644 --- a/xbox/webapi/api/provider/titlehub/__init__.py +++ b/xbox/webapi/api/provider/titlehub/__init__.py @@ -1,6 +1,7 @@ """ Titlehub - Get Title history and info """ + from typing import List, Optional from xbox.webapi.api.provider.baseprovider import BaseProvider diff --git a/xbox/webapi/api/provider/usersearch/__init__.py b/xbox/webapi/api/provider/usersearch/__init__.py index de94f3a..882eb09 100644 --- a/xbox/webapi/api/provider/usersearch/__init__.py +++ b/xbox/webapi/api/provider/usersearch/__init__.py @@ -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 diff --git a/xbox/webapi/api/provider/userstats/__init__.py b/xbox/webapi/api/provider/userstats/__init__.py index 4ad4151..6b9299f 100644 --- a/xbox/webapi/api/provider/userstats/__init__.py +++ b/xbox/webapi/api/provider/userstats/__init__.py @@ -1,6 +1,7 @@ """ Userstats - Get game statistics """ + from typing import List, Optional from xbox.webapi.api.provider.ratelimitedprovider import RateLimitedProvider diff --git a/xbox/webapi/authentication/manager.py b/xbox/webapi/authentication/manager.py index 1552e32..c43d977 100644 --- a/xbox/webapi/authentication/manager.py +++ b/xbox/webapi/authentication/manager.py @@ -3,6 +3,7 @@ Authenticate with Windows Live Server and Xbox Live. """ + import logging from typing import List, Optional diff --git a/xbox/webapi/authentication/models.py b/xbox/webapi/authentication/models.py index 4557837..d53b610 100644 --- a/xbox/webapi/authentication/models.py +++ b/xbox/webapi/authentication/models.py @@ -1,4 +1,5 @@ """Authentication Models.""" + from datetime import datetime, timedelta, timezone from typing import Dict, List, Optional diff --git a/xbox/webapi/authentication/xal.py b/xbox/webapi/authentication/xal.py index ffb05c2..fffff22 100644 --- a/xbox/webapi/authentication/xal.py +++ b/xbox/webapi/authentication/xal.py @@ -3,6 +3,7 @@ Authenticate with Windows Live Server and Xbox Live (used by mobile Xbox Apps) """ + import base64 import hashlib import logging diff --git a/xbox/webapi/common/exceptions.py b/xbox/webapi/common/exceptions.py index 0e278e5..b3b7bd4 100644 --- a/xbox/webapi/common/exceptions.py +++ b/xbox/webapi/common/exceptions.py @@ -2,7 +2,6 @@ Special Exception subclasses """ - from xbox.webapi.common.ratelimits import RateLimit diff --git a/xbox/webapi/common/filetimes.py b/xbox/webapi/common/filetimes.py index 3dd7010..bb4b063 100644 --- a/xbox/webapi/common/filetimes.py +++ b/xbox/webapi/common/filetimes.py @@ -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 diff --git a/xbox/webapi/common/models.py b/xbox/webapi/common/models.py index d2902df..75b9a8e 100644 --- a/xbox/webapi/common/models.py +++ b/xbox/webapi/common/models.py @@ -1,4 +1,5 @@ """Base Models.""" + from pydantic import ConfigDict, BaseModel @@ -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 + ) diff --git a/xbox/webapi/common/request_signer.py b/xbox/webapi/common/request_signer.py index e556235..53e9cf9 100644 --- a/xbox/webapi/common/request_signer.py +++ b/xbox/webapi/common/request_signer.py @@ -3,6 +3,7 @@ Employed for generating the "Signature" header in authentication requests. """ + import base64 from datetime import datetime, timezone import hashlib diff --git a/xbox/webapi/common/signed_session.py b/xbox/webapi/common/signed_session.py index 6f7e904..9d35b1c 100644 --- a/xbox/webapi/common/signed_session.py +++ b/xbox/webapi/common/signed_session.py @@ -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() diff --git a/xbox/webapi/scripts/authenticate.py b/xbox/webapi/scripts/authenticate.py index 58f67cd..f822208 100644 --- a/xbox/webapi/scripts/authenticate.py +++ b/xbox/webapi/scripts/authenticate.py @@ -1,6 +1,7 @@ """ Example scripts that performs XBL authentication """ + import argparse import asyncio import http.server diff --git a/xbox/webapi/scripts/change_gamertag.py b/xbox/webapi/scripts/change_gamertag.py index ce10d49..cd6f178 100644 --- a/xbox/webapi/scripts/change_gamertag.py +++ b/xbox/webapi/scripts/change_gamertag.py @@ -1,6 +1,7 @@ """ Example script that enables using your one-time-free gamertag change """ + import argparse import asyncio import os diff --git a/xbox/webapi/scripts/friends.py b/xbox/webapi/scripts/friends.py index d5c5ed6..48d14c8 100644 --- a/xbox/webapi/scripts/friends.py +++ b/xbox/webapi/scripts/friends.py @@ -1,6 +1,7 @@ """ Example script that enables using your one-time-free gamertag change """ + import argparse import asyncio import os diff --git a/xbox/webapi/scripts/search.py b/xbox/webapi/scripts/search.py index 243169f..45e8938 100644 --- a/xbox/webapi/scripts/search.py +++ b/xbox/webapi/scripts/search.py @@ -1,6 +1,7 @@ """ Example script that utilizes EDSProvider to search XBL marketplace """ + import argparse import asyncio from pprint import pprint diff --git a/xbox/webapi/scripts/xal.py b/xbox/webapi/scripts/xal.py index 3a0b97d..4f74227 100644 --- a/xbox/webapi/scripts/xal.py +++ b/xbox/webapi/scripts/xal.py @@ -1,6 +1,7 @@ """ Example scripts that performs XBL authentication via XAL """ + import argparse import asyncio import json