Renamed servers: namespace to backends:

This commit is contained in:
Abdulmhsen B. A. A
2022-07-07 16:18:53 +03:00
parent 770c14bac0
commit ff8468fdbb
10 changed files with 86 additions and 58 deletions

16
FAQ.md
View File

@@ -123,7 +123,7 @@ can run the same command with `[-h, --help]` to see more options to extend the l
Run the following command:
```bash
$ docker exec -ti watchstate console servers:edit --key options.ignore --set 'id1,id2,id3' -- [BACKEND_NAME]
$ docker exec -ti watchstate console backends:edit --key options.ignore --set 'id1,id2,id3' -- [BACKEND_NAME]
```
where `id1,id2,id3` refers to backend library id
@@ -132,7 +132,7 @@ If you ignored a library by mistake you can run the same command again and omit
entirely by running the following command
```bash
$ docker exec -ti watchstate console servers:edit --delete --key options.ignore -- [BACKEND_NAME]
$ docker exec -ti watchstate console backends:edit --delete --key options.ignore -- [BACKEND_NAME]
```
##### Note
@@ -161,7 +161,7 @@ after that you can do `./ws command` for example, `./ws db:list`
Sometimes there are problems related to HTTP/2, so before reporting bug please try running the following command:
```bash
$ docker exec -ti watchstate console servers:edit --key options.client.http_version --set 1.0 -- [BACKEND_NAME]
$ docker exec -ti watchstate console backends:edit --key options.client.http_version --set 1.0 -- [BACKEND_NAME]
```
This will force set the internal http client to use http v1 if it does not fix your problem, please open bug report
@@ -174,7 +174,7 @@ about it.
If you want to increase the timeout for specific backend you can run the following command:
```bash
$ docker exec -ti watchstate console servers:edit --key options.client.timeout --set 600 -- [BACKEND_NAME]
$ docker exec -ti watchstate console backends:edit --key options.client.timeout --set 600 -- [BACKEND_NAME]
```
where `600` is the number of secs before the timeout handler kill the request.
@@ -361,13 +361,13 @@ X-apikey: [WEBHOOK_TOKEN]
where `[WEBHOOK_TOKEN]` Should match the backend specific `webhook.token` value. to see the token for each backend run
```bash
$ docker exec -ti watchstate console servers:view --select-backends [BACKEND_NAME] -- webhook.token
$ docker exec -ti watchstate console backends:view --select-backends [BACKEND_NAME] -- webhook.token
```
If you see 'Not configured, or invalid key.' or empty value. run the following command
```bash
$ docker exec -ti watchstate console servers:edit --regenerate-webhook-token -- [BACKEND_NAME]
$ docker exec -ti watchstate console backends:edit --regenerate-webhook-token -- [BACKEND_NAME]
```
#### Emby (you need "Emby Premiere" to use webhooks).
@@ -403,7 +403,7 @@ If you have multiple plex backends and use the same PlexPass account for all of
running the following command:
```bash
$ docker exec -ti watchstate console servers:unify plex
$ docker exec -ti watchstate console backends:unify plex
Plex global webhook API key is: [random_string]
```
@@ -412,7 +412,7 @@ identify the backends, The unify command will do the necessary adjustments to ha
information run.
```bash
$ docker exec -ti watchstate console help servers:unify
$ docker exec -ti watchstate console help backends:unify
```
#### Jellyfin (Free)

View File

@@ -38,7 +38,7 @@ $ docker-compose pull && docker-compose up -d
after starting the container for the first time you need to add your backends, and to do so run the following command:
```bash
$ docker exec -ti watchstate console servers:manage --add -- [BACKEND_NAME]
$ docker exec -ti watchstate console backends:manage --add -- [BACKEND_NAME]
```
This command is interactive and will ask you for some questions to add your backend, if you want to edit the backend

View File

@@ -6,7 +6,7 @@ namespace App\Commands\Backend\Ignore;
use App\Command;
use App\Libs\Config;
use App\Libs\Entity\StateInterface as iFace;
use App\Libs\Entity\StateInterface as iState;
use App\Libs\Guid;
use App\Libs\Routable;
use InvalidArgumentException;
@@ -25,9 +25,24 @@ final class ManageCommand extends Command
protected function configure(): void
{
$cmdContext = trim(commandContext());
$cmdRoute = self::ROUTE;
$ignoreListFile = Config::get('path') . '/config/ignore.yaml';
$supportedGuids = implode(
', ',
array_map(fn($val) => '<comment>' . after($val, 'guid_') . '</comment>',
array_keys(Guid::getSupported(includeVirtual: false)))
);
$listOfTypes = implode(
', ',
array_map(fn($val) => '<comment>' . after($val, 'guid_') . '</comment>', iState::TYPES_LIST)
);
$listOfBackends = implode(
', ',
array_map(fn($val) => '<comment>' . after($val, 'guid_') . '</comment>',
array_keys(Config::get('servers', [])))
);
$this->setName(self::ROUTE)
$this->setName($cmdRoute)
->setDescription('Add/Remove external id from ignore list.')
->addOption('remove', 'r', InputOption::VALUE_NONE, 'Remove id from ignore list.')
->addArgument('id', InputArgument::REQUIRED, 'Id to ignore. Id format: type://db:id@backend_name')
@@ -38,44 +53,52 @@ This command allow you to ignore specific external id from backend.
This helps when there is a conflict between your media servers provided external ids.
Generally this should only be used as last resort. You should try to fix the source of the problem.
The <info>id</info> format is: <info>type</info>://<info>db</info>:<info>id</info>@<info>backend_name</info>[<info>?id=backend_id</info>]
The <info>id</info> format is: <info>type</info>://<info>db</info>:<info>id</info>@<info>backend</info>[<info>?id=backend_id</info>]
-----------------------------
<comment>How to Add id to ignore list.</comment>
-----------------------------
-------------------
<comment>[ Expected Values ]</comment>
-------------------
<info>type</info> expects the value to be one of [{$listOfTypes}]
<info>db</info> expects the value to be one of [{$supportedGuids}]
<info>backend</info> expects the value to be one of [{$listOfBackends}]
-------
<comment>[ FAQ ]</comment>
-------
<comment># Adding exteranl id to ignore list</comment>
To ignore <info>tvdb</info> id <info>320234</info> from <info>plex_home</info> backend you would do something like
For <comment>shows</comment>:
{$cmdContext} servers:ignore <comment>show</comment>://<info>tvdb</info>:<info>320234</info>@<info>plex_home</info>
For <comment>shows</comment> external id:
{$cmdContext} {$cmdRoute} <comment>show</comment>://<info>tvdb</info>:<info>320234</info>@<info>plex_home</info>
For <comment>movies</comment>:
{$cmdContext} servers:ignore <comment>movie</comment>://<info>tvdb</info>:<info>320234</info>@<info>plex_home</info>
For <comment>movies</comment> external id:
{$cmdContext} {$cmdRoute} <comment>movie</comment>://<info>tvdb</info>:<info>320234</info>@<info>plex_home</info>
For <comment>episodes</comment>:
{$cmdContext} servers:ignore <comment>episode</comment>://<info>tvdb</info>:<info>320234</info>@<info>plex_home</info>
For <comment>episodes</comment> external id:
{$cmdContext} {$cmdRoute} <comment>episode</comment>://<info>tvdb</info>:<info>320234</info>@<info>plex_home</info>
To scope ignore rule to specfic item from backend, You can do the same as and add [<info>?id=backend_id</info>].
To scope ignore rule to specfic item from backend, You can do the same as before and add [<info>?id=backend_id</info>].
<comment>[backend_id]:</comment>
Refers to the item id from backend. To ignore a specfic guid for item id <info>1212111</info> you can do something like this:
{$cmdContext} servers:ignore <comment>episode</comment>://<info>tvdb</info>:<info>320234</info>@<info>plex_home</info>?id=<info>1212111</info>
{$cmdContext} {$cmdRoute} <comment>episode</comment>://<info>tvdb</info>:<info>320234</info>@<info>plex_home</info>?id=<info>1212111</info>
----------------------------------
<comment>How to Remove id from ignore list.</comment>
----------------------------------
<comment># Removing exteranl id from ignore list ?</comment>
To Remove an id from ignore list just append <info>[-r, --remove]</info> to the command. For example,
To Remove an external id from ignore list just append <info>[-r, --remove]</info> to the command. For example,
{$cmdContext} servers:ignore --remove <comment>episode</comment>://<info>tvdb</info>:<info>320234</info>@<info>plex_home</info>
{$cmdContext} {$cmdRoute} --remove <comment>episode</comment>://<info>tvdb</info>:<info>320234</info>@<info>plex_home</info>
-------------------------
<comment>Where the list is stored.</comment>
-------------------------
The id should match what what entered.
{$ignoreListFile}
<comment># Where the list is stored?</comment>
By defualt we store the list at {$ignoreListFile}
HELP
);
@@ -179,12 +202,12 @@ HELP
throw new RuntimeException('No type was given.');
}
if (false === in_array($type, iFace::TYPES_LIST)) {
if (false === in_array($type, iState::TYPES_LIST)) {
throw new RuntimeException(
sprintf(
'Invalid type \'%s\' was given. Expected values are \'%s\'.',
$type,
implode(', ', iFace::TYPES_LIST)
implode(', ', iState::TYPES_LIST)
)
);
}

View File

@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Commands\Servers;
namespace App\Commands\Backends;
use App\Command;
use App\Libs\Config;
@@ -16,10 +16,10 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Yaml;
use Throwable;
#[Routable(command: self::ROUTE)]
#[Routable(command: self::ROUTE), Routable(command: 'servers:edit')]
final class EditCommand extends Command
{
public const ROUTE = 'servers:edit';
public const ROUTE = 'backends:edit';
protected function configure(): void
{
@@ -30,7 +30,8 @@ final class EditCommand extends Command
->addOption('set', 's', InputOption::VALUE_REQUIRED, 'Value to set.')
->addOption('delete', 'd', InputOption::VALUE_NONE, 'Delete value.')
->addOption('regenerate-webhook-token', 'g', InputOption::VALUE_NONE, 'Re-generate backend webhook token.')
->addArgument('backend', InputArgument::REQUIRED, 'Backend name');
->addArgument('backend', InputArgument::REQUIRED, 'Backend name')
->setAliases(['servers:edit']);
}
protected function runCommand(InputInterface $input, OutputInterface $output, null|array $rerun = null): int

View File

@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Commands\Servers;
namespace App\Commands\Backends;
use App\Command;
use App\Libs\Config;
@@ -16,16 +16,17 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Yaml;
#[Routable(command: self::ROUTE)]
#[Routable(command: self::ROUTE), Routable(command: 'servers:list')]
final class ListCommand extends Command
{
public const ROUTE = 'servers:list';
public const ROUTE = 'backends:list';
protected function configure(): void
{
$this->setName(self::ROUTE)
->addOption('config', 'c', InputOption::VALUE_REQUIRED, 'Use Alternative config file.')
->setDescription('List Added backends.');
->setDescription('List Added backends.')
->setAliases(['servers:list']);
}
/**

View File

@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Commands\Servers;
namespace App\Commands\Backends;
use App\Command;
use App\Commands\System\IndexCommand;
@@ -21,18 +21,19 @@ use Symfony\Component\Console\Question\Question;
use Symfony\Component\Yaml\Yaml;
use Throwable;
#[Routable(command: self::ROUTE)]
#[Routable(command: self::ROUTE), Routable(command: 'servers:manage')]
final class ManageCommand extends Command
{
public const ROUTE = 'servers:manage';
public const ROUTE = 'backends:manage';
protected function configure(): void
{
$this->setName(self::ROUTE)
->setDescription('Manage backend settings.')
->setDescription('Add/Edit backend settings.')
->addOption('add', 'a', InputOption::VALUE_NONE, 'Add Backend.')
->addOption('config', 'c', InputOption::VALUE_REQUIRED, 'Use Alternative config file.')
->addArgument('backend', InputArgument::REQUIRED, 'Backend name.');
->addArgument('backend', InputArgument::REQUIRED, 'Backend name.')
->setAliases(['servers:manage']);
}
/**
@@ -52,7 +53,7 @@ final class ManageCommand extends Command
'<comment>If you are running this tool inside docker, you have to enable interaction using "-ti" flag</comment>'
);
$output->writeln(
'<comment>For example: docker exec -ti watchstate console servers:manage my_home_server</comment>'
'<comment>For example: docker exec -ti watchstate console backends:manage my_home_server</comment>'
);
return self::FAILURE;
}

View File

@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Commands\Backend;
namespace App\Commands\Backends;
use App\Command;
use App\Libs\Config;
@@ -26,7 +26,7 @@ use Throwable;
#[Routable(command: self::ROUTE)]
class RestoreCommand extends Command
{
public const ROUTE = 'backend:restore';
public const ROUTE = 'backends:restore';
public const TASK_NAME = 'export';

View File

@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Commands\Servers;
namespace App\Commands\Backends;
use App\Command;
use App\Libs\Config;
@@ -16,10 +16,10 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Yaml;
use Throwable;
#[Routable(command: self::ROUTE)]
#[Routable(command: self::ROUTE), Routable(command: 'servers:unify')]
final class UnifyCommand extends Command
{
public const ROUTE = 'servers:unify';
public const ROUTE = 'backends:unify';
protected function configure(): void
{
@@ -35,6 +35,7 @@ final class UnifyCommand extends Command
implode('|', array_keys(Config::get('supported', [])))
),
)
->setAliases(['servers:unify'])
->addOption('servers-filter', null, InputOption::VALUE_OPTIONAL, '[DEPRECATED] Select backends.', '');
}
@@ -161,7 +162,7 @@ final class UnifyCommand extends Command
$output->writeln(sprintf('<error>ERROR %s: does not have backend unique id set.</error>', $backendName));
$output->writeln('<comment>Please run this command to update backend info.</comment>');
$output->writeln(sprintf(commandContext() . 'servers:manage \'%s\' ', $backendName));
$output->writeln(sprintf(commandContext() . 'backends:manage \'%s\' ', $backendName));
return self::FAILURE;
}

View File

@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Commands\Servers;
namespace App\Commands\Backends;
use App\Command;
use App\Libs\Config;
@@ -19,10 +19,10 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Yaml;
#[Routable(command: self::ROUTE)]
#[Routable(command: self::ROUTE), Routable(command: 'servers:view')]
final class ViewCommand extends Command
{
public const ROUTE = 'servers:view';
public const ROUTE = 'backends:view';
protected function configure(): void
{
@@ -36,6 +36,7 @@ final class ViewCommand extends Command
InputArgument::OPTIONAL,
'Can be any key from servers.yaml, use dot notion to access sub keys, for example [webhook.token]'
)
->setAliases(['servers:view'])
->addOption('servers-filter', null, InputOption::VALUE_OPTIONAL, '[DEPRECATED] Select backends.', '');
}

View File

@@ -225,7 +225,7 @@ final class LogsCommand extends Command
'<comment>If you are running this tool inside docker, you have to enable interaction using "-ti" flag</comment>'
);
$output->writeln(
'<comment>For example: docker exec -ti watchstate console servers:manage my_plex</comment>'
'<comment>For example: docker exec -ti watchstate console backends:manage my_plex</comment>'
);
return self::FAILURE;
}