Jump to content
McKay Development

Auto-Download games functionality, posible?


Manzanitox

Recommended Posts

Hi Dr.Mackay, first of all thanks for your library and the hard work you've done ^_^ .

 

I've been thinking about making a project which would need to auto-download game from the user library, by this i mean, i could sign in through steam, and use your library to get all game info, would be possible to automate the process of downloading the game into imagine, a remote server without having to interact to a UI Steam client directly? Another think would be interesting is to interact with updates in games, by knowing what games require updates before an instance could be launched in the machine that previously has downloaded the game. All of this in case the first one is even possible, don't know if a future feature in your lib could fit or if i'm speaking about other completely thing, hope not  :D.

 

Sorry for my English, i'm not native and again thanks for your time!

Link to comment
Share on other sites

Nope. This library simply executes web requests (or protobufs) and handles cookies etc. It could technically do it but I doubt that itll be added since it's not something steam's server does, the library would have to do a lot more too

Edited by timgfx
Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...

I've been trying to create an app that can do this, but I've been running against weird errors. I'll share the code with the hope that dr. mckay or someone else can assist me into getting this to work.

const fs = require("fs");
const path = require("path");
const mkdirp = require("mkdirp");
const SteamUser = require("steam-user");

const client = new SteamUser();

// ...
// login
// ...

client.on("contentServersReady", function() {
    downloadGame(207140);
    //doManifest(480, 481, "840604261173631294", path.join(__dirname, "480"));
});

function downloadGame(appid) {
    client.getProductInfo([+appid], [], true, apps => {
        for (let appid in apps) {
            const app = apps[appid].appinfo;
            const depots = Object.keys(app.depots).filter(id => !isNaN(parseInt(id)));
            depots.forEach(depotid => {
                const depot = app.depots[depotid];
                if (depot.manifests) {
                    doManifest(appid, depotid, depot.manifests.public, path.join(__dirname, appid));
                } else if (depot.depotfromapp) {
                    client.getProductInfo([+depot.depotfromapp], [], true, apps => {
                        const a = apps[depot.depotfromapp].appinfo;
                        const d = Object.keys(a.depots).filter(id => !isNaN(parseInt(id)));
                        if (d.manifests) {
                            doManifest(depot.depotfromapp, depotid, d.manifests.public, path.join(__dirname, appid));
                        }
                    });
                }
            });
        }
    });
}

function doManifest(appid, depotid, manifestid, savefolder) { // 480, 481, "840604261173631294", "480"
    client.getManifest(+appid, +depotid, manifestid.toString(), (error, manifest) => {
        if (error) {
            console.log(error);
            return;
        }

        //console.log(JSON.stringify(manifest, null, 4));
        const files = manifest.files;

        if (files) dlFile();

        function dlFile() {
            if (files.length > 0) {
                const file = files.shift();
                const filepath = path.join(savefolder, file.filename);
                console.log(filepath);
                mkdirp(path.dirname(filepath), error => {
                    if (error) {
                        console.log(error);
                    }

                    client.downloadFile(+appid, +depotid, file, filepath.toString(), error => {
                        if (error) {
                            console.log(error);
                        }
                        dlFile();
                    });
                });
            }
        }
    });
}

Running downloadGame(207140) gives this result:

[20-07-2018 16:13:59.306] Logged into Steam
[20-07-2018 16:13:59.913] 8088499558260683951
[20-07-2018 16:14:01.104] .\steam-downloader\207140\_CommonRedist\XNA\4.0\installscript.vdf
[20-07-2018 16:14:01.106] .\steam-downloader\207140\_CommonRedist\vcredist\2012\installscript.vdf
[20-07-2018 16:14:01.107] .\steam-downloader\207140\_CommonRedist\DotNet\4.0\Microsoft .NET Framework 4.0.cmd
[20-07-2018 16:14:01.549] .\steam-downloader\207140\Content\UI\MultiplayerHUD\Progression\Award_frame.xnb
[20-07-2018 16:14:02.315] .\steam-downloader\207140\Content\Sprites\Deco\Festival\Background.xnb
buffer.js:851
    throw new RangeError('Index out of range');
    ^

RangeError: Index out of range
    at checkOffset (buffer.js:851:11)
    at Buffer.readUInt32LE (buffer.js:913:5)
    at .\node_modules\steam-user\components\cdn.js:80:52
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:439:3)

Link to comment
Share on other sites

Other errors when trying to download a game:

// ...
.\49520\steamassets\dlc\nasturtium\lic\audio\italian\audio_streaming_nasturtium.pck
.\49520\Borderlands2.app\Contents\GameData\DLC\Sage\Lic\Audio\Spanish(Spain)\Audio_Streaming_sage.pck
.\49520\steamassets\dlc\aster\lic\audio\spanish(spain)\audio_streaming_aster.pck
Error: HTTP error 404
    at ClientRequest.<anonymous> (.\node_modules\steam-user\components\cdn.js:554:22)
    at Object.onceWrapper (events.js:293:19)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:191:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:522:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
    at Socket.socketOnData (_http_client.js:411:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
//...
{ Error: Fail
    at Object.exports.eresultError (.\node_modules\steam-user\components\helpers.js:75:12)
    at .\node_modules\steam-user\components\cdn.js:129:30
    at Object.cb (.\node_modules\steam-user\components\messages.js:174:4)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:321:26)
    at CMClient.handlers.(anonymous function) (.\node_modules\steam-client\lib\cm_client.js:603:8)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:305:24)
    at emitOne (events.js:96:13)
    at TCPConnection.emit (events.js:191:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:179:7)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:188:7) eresult: 2 }
{ Error: Fail
    at Object.exports.eresultError (.\node_modules\steam-user\components\helpers.js:75:12)
    at .\node_modules\steam-user\components\cdn.js:129:30
    at Object.cb (.\node_modules\steam-user\components\messages.js:174:4)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:321:26)
    at CMClient.handlers.(anonymous function) (.\node_modules\steam-client\lib\cm_client.js:603:8)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:305:24)
    at emitOne (events.js:96:13)
    at TCPConnection.emit (events.js:191:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:179:7)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:188:7) eresult: 2 }
{ Error: Fail
    at Object.exports.eresultError (.\node_modules\steam-user\components\helpers.js:75:12)
    at .\node_modules\steam-user\components\cdn.js:129:30
    at Object.cb (.\node_modules\steam-user\components\messages.js:174:4)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:321:26)
    at CMClient.handlers.(anonymous function) (.\node_modules\steam-client\lib\cm_client.js:603:8)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:305:24)
    at emitOne (events.js:96:13)
    at TCPConnection.emit (events.js:191:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:179:7)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:188:7) eresult: 2 }
{ Error: Fail
    at Object.exports.eresultError (.\node_modules\steam-user\components\helpers.js:75:12)
    at .\node_modules\steam-user\components\cdn.js:129:30
    at Object.cb (.\node_modules\steam-user\components\messages.js:174:4)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:321:26)
    at CMClient.handlers.(anonymous function) (.\node_modules\steam-client\lib\cm_client.js:603:8)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:305:24)
    at emitOne (events.js:96:13)
    at TCPConnection.emit (events.js:191:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:179:7)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:188:7) eresult: 2 }
//...
.\49520\steamassets\dlc\orchid\compat\localization\esn\gd_orchid_pop_raidengineeraid.esn
.\49520\DLC\POCollectors\Lic\WillowDLC.ini
.\49520\Borderlands2.app\Contents\GameData\DLC\Aster\Compat\Localization\ESN\GD_Aster_Shrines.ESN
.\node_modules\steam-user\components\cdn.js:316
        throw new Error("Cannot download a directory");
        ^

Error: Cannot download a directory
    at SteamUser.downloadFile (.\node_modules\steam-user\components\cdn.js:316:15)
    at error (.\steam-downloader\index.js:160:28)
    at .\node_modules\mkdirp\index.js:30:20
    at FSReqWrap.oncomplete (fs.js:114:15)

Only the last error was uncaught and made my program crash.

Link to comment
Share on other sites

Thank you, that resolves that problem. Do you have any idea what to do to fix these problems? Only top error was a fatal one that made the program crash, others are from console.log(error).
 

.\49520\steamassets\willowgame\cookedpcconsole\cd_assassin_skin_orangef_sf.upk
{ Error: connect ETIMEDOUT 155.133.248.24:80
    at Object.exports._errnoException (util.js:1050:11)
    at exports._exceptionWithHostPort (util.js:1073:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '155.133.248.24',
  port: 80 }
.\49520\steamassets\dlc\aster\lic\content\castleexterior_light.upk
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length
    at Decipheriv._flush (crypto.js:135:28)
    at Decipheriv.<anonymous> (_stream_transform.js:118:12)
    at Object.onceWrapper (events.js:293:19)
    at emitNone (events.js:86:13)
    at Decipheriv.emit (events.js:188:7)
    at prefinish (_stream_writable.js:500:12)
    at finishMaybe (_stream_writable.js:512:7)
    at endWritable (_stream_writable.js:520:3)
    at Decipheriv.Writable.end (_stream_writable.js:485:5)
    at Object.exports.symmetricDecrypt (.\node_modules\@doctormckay\steam-crypto\index.js:80:10)
{ Error: connect ETIMEDOUT 155.133.248.10:80
    at Object.exports._errnoException (util.js:1050:11)
    at exports._exceptionWithHostPort (util.js:1073:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '155.133.248.10',
  port: 80 }
{ Error: connect ETIMEDOUT 155.133.248.10:80
    at Object.exports._errnoException (util.js:1050:11)
    at exports._exceptionWithHostPort (util.js:1073:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '155.133.248.10',
  port: 80 }
{ Error: connect ETIMEDOUT 155.133.248.10:80
    at Object.exports._errnoException (util.js:1050:11)
    at exports._exceptionWithHostPort (util.js:1073:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '155.133.248.10',
  port: 80 }
.\49520\steamassets\dlc\lobelia\compat\content\cd_mechro_head_lobelia_sf.upk
.\49520\steamassets\dlc\aster\lic\content\dungeon_p.upk
Error: File checksum mismatch
    at Hash.<anonymous> (.\node_modules\steam-user\components\cdn.js:457:38)
    at emitNone (events.js:86:13)
    at Hash.emit (events.js:188:7)
    at emitReadable_ (_stream_readable.js:434:10)
    at emitReadable (_stream_readable.js:428:7)
    at readableAddChunk (_stream_readable.js:189:13)
    at Hash.Readable.push (_stream_readable.js:136:10)
    at Hash.Transform.push (_stream_transform.js:128:32)
    at Hash._flush (crypto.js:70:8)
    at Hash.<anonymous> (_stream_transform.js:118:12)
.\49520\steamassets
.\49520\DLC\Iris\Lic\Audio\English(US)\Audio_Banks_iris.pck
.\49520\Borderlands2.app\Contents\GameData\DLC\Sage\Compat\Localization\FRA\GD_Sage_SM_Friendship.FRA
{ Error: Fail
    at Object.exports.eresultError (.\node_modules\steam-user\components\helpers.js:75:12)
    at .\node_modules\steam-user\components\cdn.js:129:30
    at Object.cb (.\node_modules\steam-user\components\messages.js:174:4)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:321:26)
    at CMClient.handlers.(anonymous function) (.\node_modules\steam-client\lib\cm_client.js:603:8)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:305:24)
    at emitOne (events.js:96:13)
    at TCPConnection.emit (events.js:191:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:179:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:182:7) eresult: 2 }
{ Error: Fail
    at Object.exports.eresultError (.\node_modules\steam-user\components\helpers.js:75:12)
    at .\node_modules\steam-user\components\cdn.js:129:30
    at Object.cb (.\node_modules\steam-user\components\messages.js:174:4)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:321:26)
    at CMClient.handlers.(anonymous function) (.\node_modules\steam-client\lib\cm_client.js:603:8)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:305:24)
    at emitOne (events.js:96:13)
    at TCPConnection.emit (events.js:191:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:179:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:182:7) eresult: 2 }
{ Error: Fail
    at Object.exports.eresultError (.\node_modules\steam-user\components\helpers.js:75:12)
    at .\node_modules\steam-user\components\cdn.js:129:30
    at Object.cb (.\node_modules\steam-user\components\messages.js:174:4)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:321:26)
    at CMClient.handlers.(anonymous function) (.\node_modules\steam-client\lib\cm_client.js:603:8)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:305:24)
    at emitOne (events.js:96:13)
    at TCPConnection.emit (events.js:191:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:179:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:182:7) eresult: 2 }
{ Error: Fail
    at Object.exports.eresultError (.\node_modules\steam-user\components\helpers.js:75:12)
    at .\node_modules\steam-user\components\cdn.js:129:30
    at Object.cb (.\node_modules\steam-user\components\messages.js:174:4)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:321:26)
    at CMClient.handlers.(anonymous function) (.\node_modules\steam-client\lib\cm_client.js:603:8)
    at CMClient._netMsgReceived (.\node_modules\steam-client\lib\cm_client.js:305:24)
    at emitOne (events.js:96:13)
    at TCPConnection.emit (events.js:191:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:179:7)
    at TCPConnection._readPacket (.\node_modules\steam-client\lib\tcp_connection.js:182:7) eresult: 2 }
.\49520\Borderlands2.app\Contents\GameData\DLC\Aster\Lic\Audio\English(US)\Audio_Streaming_aster.pck
.\49520\DLC\Flax\Compat\Localization\KOR\GD_Flax_PumpkinHead.KOR
Edited by Royalgamer06
Link to comment
Share on other sites

That top one looks kind of like you got a corrupt chunk.

 

All your connect timeouts are likely due to CDN servers being down/slow to respond. Just retry.

 

File checksum mismatch is weird, that means the decompressed/decrypted data in the chunk didn't match the sha1 we expected.

 

And all the "Fail" errors is just Steam being Steam.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...