Skip to content

Commit

Permalink
Adding ability to queue one or more app IDs at once
Browse files Browse the repository at this point in the history
  • Loading branch information
ilumos committed Sep 7, 2017
1 parent 3a1894a commit 9029701
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ Automatically fill a [lancache](https://github.com/zeropingheroes/lancache) with
* Authorise a Steam account to allow download of apps in their library.
* If no account is specified, you will be prompted for the username

`steam:queue-app appid [--windows] [--osx] [--linux]`
`steam:queue-app appid [appid, appid...] [--windows] [--osx] [--linux]`

* Queue a Steam app for downloading.
* Queue one or more Steam apps for downloading.
* Optionally the platform(s) to download can be specified as options
* If no platform option is specified, the Windows version of the app will be queued

Expand Down
71 changes: 36 additions & 35 deletions src/Commands/Steam/QueueApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class QueueApp extends Command
* @var string
*/
protected $signature = 'steam:queue-app
{app_id : The ID of the app}
{app_ids* : One or more app IDs to queue}
{--windows=true : Queue the Windows version of the app}
{--osx : Queue the OS X version of the app}
{--linux : Queue the Linux version of the app}';
Expand All @@ -34,50 +34,51 @@ class QueueApp extends Command
*/
public function handle()
{
$appId = $this->argument('app_id');
$appIds = $this->argument('app_ids');

if (!$app = SteamApp::find($appId)) {
$this->error('Steam app with ID '.$this->argument('app_id').' not found');
die();
}
foreach($appIds as $appId)
{
if (!$app = SteamApp::find($appId)) {
$this->error('Steam app with ID '.$appId.' not found');
die();
}

// Add platforms depending on options
if ($this->option('windows')) {
$platforms[] = 'windows';
}
// Add platforms depending on options
if ($this->option('windows')) {
$platforms[] = 'windows';
}

if ($this->option('osx')) {
$platforms[] = 'osx';
}
if ($this->option('osx')) {
$platforms[] = 'osx';
}

if ($this->option('linux')) {
$platforms[] = 'linux';
}
if ($this->option('linux')) {
$platforms[] = 'linux';
}

// Queue each platform separately
foreach ($platforms as $platform) {
// Queue each platform separately
foreach ($platforms as $platform) {

$alreadyQueued = SteamQueueItem::where('app_id', $app->id)
->where('platform', $platform)
->first();
$alreadyQueued = SteamQueueItem::where('app_id', $app->id)
->where('platform', $platform)
->first();

if ($alreadyQueued) {
$this->error('Steam app "'.$app->name.'" on platform "'.ucfirst($platform).'" already in download queue');
continue;
}
if ($alreadyQueued) {
$this->error('Steam app "'.$app->name.'" on platform "'.ucfirst($platform).'" already in download queue');
continue;
}

// Add the app to the download queue, specifying the platform and account
$steamQueueItem = new SteamQueueItem;
$steamQueueItem->app_id = $app->id;
$steamQueueItem->platform = $platform;
$steamQueueItem->status = 'queued';
// Add the app to the download queue, specifying the platform and account
$steamQueueItem = new SteamQueueItem;
$steamQueueItem->app_id = $app->id;
$steamQueueItem->platform = $platform;
$steamQueueItem->status = 'queued';

if ($steamQueueItem->save()) {
$this->info('Added Steam app "'.$app->name.'" on platform "'.ucfirst($platform).'" to download queue');
}
if ($steamQueueItem->save()) {
$this->info('Added Steam app "'.$app->name.'" on platform "'.ucfirst($platform).'" to download queue');
}

}
}


}
}

0 comments on commit 9029701

Please sign in to comment.