mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Fix: [ALAS] Revise serial as fool-proof
This commit is contained in:
parent
e4e5d8d558
commit
51348e7e30
@ -49,15 +49,38 @@ class ConnectionAttr:
|
|||||||
self.serial_check()
|
self.serial_check()
|
||||||
self.config.DEVICE_OVER_HTTP = self.is_over_http
|
self.config.DEVICE_OVER_HTTP = self.is_over_http
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def revise_serial(serial):
|
||||||
|
serial = serial.replace(' ', '')
|
||||||
|
# 127。0。0。1:5555
|
||||||
|
serial = serial.replace('。', '.').replace(',', '.').replace(',', '.').replace(':', ':')
|
||||||
|
# 127.0.0.1.5555
|
||||||
|
serial = serial.replace('127.0.0.1.', '127.0.0.1:')
|
||||||
|
# 16384
|
||||||
|
try:
|
||||||
|
port = int(serial)
|
||||||
|
if 1000 < port < 65536:
|
||||||
|
serial = f'127.0.0.1:{port}'
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
# 夜神模拟器 127.0.0.1:62001
|
||||||
|
if '模拟' in serial:
|
||||||
|
res = re.search(r'(\d+\.\d+\.\d+\.\d+:\d+)', serial)
|
||||||
|
if res:
|
||||||
|
serial = res.group(1)
|
||||||
|
return str(serial)
|
||||||
|
|
||||||
def serial_check(self):
|
def serial_check(self):
|
||||||
"""
|
"""
|
||||||
serial check
|
serial check
|
||||||
"""
|
"""
|
||||||
# Chinese colon
|
# fool-proof
|
||||||
if ':' in self.serial:
|
new = self.revise_serial(self.serial)
|
||||||
self.serial = self.serial.replace(':', ':')
|
if new != self.serial:
|
||||||
logger.warning(f'Serial {self.config.Emulator_Serial} is revised to {self.serial}')
|
logger.warning(f'Serial "{self.config.Emulator_Serial}" is revised to "{new}"')
|
||||||
self.config.Emulator_Serial = self.serial
|
self.config.Emulator_Serial = new
|
||||||
|
self.serial = new
|
||||||
if self.is_bluestacks4_hyperv:
|
if self.is_bluestacks4_hyperv:
|
||||||
self.serial = self.find_bluestacks4_hyperv(self.serial)
|
self.serial = self.find_bluestacks4_hyperv(self.serial)
|
||||||
if self.is_bluestacks5_hyperv:
|
if self.is_bluestacks5_hyperv:
|
||||||
|
Loading…
Reference in New Issue
Block a user