repod/lib/Controller/EpisodesController.php
Michel Roux d2f59538c1
All checks were successful
repod / nextcloud (push) Successful in 1m9s
repod / nodejs (push) Successful in 1m35s
Add list
2023-08-24 17:43:10 +02:00

32 lines
790 B
PHP

<?php
declare(strict_types=1);
namespace OCA\RePod\Controller;
use OCA\RePod\AppInfo\Application;
use OCA\RePod\Core\EpisodeAction\EpisodeActionReader;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Http\Client\IClientService;
use OCP\IRequest;
class EpisodesController extends Controller
{
public function __construct(
IRequest $request,
private IClientService $clientService,
private EpisodeActionReader $episodeActionReader
) {
parent::__construct(Application::APP_ID, $request);
}
public function index(string $url): JSONResponse
{
$client = $this->clientService->newClient();
$feed = $client->get($url);
return new JSONResponse($this->episodeActionReader->parseRssXml((string) $feed->getBody()), $feed->getStatusCode());
}
}