mirror of
https://github.com/zeropingheroes/lancache-autofill
synced 2024-11-26 09:20:18 +00:00
Increased flexibility of dequeuing
This commit is contained in:
parent
7545596ff9
commit
781f3cb473
3 changed files with 68 additions and 68 deletions
|
@ -7,7 +7,7 @@ use Illuminate\Events\Dispatcher;
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
use Dotenv\Dotenv;
|
use Dotenv\Dotenv;
|
||||||
|
|
||||||
use Zeropingheroes\LancacheAutofill\Console\Commands\Steam\{UpdateAppList, SearchApps, QueueApp, ShowQueue, DequeueApp, AuthoriseAccount, StartDownloading};
|
use Zeropingheroes\LancacheAutofill\Console\Commands\Steam\{UpdateAppList, SearchApps, QueueApp, ShowQueue, Dequeue, AuthoriseAccount, StartDownloading};
|
||||||
use Zeropingheroes\LancacheAutofill\Console\Commands\{InitialiseDatabase, InitialiseDownloadsDirectory};
|
use Zeropingheroes\LancacheAutofill\Console\Commands\{InitialiseDatabase, InitialiseDownloadsDirectory};
|
||||||
|
|
||||||
// Load Composer's autoloader
|
// Load Composer's autoloader
|
||||||
|
@ -45,7 +45,7 @@ $app->add(new UpdateAppList);
|
||||||
$app->add(new SearchApps);
|
$app->add(new SearchApps);
|
||||||
$app->add(new QueueApp);
|
$app->add(new QueueApp);
|
||||||
$app->add(new ShowQueue);
|
$app->add(new ShowQueue);
|
||||||
$app->add(new DequeueApp);
|
$app->add(new Dequeue);
|
||||||
$app->add(new AuthoriseAccount);
|
$app->add(new AuthoriseAccount);
|
||||||
$app->add(new StartDownloading);
|
$app->add(new StartDownloading);
|
||||||
|
|
||||||
|
|
66
src/Console/Commands/Steam/Dequeue.php
Executable file
66
src/Console/Commands/Steam/Dequeue.php
Executable file
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Zeropingheroes\LancacheAutofill\Console\Commands\Steam;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
|
|
||||||
|
class Dequeue extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'steam:dequeue
|
||||||
|
{--app_id=}
|
||||||
|
{--platform=}
|
||||||
|
{--account=}';
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Remove item(s) from the download queue';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The permissible platforms.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
const PLATFORMS = ['windows', 'osx', 'linux'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
if( $this->option('platform') && ! in_array($this->option('platform'), $this::PLATFORMS))
|
||||||
|
{
|
||||||
|
$this->error('Invalid platform specified. Available platforms are: '. implode(' ', $this::PLATFORMS));
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = Capsule::table('steam_queue');
|
||||||
|
|
||||||
|
if( $this->option('app_id') )
|
||||||
|
$query->where('appid', $this->option('app_id'));
|
||||||
|
|
||||||
|
if( $this->option('platform') )
|
||||||
|
$query->where('platform', $this->option('platform'));
|
||||||
|
|
||||||
|
if( $this->option('account') )
|
||||||
|
$query->where('account', $this->option('account'));
|
||||||
|
|
||||||
|
$affected = $query->delete();
|
||||||
|
|
||||||
|
if( ! $affected ) {
|
||||||
|
$this->error('No items in the queue match the provided criteria');
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info('Removed ' . $affected .' item(s) from the download queue');
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,66 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Zeropingheroes\LancacheAutofill\Console\Commands\Steam;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
|
||||||
|
|
||||||
class DequeueApp extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'steam:dequeue-app
|
|
||||||
{app_id : The ID of the app}
|
|
||||||
{platforms=windows,osx,linux : (Optional) Which platform(s) to dequeue. Defaults to all platforms}';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Remove a Steam app from the download queue';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The permissible platforms.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
const PLATFORMS = ['windows', 'osx', 'linux'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
// If no platforms are specified, default to all platforms
|
|
||||||
$platforms = explode(',', $this->argument('platforms'));
|
|
||||||
|
|
||||||
if( array_diff($platforms, $this::PLATFORMS))
|
|
||||||
{
|
|
||||||
$this->error('Invalid platform(s) specified. Available platforms are: '. implode(' ', $this::PLATFORMS));
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if app with specified ID exists
|
|
||||||
$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();
|
|
||||||
}
|
|
||||||
|
|
||||||
Capsule::table('steam_queue')
|
|
||||||
->where('appid', $this->argument('app_id'))
|
|
||||||
->whereIn('platform', $platforms)
|
|
||||||
->delete();
|
|
||||||
|
|
||||||
$this->info('Removed Steam app "' . $app->name .'" on platforms "'.implode(' ', $platforms).'" from download queue');
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue