diff --git a/lib/Controller/EpisodesController.php b/lib/Controller/EpisodesController.php index 63d9d54..8b76c16 100644 --- a/lib/Controller/EpisodesController.php +++ b/lib/Controller/EpisodesController.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace OCA\RePod\Controller; use OCA\RePod\AppInfo\Application; +use OCA\RePod\Core\EpisodeAction\EpisodeActionExtraData; use OCA\RePod\Core\EpisodeAction\EpisodeActionReader; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; @@ -26,7 +27,12 @@ class EpisodesController extends Controller $client = $this->clientService->newClient(); $feed = $client->get($url); - return new JSONResponse($this->episodeActionReader->parseRssXml((string) $feed->getBody()), $feed->getStatusCode()); + $episodes = $this->episodeActionReader->parseRssXml((string) $feed->getBody()); + + usort($episodes, fn (EpisodeActionExtraData $a, EpisodeActionExtraData $b) => $b->getFetchedAtUnix() <=> $a->getFetchedAtUnix()); + $episodes = array_intersect_key($episodes, array_unique(array_map(fn (EpisodeActionExtraData $episode) => $episode->getEpisodeGuid(), $episodes))); + + return new JSONResponse($episodes, $feed->getStatusCode()); } public function action(string $url): JSONResponse { diff --git a/lib/Controller/PodcastController.php b/lib/Controller/PodcastController.php index d7030fe..17871e3 100644 --- a/lib/Controller/PodcastController.php +++ b/lib/Controller/PodcastController.php @@ -33,15 +33,10 @@ class PodcastController extends Controller $client = $this->clientService->newClient(); $feed = $client->get($url); - $statusCode = $feed->getStatusCode(); - - if ($statusCode < 200 || $statusCode >= 300) { - throw new \ErrorException("Web request returned non-2xx status code: {$statusCode}"); - } $podcast = PodcastData::parseRssXml((string) $feed->getBody()); $this->podcastDataReader->trySetCachedPodcastData($url, $podcast); - return new JSONResponse($podcast, $statusCode); + return new JSONResponse($podcast, $feed->getStatusCode()); } } diff --git a/lib/Controller/ToplistController.php b/lib/Controller/ToplistController.php index 54f8992..325abe8 100644 --- a/lib/Controller/ToplistController.php +++ b/lib/Controller/ToplistController.php @@ -7,7 +7,6 @@ namespace OCA\RePod\Controller; use OCA\RePod\AppInfo\Application; use OCA\RePod\Service\FyydService; use OCP\AppFramework\Controller; -use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; @@ -25,10 +24,6 @@ class ToplistController extends Controller * @NoCSRFRequired */ public function index(): JSONResponse { - try { - return new JSONResponse($this->fyydService->hot()); - } catch (\Exception $e) { - return new JSONResponse([$e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR); - } + return new JSONResponse($this->fyydService->hot()); } } diff --git a/src/components/Feed/Episodes.vue b/src/components/Feed/Episodes.vue index 228d828..94ecd03 100644 --- a/src/components/Feed/Episodes.vue +++ b/src/components/Feed/Episodes.vue @@ -38,38 +38,21 @@ - - - {{ modalEpisode.episodeName }} - {{ modalEpisode.episodeDescription }} - - - - - - {{ modalEpisode.podcastName }} - - - - - - {{ t('Download') }} - - - + + +