WIP: working move/tv show download

This commit is contained in:
Brock H Caldwell
2026-03-21 23:22:41 -05:00
parent 9e2c5410ba
commit e39cb6e9bd
17 changed files with 325 additions and 132 deletions

View File

@@ -8,6 +8,17 @@ use Symfony\Component\Security\Core\User\UserInterface;
class UserPreferencesFactory
{
public static function createFromArray(array $data): UserPreferences
{
return new UserPreferences(
resolution: static::getArrayValue($data, 'resolution'),
codec: static::getArrayValue($data, 'codec'),
language: static::getArrayValue($data, 'language'),
provider: static::getArrayValue($data, 'provider'),
quality: static::getArrayValue($data, 'quality'),
);
}
/** @param User $user */
public static function createFromUser(UserInterface $user): UserPreferences
{
@@ -30,4 +41,21 @@ class UserPreferencesFactory
$value = explode(',', $value);
return $value;
}
private static function getArrayValue(array $data, string $key): array|null
{
if (!array_key_exists($key, $data)) {
return null;
}
if ("" === $data[$key]) {
return null;
}
if (true === is_string($data[$key])) {
return [$data[$key]];
}
return $data[$key];
}
}