Skip to content

Commit a0b6802

Browse files
committed
Linting
1 parent 6a1bfb4 commit a0b6802

11 files changed

+55
-23
lines changed

xcloud/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""
22
Init
3-
"""
3+
"""

xcloud/auth/models.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from pydantic import BaseModel
22
from typing import Dict, List, Optional
3-
from .constants import XalAppId, XalTitleId, XalRedirectUri,\
4-
XalQueryDisplay, XalDeviceType, XalUserAgents
53

64

75
class XADDisplayClaims(BaseModel):

xcloud/auth/signed_session.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
A wrapper around httpx' AsyncClient which transparently calculates the "Signature" header.
55
"""
66

7-
import asyncio
87
import httpx
98
from .request_signer import RequestSigner
109

xcloud/auth/xal_auth.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import base64
88
import hashlib
99
import json
10-
import asyncio
1110
import httpx
1211
from urllib import parse
1312
from typing import Optional, Tuple

xcloud/protocol/packets.py

+25-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"""
55
Payload types
66
"""
7+
8+
79
class PayloadType(Enum):
810
MuxDCTChannelRangeDefault = 0x23
911
MuxDCTChannelRangeEnd = 0x3f
@@ -17,10 +19,12 @@ class PayloadType(Enum):
1719
URCPDummyPacket = 0x68
1820
MockUDPDctCtrl = 0x7f
1921

22+
2023
"""
2124
Video Channel
2225
"""
2326

27+
2428
class VideoControlFlags:
2529
LAST_DISPLAYED_FRAME = 0x01
2630
LOST_FRAMES = 0x02
@@ -31,9 +35,11 @@ class VideoControlFlags:
3135
LAST_DISPLAYED_FRAME_RENDERED = 0x80
3236
SMOOTH_RENDERING_SETTINGS_SENT = 0x1000
3337

38+
3439
video_format = Struct(
3540
)
3641

42+
3743
video_server_handshake = Struct(
3844
'protocol_version' / Int32ul,
3945
'screen_width' / Int32ul,
@@ -42,19 +48,22 @@ class VideoControlFlags:
4248
'formats' / PrefixedArray(Int32ul, video_format)
4349
)
4450

51+
4552
video_client_handshake = Struct(
4653
'initial_frame_id' / Int32ul,
4754
'requested_format' / video_format
4855
)
4956

57+
5058
video_control = Struct(
51-
'flags' / Int32ul, # see VideoControlFlags
52-
'last_displayed_frame' / Int32ul, # if(flags << 31)
53-
'last_displayed_frame_rendered' / Int32ul, # if(flags & 0x80)
54-
'lost_frames' / Array(2, Int32ul), # if (flags & 2)
55-
'queue_depth' / Int32ul, # if(flags & 4)
59+
'flags' / Int32ul, # see VideoControlFlags
60+
'last_displayed_frame' / Int32ul, # if(flags << 31)
61+
'last_displayed_frame_rendered' / Int32ul, # if(flags & 0x80)
62+
'lost_frames' / Array(2, Int32ul), # if (flags & 2)
63+
'queue_depth' / Int32ul, # if(flags & 4)
5664
)
5765

66+
5867
video_data = Struct(
5968
'flags' / Int32ul,
6069
'frame_id' / Int32ul,
@@ -65,9 +74,11 @@ class VideoControlFlags:
6574
'data' / Bytes(this.data_size)
6675
)
6776

77+
6878
class QosControlFlags:
6979
REINITIALIZE = 0x1
7080

81+
7182
qos_server_policy = Struct(
7283
'schema_version' / Int32ul,
7384
'policy_length' / Int32ul,
@@ -76,36 +87,44 @@ class QosControlFlags:
7687
'fragment_size' / Int32ul
7788
)
7889

90+
7991
qos_server_handshake = Struct(
8092
'protocol_version' / Int32ul,
8193
'min_supported_client_version' / Int32ul
8294
)
8395

96+
8497
qos_client_policy = Struct(
8598
'schema_version' / Int32ul
8699
)
87100

101+
88102
qos_client_handshake = Struct(
89103
'protocol_version' / Int32ul,
90104
'initial_frame_id' / Int32ul
91105
)
92106

107+
93108
qos_control = Struct(
94109
'flags' / Int32ul
95110
)
96111

112+
97113
qos_data = Struct(
98114
'flags' / Int32ul,
99115
'frame_id' / Int32ul,
100116
# TBD
101117
)
102118

119+
103120
"""
104121
Control Protocol
105122
"""
123+
124+
106125
class ControlProtocolMessageOpCode(Enum):
107126
Auth = 0x1
108127
AuthComplete = 0x2
109128
Config = 0x3
110129
ControllerChange = 0x4
111-
Config2 = 0x6
130+
Config2 = 0x6

xcloud/scripts/client.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ..common import AppConfiguration
88

99
from ..auth.constants import IOS_XBOXBETA_APP_PARAMS, ANDROID_GAMEPASS_BETA_PARAMS
10-
from ..auth.models import XalClientParameters, XSTSResponse
10+
from ..auth.models import XalClientParameters
1111
from ..auth.xal_auth import XalAuthenticator
1212
from ..auth.request_signer import RequestSigner
1313

@@ -18,6 +18,7 @@
1818
APP_CONFIG_XBOXBETA_FILE = "appconfig.xboxbeta.json"
1919
APP_CONFIG_XBOXGAMEPASS_FILE = "appconfig.xboxgamepass.json"
2020

21+
2122
def choose_console(console_list):
2223
print('Please choose a console:')
2324
for index, c in enumerate(console_list.result):
@@ -165,6 +166,7 @@ async def async_main(command: str):
165166
elif command == 'xcloud':
166167
await test_xcloud_streaming(config)
167168

169+
168170
def main():
169171
if len(sys.argv) < 2:
170172
print(':: Please provide a command! Choices: smartglass, xhome, xcloud')
@@ -177,5 +179,6 @@ def main():
177179

178180
asyncio.run(async_main(command))
179181

182+
180183
if __name__ == '__main__':
181184
main()

xcloud/scripts/pcap_reader.py

+3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"""
44
import argparse
55

6+
67
def parse_file(filepath: str) -> None:
78
print(f"hello -> {filepath}")
89

10+
911
def main():
1012
parser = argparse.ArgumentParser(
1113
"XCloud PCAP parser",
@@ -16,5 +18,6 @@ def main():
1618

1719
parse_file(args.filepath)
1820

21+
1922
if __name__ == "__main__":
2023
main()

xcloud/smartglass_api.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import asyncio
21
import httpx
32
import uuid
4-
from typing import Optional, Union, List
3+
from typing import Optional, List
54

65
import ms_cv
7-
from .auth.models import SisuAuthorizationResponse, XSTSResponse
6+
from .auth.models import XSTSResponse
87
from .auth.signed_session import SignedSession
98
from .auth.request_signer import RequestSigner
109

@@ -39,7 +38,7 @@ async def fetch_operation_status(
3938
operation_id: str,
4039
device_id: str
4140
) -> OperationStatusResponse:
42-
url = f'https://xccs.xboxlive.com/opStatus'
41+
url = 'https://xccs.xboxlive.com/opStatus'
4342
headers = {
4443
'MS-CV': self.cv.increment(),
4544
'x-xbl-contract-version': '3',
@@ -103,7 +102,7 @@ async def _send_command(
103102
if not parameters:
104103
parameters = [{}]
105104

106-
url = f'https://xccs.xboxlive.com/commands'
105+
url = 'https://xccs.xboxlive.com/commands'
107106
headers = {
108107
'MS-CV': self.cv.increment()
109108
}

xcloud/xcloud_api.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
StreamStateResponse, StreamConfig, StreamSetupState
1111
from .xcloud_models import TitlesResponse, TitleWaitTimeResponse, CloudGameTitle
1212

13-
USER_AGENT_ANDROID = '{"conn":{"cell":{"carrier":"congstar","mcc":"262","mnc":"01","networkDetail":"{\"ci\":\"unknown\",\"pci\":\"unknown\",\"rat\":\"unknown\",\"signalStrengthDbm\":\"-2147483648\",\"pilotPowerSignalQuality\":\"-2147483648\",\"snr\":\"-2147483648\"}","roaming":"NotRoaming","strengthPct":100},"type":"Wifi","wifi":{"freq":5300,"strengthDbm":-60,"strengthPct":88}},"dev":{"hw":{"make":"Google","model":"Pixel 3a"},"os":{"name":"Android","ver":"11-RP1A.200720.009-30"}}}'
13+
USER_AGENT_ANDROID = (
14+
'{"conn":{"cell":{"carrier":"congstar","mcc":"262","mnc":"01","networkDetail":"{\"ci\":\"unknown\",\"pci\":\"unknown\",'
15+
'\"rat\":\"unknown\",\"signalStrengthDbm\":\"-2147483648\",\"pilotPowerSignalQuality\":\"-2147483648\",\"snr\":'
16+
'\"-2147483648\"}","roaming":"NotRoaming","strengthPct":100},"type":"Wifi","wifi":{"freq":5300,"strengthDbm":-60,'
17+
'"strengthPct":88}},"dev":{"hw":{"make":"Google","model":"Pixel 3a"},"os":{"name":"Android","ver":'
18+
'"11-RP1A.200720.009-30"}}}'
19+
)
1420

1521

1622
class XCloudApi:

xcloud/xcloud_models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ class TitlesResponse(BaseModel):
3333
class TitleWaitTimeResponse(BaseModel):
3434
estimatedProvisioningTimeInSeconds: int
3535
estimatedAllocationTimeInSeconds: int
36-
estimatedTotalWaitTimeInSeconds: int
36+
estimatedTotalWaitTimeInSeconds: int

xcloud/xhomestreaming_api.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@
1212
from .streaming_models import StreamLoginResponse, StreamSessionResponse, \
1313
StreamStateResponse, StreamConfig, StreamICEConfig
1414

15-
USER_AGENT_IOS = '{"conn":{"cell":{"carrier":"","mcc":"","mnc":"","networkDetail":"","roaming":"Unknown","strengthPct":-1},"type":"Wifi","wifi":{"freq":-2147483648,"strengthDbm":-2147483648,"strengthPct":-1}},"dev":{"hw":{"make":"Apple","model":"iPad6,11"},"os":{"name":"iOS","ver":"14.0.1 (Build 18A393)"}}}'
16-
USER_AGENT_ANDROID = '{"conn":{"cell":{"carrier":"","mcc":"unknown","mnc":"unknown","strengthPct":0},"type":"Wifi","wifi":{"freq":2417,"strengthDbm":-47,"strengthPct":100}},"dev":{"hw":{"make":"amzn","model":"Fire"},"os":{"name":"Android","ver":"7.1.2-NJH47F-25"}}}'
15+
USER_AGENT_IOS = (
16+
'{"conn":{"cell":{"carrier":"","mcc":"","mnc":"","networkDetail":"","roaming":"Unknown","strengthPct":-1},'
17+
'"type":"Wifi","wifi":{"freq":-2147483648,"strengthDbm":-2147483648,"strengthPct":-1}},"dev":{"hw":{"make"'
18+
':"Apple","model":"iPad6,11"},"os":{"name":"iOS","ver":"14.0.1 (Build 18A393)"}}}'
19+
)
20+
USER_AGENT_ANDROID = (
21+
'{"conn":{"cell":{"carrier":"","mcc":"unknown","mnc":"unknown","strengthPct":0},"type":"Wifi","wifi":{"freq":'
22+
'2417,"strengthDbm":-47,"strengthPct":100}},"dev":{"hw":{"make":"amzn","model":"Fire"},"os":{"name":"Android",'
23+
'"ver":"7.1.2-NJH47F-25"}}}'
24+
)
1725

1826

1927
class XHomeStreamingApi:
@@ -205,5 +213,3 @@ async def start_streaming(self, console_liveid: str):
205213

206214
print(':: Closing stream again')
207215
await self._stop_stream(base_url, stream_session_info.sessionPath)
208-
209-

0 commit comments

Comments
 (0)