mirror of
https://github.com/zeropingheroes/lancache-autofill
synced 2024-11-10 10:24:12 +00:00
Adding ability to specify platform when queuing an app for download
This commit is contained in:
parent
f9ef78deb4
commit
91b1ad3f16
4 changed files with 29 additions and 12 deletions
3
src/Console/Commands/CreateDatabase.php
Normal file → Executable file
3
src/Console/Commands/CreateDatabase.php
Normal file → Executable file
|
@ -37,8 +37,9 @@ class CreateDatabase extends Command
|
|||
|
||||
Capsule::schema()->create('steam_queue', function ($table) {
|
||||
$table->increments('id')->unique();
|
||||
$table->integer('appid')->unique();
|
||||
$table->integer('appid');
|
||||
$table->string('name');
|
||||
$table->string('platform');
|
||||
$table->string('status');
|
||||
$table->string('message')->nullable();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class QueueApp extends Command
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'steam:queue-app {app_id}';
|
||||
protected $signature = 'steam:queue-app {app_id} {platform=windows}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
|
@ -21,13 +21,27 @@ class QueueApp extends Command
|
|||
*/
|
||||
protected $description = 'Queue a Steam app for donwloading';
|
||||
|
||||
/**
|
||||
* The permissible platforms.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
const PLATFORMS = ['windows', 'osx', 'linux'];
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
{
|
||||
|
||||
if( $this->argument('platform') && ! in_array($this->argument('platform'), $this::PLATFORMS))
|
||||
{
|
||||
$this->error('Invalid platform specified. Available platforms are: '. implode(' ', $this::PLATFORMS));
|
||||
die();
|
||||
}
|
||||
|
||||
$app = Capsule::table('steam_apps')
|
||||
->where('appid', $this->argument('app_id'))
|
||||
->first();
|
||||
|
@ -40,21 +54,23 @@ class QueueApp extends Command
|
|||
|
||||
$alreadyQueued = Capsule::table('steam_queue')
|
||||
->where('appid', $app->appid)
|
||||
->where('platform', $this->argument('platform'))
|
||||
->count();
|
||||
|
||||
if( $alreadyQueued )
|
||||
{
|
||||
$this->error('Steam app "' . $app->name .'" already in download queue');
|
||||
$this->error('Steam app "' . $app->name .'" on platform "'.$this->argument('platform').'" already in download queue');
|
||||
die();
|
||||
}
|
||||
|
||||
Capsule::table('steam_queue')->insert([
|
||||
'appid' => $app->appid,
|
||||
'name' => $app->name,
|
||||
'platform' => $this->argument('platform'),
|
||||
'status'=> 'queued'
|
||||
]);
|
||||
|
||||
$this->info('Steam app "' . $app->name .'" added to download queue');
|
||||
$this->info('Added Steam app "' . $app->name .'" on platform "'.$this->argument('platform').'" to download queue');
|
||||
|
||||
}
|
||||
}
|
2
src/Console/Commands/Steam/ShowQueue.php
Normal file → Executable file
2
src/Console/Commands/Steam/ShowQueue.php
Normal file → Executable file
|
@ -84,7 +84,7 @@ class ShowQueue extends Command
|
|||
|
||||
foreach( $apps as $app )
|
||||
{
|
||||
$this->{$messageStyle}( $app->appid ."\t". $app->name . "\t" . $app->message );
|
||||
$this->{$messageStyle}( $app->appid ."\t". $app->name . "\t" . $app->platform . "\t" . $app->message );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,14 +39,14 @@ class StartDownloading extends Command
|
|||
// Loop through all apps to process
|
||||
while( $app = $this->nextApp() ) {
|
||||
|
||||
$this->info('Starting download of ' . $app->name );
|
||||
$this->info('Starting download of ' . $app->name . ' for ' . $app->platform);
|
||||
|
||||
try {
|
||||
$arguments =
|
||||
[
|
||||
'login' => getenv('STEAM_USER'),
|
||||
'@sSteamCmdForcePlatformType' => 'windows',
|
||||
'force_install_dir' => getenv('DOWNLOAD_LOCATION').$app->appid,
|
||||
'@sSteamCmdForcePlatformType' => $app->platform,
|
||||
'force_install_dir' => getenv('DOWNLOAD_LOCATION').'/'.$app->platform.'/'.$app->appid,
|
||||
'app_license_request' => $app->appid,
|
||||
'app_update' => $app->appid,
|
||||
'quit' => null,
|
||||
|
@ -75,12 +75,12 @@ class StartDownloading extends Command
|
|||
if (!$process->isSuccessful())
|
||||
throw new ProcessFailedException($process);
|
||||
|
||||
$this->info('Successfully completed download of ' . $app->name );
|
||||
$this->info('Successfully completed download of ' . $app->name . ' for ' . $app->platform);
|
||||
$this->updateQueueItemStatus($app->id, 'completed');
|
||||
|
||||
} catch (ProcessFailedException $e) {
|
||||
if($process->getExitCode() == 127) {
|
||||
$this->error('SteamCMD not found - please ensure it is in your $PATH');
|
||||
$this->error('SteamCMD not found - please check the correct path is set in your .env file');
|
||||
die();
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ class StartDownloading extends Command
|
|||
// Get the last line (removing ANSI codes)
|
||||
$lastLine = preg_replace('#\x1b\[[0-9;]*[a-zA-Z]#', '', end($lines));
|
||||
|
||||
$this->error('Failed to download ' . $app->name );
|
||||
$this->error('Failed to download ' . $app->name . ' for ' . $app->platform);
|
||||
$this->updateQueueItemStatus($app->id, 'failed', $lastLine );
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue