如何从 Steam 构建页面提取构建号,以便使用批处理与旧版本进行比较

问题描述 投票:0回答:1

我正在尝试找到一种方法从 Steam 构建页面中提取构建号,以与我正在使用批处理制作的更新脚本的旧版本进行比较

公共分支的构建位于 ln 1 col 5944 上的这部分之后,并在 5802 处结束

"public": {"buildid": "13585476",

构建 ID 似乎总是出现在

"public": {"buildid": 

之后

完整文件。您可以使用 https://api.steamcmd.net/v1/info/%SteamGameID%

获取此信息
{"data": {"2394010": {"_change_number": 22640295, "_missing_token": false, "_sha": "a53f484e47f19ca659e1c71d5aa57d864417e986", "_size": 7299, "appid": "2394010", "common": {"associations": {}, "clienticon": "22a20bdaa6d782f60caa45eb7b02fc2411dcd988", "clienttga": "2032a63848f1ab00b518b7e984bd533c1ce0cf07", "gameid": "2394010", "icon": "606e637a2f0610f3805893e917c0e22d1d043ba6", "linuxclienticon": "d26e2c064a36a71a1ae404a0fc9bef6c2182f611", "name": "Palworld Dedicated Server", "osarch": "64", "osextended": "", "oslist": "windows,linux", "parent": "1623730", "releasestate": "released", "type": "Tool"}, "config": {"installdir": "PalServer", "launch": {"0": {"arguments": "-useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS", "config": {"oslist": "windows"}, "executable": "PalServer.exe", "type": "default"}, "1": {"arguments": "EpicApp=PalServer -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS -publiclobby", "config": {"oslist": "linux"}, "executable": "PalServer.sh", "type": "default"}, "2": {"arguments": "-publiclobby -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS -publiclobby", "description": "Open and start as a community server", "description_loc": {"english": "Open and start as a community server"}, "executable": "PalServer.exe"}}}, "depots": {"1004": {"config": {"oslist": "windows"}, "depotfromapp": "1007", "manifests": {"public": {"download": "13804528", "gid": "1923798258558304932", "size": "44194776"}}}, "1005": {"config": {"oslist": "macos"}, "depotfromapp": "1007", "manifests": {"public": {"download": "0", "gid": "2135359612286175146", "size": "0"}}}, "1006": {"config": {"oslist": "linux"}, "depotfromapp": "1007", "manifests": {"public": {"download": "20270768", "gid": "4884950798805348056", "size": "73781292"}}}, "228989": {"config": {"oslist": "windows"}, "depotfromapp": "228980", "sharedinstall": "1"}, "2394011": {"config": {"osarch": "64", "oslist": "windows"}, "encryptedmanifests": {"main_development": {"download": "341FA01F9A87AD891BA3709EAFB9A7E6", "gid": "FE9CA32D71E548C25B1EBB4A24DFC5E7", "size": "C5BBA3F56B0BCA37774475F6EDCD6CB9"}, "main_shipping": {"download": "610DC1B95EADDC9C91DF8134231538C4", "gid": "5ED9E008B260439F1D1A43609558C967", "size": "3F8B2BC51DFEC0F7FA16D681DFBBD91E"}, "main_test": {"download": "592660B08414491EB6D96370DF42158A", "gid": "4E7680D483F0E28EE3E0ECAEF9991A93", "size": "CAADBAF84ADD02975621E610827B1638"}, "network_development": {"download": "DBE5538D1DEA6D0C10EE0054614FBB57", "gid": "2338407EB8ACAD99DA90CE5F4A0F86F3", "size": "41D370410D056EAEED1A127F0F8823E3"}, "network_test": {"download": "6452A19273C8CF809D3D1800F116CF00", "gid": "8A82B817F933C870266A79E2AA0345D7", "size": "F70FF4142E90B7FA34C4A536D65B2C22"}, "private_development": {"download": "D7276975F8C8B53B508882EBB3B40618", "gid": "A30D9A1E29AD71D3C37E49828F3A190D", "size": "47C01C7FABCD626EAFB48C47AC29B930"}, "private_shipping": {"download": "B8AAF1B532A86E41F89964CF4BD3F43A", "gid": "F97AC8AD4BA0AA632F61C873DBC64B35", "size": "BC4DE2102642AFF2F45FAC54FE97693C"}, "private_test": {"download": "0AA9FF39E3132D7EFA973E99FD4D889E", "gid": "B5B2B88312687534C8F1B80017C76071", "size": "1D5E544819961A033AA160D72B248A34"}, "qa_development": {"download": "4D53D9A9132F852382DF8DC133FA01FA", "gid": "CE6AAD76E2838708E977B087A6862450", "size": "76BD9BB88B98FA27C6E8859310A5DA4B"}, "qa_test": {"download": "BBD773C3CBB007BF410823A4A479812C", "gid": "4FA6EEA7176D5497935E8DAC6DC8521D", "size": "3D5A6671D63CF35AE677F4960666DD52"}}, "manifests": {"public": {"download": "1817329616", "gid": "3909453160250477875", "size": "2634379082"}}}, "2394012": {"config": {"osarch": "64", "oslist": "linux"}, "encryptedmanifests": {"main_development": {"download": "CAA40DFB627C248E2B861C1A959B78A0", "gid": "C4B345F653E69D3A8D824B3BDCDF6E45", "size": "FDD9D947C6EE76F4B043B013A4EC8578"}, "main_shipping": {"download": "0637954CC4E1D3839705757210554002", "gid": "493D3221D9FD8EA90B453139F508965D", "size": "9D879F3A6F3686B5B3FAA8DE4B9C80E8"}, "main_test": {"download": "A5BF2F1DA37AA157900E9FB4423DE1AB", "gid": "2BFBF75618C682A2438F19E21B298263", "size": "19B92E209D5C2465D5DA4F1E82D2C76C"}, "network_development": {"download": "7CDB8D38354AF29FE19A1FB94BBF2902", "gid": "879E66D8EC6DE5683690429053175379", "size": "9A65782E2232060642D92271F5EC695A"}, "network_test": {"download": "9F0239BB70A1ADA0A24E78301F93FB33", "gid": "B8EA804B5ACA6856F0735038597E6CC0", "size": "F24EA35AC6987754788924BADECB39B9"}, "private_development": {"download": "692ABD6B9472B5A1D143ADA52EDE5334", "gid": "6DE562F362D22CA783D022757067F78B", "size": "8A2F1FE55B244C3472FF0A049A9C86F2"}, "private_test": {"download": "A9E09B6BF978C5BB07CB08A143B487C9", "gid": "317EE013A2FF2D90CAD8BE7D9C420B5F", "size": "B901FB67C3C0BBAA273DD2E85B696B45"}, "qa_development": {"download": "C732C52909434FCB875C53A88C013DFA", "gid": "504868BEFC6BEE793B90919E672CC3E1", "size": "8CEF75E9C0AF17DEBECDABDE7E63C490"}, "qa_test": {"download": "57C6D3EE16B08BB0688FEC9BBCE8F58E", "gid": "8ED372EE2B84DB361561EBB6C5ED35AF", "size": "103A73CA89295C0A46563FFD4AE9DA0C"}}, "manifests": {"public": {"download": "1708620368", "gid": "2815085007637542021", "size": "2187203282"}}}, "branches": {"main_development": {"buildid": "13644213", "pwdrequired": "1", "timeupdated": "1709634739"}, "main_shipping": {"buildid": "13644092", "pwdrequired": "1", "timeupdated": "1709633869"}, "main_test": {"buildid": "13644302", "pwdrequired": "1", "timeupdated": "1709635395"}, "network_development": {"buildid": "13162989", "pwdrequired": "1", "timeupdated": "1705119306"}, "network_test": {"buildid": "13162940", "pwdrequired": "1", "timeupdated": "1705118469"}, "private_development": {"buildid": "13646268", "pwdrequired": "1", "timeupdated": "1709647875"}, "private_shipping": {"buildid": "12344676", "pwdrequired": "1", "timeupdated": "1696342174"}, "private_test": {"buildid": "13646174", "pwdrequired": "1", "timeupdated": "1709647293"}, "public": {"buildid": "13585476", "timeupdated": "1709170119"}, "qa_development": {"buildid": "13585483", "pwdrequired": "1", "timeupdated": "1709607496"}, "qa_test": {"buildid": "13585476", "pwdrequired": "1", "timeupdated": "1709607431"}}}, "extended": {"gamedir": "Palworld", "serverbrowsername": "Palworld"}}}, "status": "success"}

我尝试过的大多数方法都不起作用,搜索一个单词然后再搜索一个单词也不起作用,因为文件中有多个 BuildID,而且我无法搜索 "public": {"buildid": " 然后获得了构建 ID

batch-file
1个回答
0
投票
@ECHO OFF
SETLOCAL enabledelayedexpansion
rem The following settings for the directory and filename are names
rem that I use for testing and deliberately includes spaces to make sure
rem that the process works using such names. These will need to be changed to suit your situation.

SET "sourcedir=u:\your files"
SET "filename1=%sourcedir%\q78118427.txt"

SET "public="
SET "buildid="
SET "required="

FOR /f "usebackqdelims=" %%e IN ("%filename1%") DO (
 SET "line=%%e"
 SET "line=!line::= !"
 SET "line=!line:{= !"
 SET "line=!line:}= !"
 FOR %%y IN (!line!) DO (
  IF DEFINED public IF DEFINED buildid IF NOT DEFINED required SET "required=%%~y"
  IF "%%~y"=="public" (SET "public=Y"&SET "buildid=") ELSE (
   IF "%%~y"=="buildid" (
    IF DEFINED public (SET "buildid=Y") ELSE (SET "public="&SET "buildid=")
   )
  )
 )
)

ECHO required data: "%required%"

GOTO :EOF

请注意,如果文件名不包含空格等分隔符,则

usebackq
%filename1%
周围的引号都可以省略。

抓取

%%e
中出现的数据行并记录为
line

使用

:
将每个
{
}
delayedexpansion
替换为空格,因为您无法直接操作
%%e
。这会生成一个字符串,可以将其作为一系列空格或逗号分隔的标记进行处理。

将每个取消引用的标记与两个密钥字符串进行比较。仅当找到序列

public
buildid
时,变量
public
buildid
才会被设置为非空(即“已定义”)

我们需要在设置这两个标志之后立即出现的字符串。

© www.soinside.com 2019 - 2024. All rights reserved.