repod/lib/Controller/EpisodesController.php

32 lines
790 B
PHP
Raw Normal View History

2023-08-24 10:48:10 +00:00
<?php
declare(strict_types=1);
namespace OCA\RePod\Controller;
use OCA\RePod\AppInfo\Application;
2023-08-24 15:43:10 +00:00
use OCA\RePod\Core\EpisodeAction\EpisodeActionReader;
2023-08-24 10:48:10 +00:00
use OCP\AppFramework\Controller;
2023-08-24 15:43:10 +00:00
use OCP\AppFramework\Http\JSONResponse;
use OCP\Http\Client\IClientService;
2023-08-24 10:48:10 +00:00
use OCP\IRequest;
class EpisodesController extends Controller
{
2023-08-24 15:43:10 +00:00
public function __construct(
IRequest $request,
private IClientService $clientService,
private EpisodeActionReader $episodeActionReader
) {
2023-08-24 10:48:10 +00:00
parent::__construct(Application::APP_ID, $request);
}
2023-08-24 15:43:10 +00:00
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());
}
2023-08-24 10:48:10 +00:00
}