79
79
import struct
80
80
import time
81
81
import yarl
82
+ import uuid
82
83
83
84
try :
84
85
import orjson # type: ignore
@@ -1740,27 +1741,30 @@ class Headers:
1740
1741
"""
1741
1742
1742
1743
FALLBACK_BUILD_NUMBER = 9999
1743
- FALLBACK_BROWSER_VERSION = 135
1744
+ FALLBACK_BROWSER_VERSION = 136
1744
1745
1745
1746
def __init__ (
1746
1747
self ,
1748
+ * ,
1747
1749
platform : Literal ['Windows' , 'macOS' , 'Linux' , 'Android' , 'iOS' ],
1748
1750
major_version : int ,
1749
1751
super_properties : Dict [str , Any ],
1750
1752
encoded_super_properties : str ,
1753
+ extra_gateway_properties : Optional [Dict [str , Any ]] = None ,
1751
1754
) -> None :
1752
1755
self .platform = platform
1753
1756
self .major_version = major_version
1754
1757
self .super_properties = super_properties
1755
1758
self .encoded_super_properties = encoded_super_properties
1759
+ self .extra_gateway_properties = extra_gateway_properties or {}
1756
1760
1757
1761
@classmethod
1758
1762
async def default (
1759
1763
cls : type [Self ], session : ClientSession
1760
1764
) -> Self :
1761
1765
"""Creates a new :class:`Headers` instance using the default fetching mechanisms."""
1762
1766
try :
1763
- properties , encoded = await asyncio .wait_for (
1767
+ properties , extra , encoded = await asyncio .wait_for (
1764
1768
cls .get_api_properties (session , 'web' ), timeout = 3
1765
1769
)
1766
1770
except Exception :
@@ -1771,6 +1775,7 @@ async def default(
1771
1775
major_version = int (properties ['browser_version' ].split ('.' )[0 ]),
1772
1776
super_properties = properties ,
1773
1777
encoded_super_properties = encoded ,
1778
+ extra_gateway_properties = extra ,
1774
1779
)
1775
1780
1776
1781
try :
@@ -1789,6 +1794,7 @@ async def default(
1789
1794
'os' : 'Windows' ,
1790
1795
'browser' : 'Chrome' ,
1791
1796
'device' : '' ,
1797
+ 'system_locale' : 'en-US' ,
1792
1798
'browser_user_agent' : cls ._get_user_agent (bv ),
1793
1799
'browser_version' : f'{ bv } .0.0.0' ,
1794
1800
'os_version' : '10' ,
@@ -1797,42 +1803,56 @@ async def default(
1797
1803
'referrer_current' : '' ,
1798
1804
'referring_domain_current' : '' ,
1799
1805
'release_channel' : 'stable' ,
1800
- 'system_locale' : 'en-US' ,
1801
1806
'client_build_number' : bn ,
1802
1807
'client_event_source' : None ,
1803
1808
'has_client_mods' : False ,
1809
+ 'client_heartbeat_session_id' : str (uuid .uuid4 ()),
1804
1810
}
1805
1811
1806
1812
return cls (
1807
1813
platform = 'Windows' ,
1808
1814
major_version = bv ,
1809
1815
super_properties = properties ,
1810
1816
encoded_super_properties = b64encode (_to_json (properties ).encode ()).decode ('utf-8' ),
1817
+ extra_gateway_properties = {
1818
+ 'client_app_state' : None ,
1819
+ 'is_fast_connect' : False ,
1820
+ },
1811
1821
)
1812
1822
1813
1823
@cached_property
1814
1824
def user_agent (self ) -> str :
1825
+ """Returns the user agent to be used for HTTP requests."""
1815
1826
return self .super_properties ['browser_user_agent' ]
1816
1827
1817
1828
@cached_property
1818
1829
def client_hints (self ) -> Dict [str , str ]:
1830
+ """Returns the client hints to be used for HTTP requests."""
1819
1831
return {
1820
1832
'Sec-CH-UA' : ', ' .join ([f'"{ brand } ";v="{ version } "' for brand , version in self .generate_brand_version_list ()]),
1821
1833
'Sec-CH-UA-Mobile' : '?1' if self .platform in ('Android' , 'iOS' ) else '?0' ,
1822
1834
'Sec-CH-UA-Platform' : f'"{ self .platform } "' ,
1823
1835
}
1824
1836
1837
+ @property
1838
+ def gateway_properties (self ) -> Dict [str , Any ]:
1839
+ """Returns the properties to be used for the Gateway."""
1840
+ return {
1841
+ ** self .super_properties ,
1842
+ ** self .extra_gateway_properties ,
1843
+ }
1844
+
1825
1845
@staticmethod
1826
1846
async def get_api_properties (
1827
1847
session : ClientSession , type : str
1828
- ) -> Tuple [Dict [str , Any ], str ]:
1848
+ ) -> Tuple [Dict [str , Any ], Dict [ str , Any ], str ]:
1829
1849
"""Fetches client properties from the API."""
1830
1850
async with session .post (
1831
1851
f'https://cordapi.dolfi.es/api/v2/properties/{ type } '
1832
1852
) as resp :
1833
1853
resp .raise_for_status ()
1834
1854
json = await resp .json ()
1835
- return json ['properties' ], json ['encoded' ]
1855
+ return json ['properties' ], json ['extra_gateway_properties' ], json [ ' encoded' ]
1836
1856
1837
1857
@staticmethod
1838
1858
async def _get_build_number (
0 commit comments