mirror of
https://github.com/zeropingheroes/lancache-autofill
synced 2024-11-10 10:24:12 +00:00
Adding ability to add Steam apps to the download queue
This commit is contained in:
parent
ddc0670f6b
commit
d1665fa5ca
3 changed files with 66 additions and 2 deletions
|
@ -8,7 +8,7 @@ use Illuminate\Events\Dispatcher;
|
|||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
// Import available commands
|
||||
use Zeropingheroes\LancacheAutofill\Console\Commands\Steam\{UpdateAppList, SearchApps};
|
||||
use Zeropingheroes\LancacheAutofill\Console\Commands\Steam\{UpdateAppList, SearchApps, QueueApp};
|
||||
use Zeropingheroes\LancacheAutofill\Console\Commands\CreateDatabase;
|
||||
|
||||
// Load Composer's autoloader
|
||||
|
@ -34,6 +34,7 @@ $capsule->setAsGlobal();
|
|||
$app->add(new CreateDatabase);
|
||||
$app->add(new UpdateAppList);
|
||||
$app->add(new SearchApps);
|
||||
$app->add(new QueueApp);
|
||||
|
||||
// Run the console app
|
||||
$app->run();
|
|
@ -35,8 +35,11 @@ class CreateDatabase extends Command
|
|||
$table->string('name');
|
||||
});
|
||||
|
||||
Capsule::schema()->create('dummy', function ($table) {
|
||||
Capsule::schema()->create('steam_queue', function ($table) {
|
||||
$table->increments('id')->unique();
|
||||
$table->integer('appid')->unique();
|
||||
$table->string('name');
|
||||
$table->string('status');
|
||||
});
|
||||
}
|
||||
}
|
60
src/Console/Commands/Steam/QueueApp.php
Normal file
60
src/Console/Commands/Steam/QueueApp.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Zeropingheroes\LancacheAutofill\Console\Commands\Steam;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
class QueueApp extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'steam:queue-app {app_id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Queue a Steam app for donwloading';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$app = Capsule::table('steam_apps')
|
||||
->where('appid', $this->argument('app_id'))
|
||||
->first();
|
||||
|
||||
if( ! $app )
|
||||
{
|
||||
$this->error('Steam app with ID '.$this->argument('app_id').' not found');
|
||||
die();
|
||||
}
|
||||
|
||||
$alreadyQueued = Capsule::table('steam_queue')
|
||||
->where('appid', $app->appid)
|
||||
->count();
|
||||
|
||||
if( $alreadyQueued )
|
||||
{
|
||||
$this->error('Steam app "' . $app->name .'" already in download queue');
|
||||
die();
|
||||
}
|
||||
|
||||
Capsule::table('steam_queue')->insert([
|
||||
'appid' => $app->appid,
|
||||
'name' => $app->name,
|
||||
'status'=> 'Queued'
|
||||
]);
|
||||
|
||||
$this->info('Steam app "' . $app->name .'" added to download queue');
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue