@@ -105,7 +105,9 @@ def list_firmwares(region: str, model: str):
105105 # Check if model is correct by checking the "versioninfo" key.
106106 if "versioninfo" in req :
107107 # Parse latest firmware version.
108- latest = Constants .parse_firmware (req ["versioninfo" ]["firmware" ]["version" ]["latest" ]["#text" ])
108+ l = req ["versioninfo" ]["firmware" ]["version" ]["latest" ]
109+ # If the latest field is dictionary, get the inner text, otherwise get its value directly.
110+ latest = Constants .parse_firmware (l if isinstance (l , str ) else l ["#text" ])
109111 # Parse alternate firmware version.
110112 # If none, it will return a empty list.
111113 alternate = [Constants .parse_firmware (x ["#text" ]) for x in req ["versioninfo" ]["firmware" ]["version" ]["upgrade" ]["value" ] or []]
@@ -158,6 +160,7 @@ def get_binary_details(region: str, model: str, firmware: str):
158160 "size" : int (r ["FUSMsg" ]["FUSBody" ]["Put" ]["BINARY_BYTE_SIZE" ]["Data" ]),
159161 "filename" : r ["FUSMsg" ]["FUSBody" ]["Put" ]["BINARY_NAME" ]["Data" ],
160162 "path" : r ["FUSMsg" ]["FUSBody" ]["Put" ]["MODEL_PATH" ]["Data" ],
163+ "version" : r ["FUSMsg" ]["FUSBody" ]["Put" ]["CURRENT_OS_VERSION" ]["Data" ].replace ("(" , " (" ),
161164 # "crc": r["FUSMsg"]["FUSBody"]["Put"]["BINARY_CRC"]["Data"],
162165 # CRC won't be included until the issue has resolved.
163166 # https://github.com/ysfchn/SamFetch/issues/1
@@ -188,7 +191,7 @@ def get_binary_details(region: str, model: str, firmware: str):
188191def download_binary (filename : str , path : str , decrypt_key : str ):
189192 """
190193 Downloads the firmware and decrypts the file during download automatically.\n
191- **Do not try the endpoint in the interactive API docs, because as it returns a file it doesn't work in OpenAPI.**
194+ **Do not try the endpoint in the interactive API docs, because as it returns a file, it doesn't work in OpenAPI.**
192195 """
193196 # Create new keyholder.
194197 key = Keyholder .from_response (requests .post (Constants .NONCE_URL , headers = Constants .HEADERS ()))
@@ -236,7 +239,7 @@ def automatic_download(region: str, model: str):
236239 """
237240 Executes all required endpoints and directly starts dowloading the latest firmware with one call.\n
238241 It is useful for end-users who don't want to integrate the API in a client app.\n
239- **Do not try the endpoint in the interactive API docs, because as it returns a file it doesn't work in OpenAPI.**
242+ **Do not try the endpoint in the interactive API docs, because as it returns a file, it doesn't work in OpenAPI.**
240243 """
241244 version = list_firmwares (region , model )
242245 binary = get_binary_details (region , model , version ["latest" ])
0 commit comments