Removed WS_EPISODES_DISABLE_GUID in favor of WS_EPISODES_ENABLE_GUID

This commit is contained in:
arabcoders
2025-05-06 16:09:18 +03:00
parent bd63aa1a9a
commit 156e4aaa78
11 changed files with 43 additions and 39 deletions

View File

@@ -17,13 +17,13 @@ use Monolog\Level;
return (function () {
$inContainer = inContainer();
$progressTimeCheck = fn(int $v, int $d): int => 0 === $v || $v >= 180 ? $v : $d;
$progressTimeCheck = fn (int $v, int $d): int => 0 === $v || $v >= 180 ? $v : $d;
$config = [
'name' => 'WatchState',
'version' => '$(version_via_ci)',
'tz' => env('WS_TZ', env('TZ', 'UTC')),
'path' => fixPath(env('WS_DATA_PATH', fn() => $inContainer ? '/config' : __DIR__ . '/../var')),
'path' => fixPath(env('WS_DATA_PATH', fn () => $inContainer ? '/config' : __DIR__ . '/../var')),
'logs' => [
'context' => (bool)env('WS_LOGS_CONTEXT', false),
'prune' => [
@@ -44,7 +44,7 @@ return (function () {
'encode' => JSON_INVALID_UTF8_IGNORE | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE,
'headers' => [
'Content-Type' => 'application/json',
'X-Application-Version' => fn() => getAppVersion(),
'X-Application-Version' => fn () => getAppVersion(),
'Access-Control-Allow-Origin' => '*',
],
],
@@ -67,9 +67,9 @@ return (function () {
'not_found' => (int)env('WS_EXPORT_NOT_FOUND', 259_200),
],
'episodes' => [
'disable' => [
'guid' => (bool)env('WS_EPISODES_DISABLE_GUID', true),
]
'enable' => [
'guid' => (bool)env('WS_EPISODES_ENABLE_GUID', false),
],
],
'ignore' => [],
'trust' => [
@@ -159,14 +159,14 @@ return (function () {
$config['profiler'] = [
'save' => (bool)env('WS_PROFILER_SAVE', true),
'path' => env('WS_PROFILER_PATH', fn() => ag($config, 'tmpDir') . '/profiler'),
'path' => env('WS_PROFILER_PATH', fn () => ag($config, 'tmpDir') . '/profiler'),
'collector' => env('WS_PROFILER_COLLECTOR', null),
];
$config['cache'] = [
'prefix' => env('WS_CACHE_PREFIX', null),
'url' => env('WS_CACHE_URL', 'redis://127.0.0.1:6379'),
'path' => env('WS_CACHE_PATH', fn() => ag($config, 'tmpDir') . '/cache'),
'path' => env('WS_CACHE_PATH', fn () => ag($config, 'tmpDir') . '/cache'),
];
$config['logger'] = [

View File

@@ -95,10 +95,9 @@ return (function () {
'type' => 'int',
],
[
'key' => 'WS_EPISODES_DISABLE_GUID',
'description' => 'DO NOT parse episodes GUID.',
'key' => 'WS_EPISODES_ENABLE_GUID',
'description' => 'Enable Episodes GUID parsing.',
'type' => 'bool',
'deprecated' => true,
],
[
'key' => 'WS_BACKENDS_FILE',

View File

@@ -207,9 +207,9 @@ final class ParseWebhook
],
];
$disableGuid = (bool)Config::get('episodes.disable.guid');
$enableGUID = (bool)Config::get('episodes.enable.guid');
if (EmbyClient::TYPE_EPISODE === $type && true === $disableGuid) {
if (EmbyClient::TYPE_EPISODE === $type && false === $enableGUID) {
$guids = [];
} else {
$guids = $guid->get(guids: ag($json, 'Item.ProviderIds', []), context: $logContext);
@@ -263,7 +263,7 @@ final class ParseWebhook
context: $context,
guid: $guid,
item: $obj,
opts: ['override' => $fields, Options::DISABLE_GUID => $disableGuid],
opts: ['override' => $fields, Options::ENABLE_EPISODE_GUID => $enableGUID],
)->setIsTainted(isTainted: true === in_array($event, self::WEBHOOK_TAINTED_EVENTS));
if (false === $entity->hasGuids() && false === $entity->hasRelativeGuid()) {

View File

@@ -238,7 +238,7 @@ class EmbyClient implements iClient
guid: $this->guid,
mapper: $mapper,
after: $after,
opts: [Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid')]
opts: [Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid')]
);
if ($response->hasError()) {
@@ -263,7 +263,7 @@ class EmbyClient implements iClient
mapper: $mapper,
opts: ag_sets($opts, [
'writer' => $writer,
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid'),
])
);
@@ -290,7 +290,7 @@ class EmbyClient implements iClient
after: $after,
opts: [
'queue' => $queue,
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid'),
],
);
@@ -448,7 +448,7 @@ class EmbyClient implements iClient
mapper: $mapper,
after: null,
opts: ag_sets($opts, [
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid'),
Options::ONLY_LIBRARY_ID => $libraryId,
])
);

View File

@@ -166,7 +166,7 @@ final class ParseWebhook
],
];
$disableGuid = (bool)Config::get('episodes.disable.guid');
$enableGUID = (bool)Config::get('episodes.enable.guid');
$providersId = [];
@@ -177,7 +177,7 @@ final class ParseWebhook
$providersId[after($key, 'provider_')] = $val;
}
if (JFC::TYPE_EPISODE === $type && true === $disableGuid) {
if (JFC::TYPE_EPISODE === $type && false === $enableGUID) {
$guids = [];
} else {
$guids = $guid->get(guids: $providersId, context: $logContext);
@@ -227,7 +227,7 @@ final class ParseWebhook
context: $context,
guid: $guid,
item: $obj,
opts: ['override' => $fields, Options::DISABLE_GUID => $disableGuid],
opts: ['override' => $fields, Options::ENABLE_EPISODE_GUID => $enableGUID],
)->setIsTainted(isTainted: true === in_array($event, self::WEBHOOK_TAINTED_EVENTS));
if (false === $entity->hasGuids() && false === $entity->hasRelativeGuid()) {

View File

@@ -93,7 +93,7 @@ trait JellyfinActionTrait
],
];
if (iState::TYPE_EPISODE === $type && true === (bool)ag($opts, Options::DISABLE_GUID, false)) {
if (iState::TYPE_EPISODE === $type && false === (bool)ag($opts, Options::ENABLE_EPISODE_GUID, false)) {
$guids = [];
} else {
$guids = $guid->get(guids: ag($item, 'ProviderIds', []), context: $logContext);

View File

@@ -265,7 +265,7 @@ class JellyfinClient implements iClient
guid: $this->guid,
mapper: $mapper,
after: $after,
opts: [Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid')]
opts: [Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid')]
);
if ($response->hasError()) {
@@ -290,7 +290,7 @@ class JellyfinClient implements iClient
mapper: $mapper,
opts: ag_sets($opts, [
'writer' => $writer,
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid')
Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid')
])
);
@@ -317,7 +317,7 @@ class JellyfinClient implements iClient
after: $after,
opts: [
'queue' => $queue,
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid'),
],
);
@@ -499,8 +499,8 @@ class JellyfinClient implements iClient
mapper: $mapper,
after: null,
opts: ag_sets($opts, [
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
Options::ONLY_LIBRARY_ID => $libraryId,
Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid'),
])
);

View File

@@ -182,9 +182,9 @@ final class ParseWebhook
],
];
$disableGuid = (bool)Config::get('episodes.disable.guid');
$enableGUID = (bool)Config::get('episodes.enable.guid');
if (PlexClient::TYPE_EPISODE === $type && true === $disableGuid) {
if (PlexClient::TYPE_EPISODE === $type && false === $enableGUID) {
$guids = [];
} else {
$guids = $guid->get(guids: ag($item, 'Guid', []), context: $logContext);
@@ -234,7 +234,7 @@ final class ParseWebhook
context: $context,
guid: $guid,
item: $obj,
opts: ['override' => $fields, Options::DISABLE_GUID => $disableGuid],
opts: ['override' => $fields, Options::ENABLE_EPISODE_GUID => $enableGUID],
)->setIsTainted(isTainted: true === in_array($event, self::WEBHOOK_TAINTED_EVENTS));
if (false === $entity->hasGuids() && false === $entity->hasRelativeGuid()) {

View File

@@ -104,7 +104,7 @@ trait PlexActionTrait
],
];
if (iState::TYPE_EPISODE === $type && true === (bool)ag($opts, Options::DISABLE_GUID, false)) {
if (iState::TYPE_EPISODE === $type && false === (bool)ag($opts, Options::ENABLE_EPISODE_GUID, false)) {
$guids = [];
} else {
$guids = $guid->get(guids: ag($item, 'Guid', []), context: $logContext);

View File

@@ -258,7 +258,7 @@ class PlexClient implements iClient
mapper: $mapper,
after: $after,
opts: [
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid'),
]
);
@@ -284,7 +284,7 @@ class PlexClient implements iClient
mapper: $mapper,
opts: ag_sets($opts, [
'writer' => $writer,
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid')
Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid')
])
);
@@ -309,7 +309,7 @@ class PlexClient implements iClient
guid: $this->guid,
mapper: $mapper,
after: $after,
opts: ['queue' => $queue, Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid')],
opts: ['queue' => $queue, Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid')],
);
if ($response->hasError()) {
@@ -468,8 +468,8 @@ class PlexClient implements iClient
mapper: $mapper,
after: null,
opts: ag_sets($opts, [
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
Options::ONLY_LIBRARY_ID => $libraryId,
Options::ENABLE_EPISODE_GUID => (bool)Config::get('episodes.enable.guid'),
]),
);
@@ -789,7 +789,8 @@ class PlexClient implements iClient
'payload' => $payload
]),
]
), $response->getStatusCode()
),
$response->getStatusCode()
);
}
} catch (TransportExceptionInterface $e) {
@@ -802,7 +803,9 @@ class PlexClient implements iClient
'line' => $e->getLine(),
'file' => after($e->getFile(), ROOT_PATH),
]
), code: 500, previous: $e
),
code: 500,
previous: $e
);
}
@@ -935,7 +938,9 @@ class PlexClient implements iClient
'line' => $e->getLine(),
'file' => after($e->getFile(), ROOT_PATH),
]
), code: 500, previous: $e
),
code: 500,
previous: $e
);
}
}
@@ -959,7 +964,7 @@ class PlexClient implements iClient
private function throwError(Response $response, string $className = RuntimeException::class, int $code = 0): void
{
throw new $className(
message: ag($response->extra, 'message', fn() => $response->error->format()),
message: ag($response->extra, 'message', fn () => $response->error->format()),
code: $code,
previous: $response->error->previous
);

View File

@@ -21,7 +21,6 @@ final class Options
public const string MAPPER_DISABLE_AUTOCOMMIT = 'DISABLE_AUTOCOMMIT';
public const string IMPORT_METADATA_ONLY = 'IMPORT_METADATA_ONLY';
public const string MISMATCH_DEEP_SCAN = 'MISMATCH_DEEP_SCAN';
public const string DISABLE_GUID = 'DISABLE_GUID';
public const string LIBRARY_SEGMENT = 'LIBRARY_SEGMENT';
public const string STATE_UPDATE_EVENT = 'STATE_UPDATE_EVENT';
public const string DUMP_PAYLOAD = 'DUMP_PAYLOAD';
@@ -51,6 +50,7 @@ final class Options
public const string DELAY_BY = 'DELAY_BY';
public const string RAW_RESPONSE_CALLBACK = 'RAW_RESPONSE_CALLBACK';
public const string INTERNAL_REQUEST = 'INTERNAL_REQUEST';
public const string ENABLE_EPISODE_GUID = 'ENABLE_EPISODE_GUID';
private function __construct()
{