Fix itunes bug and add logger
This commit is contained in:
parent
d8241e1ac3
commit
f188181528
@ -10,11 +10,13 @@ use OCA\RePod\Service\ItunesService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\IRequest;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class SearchController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
IRequest $request,
|
||||
private LoggerInterface $logger,
|
||||
private FyydService $fyydService,
|
||||
private ItunesService $itunesService
|
||||
) {
|
||||
@ -30,6 +32,7 @@ class SearchController extends Controller
|
||||
try {
|
||||
$podcasts = [...$podcasts, ...$provider->search($value)];
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error($e->getMessage(), $e->getTrace());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ use OCP\Http\Client\IClientService;
|
||||
use OCP\Http\Client\IResponse;
|
||||
use OCP\IUserSession;
|
||||
use OCP\L10N\IFactory;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class FyydService implements IProvider
|
||||
{
|
||||
@ -17,7 +18,8 @@ class FyydService implements IProvider
|
||||
private UserService $userService,
|
||||
private IClientService $clientService,
|
||||
private IFactory $l10n,
|
||||
private IUserSession $userSession
|
||||
private IUserSession $userSession,
|
||||
private LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
@ -68,6 +70,7 @@ class FyydService implements IProvider
|
||||
$language = in_array($userLang, $langJson['data']) ? $userLang : 'en';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error($e->getMessage(), $e->getTrace());
|
||||
}
|
||||
|
||||
$podcastClient = $this->clientService->newClient();
|
||||
|
@ -30,7 +30,7 @@ class ItunesService implements IProvider
|
||||
]);
|
||||
$json = (array) json_decode((string) $response->getBody(), true, flags: JSON_THROW_ON_ERROR);
|
||||
|
||||
if (array_key_exists('data', $json) && is_array($json['data'])) {
|
||||
if (array_key_exists('results', $json) && is_array($json['results'])) {
|
||||
/** @var string[] $feed */
|
||||
foreach ($json['results'] as $feed) {
|
||||
$podcasts[] = [
|
||||
|
Loading…
Reference in New Issue
Block a user