From 7dbe046ad3730f8f24d21bd834dc3f7dc4dd847c Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Thu, 24 Aug 2023 20:53:54 +0200 Subject: [PATCH] Add play button --- lib/Controller/PodcastController.php | 11 +++--- .../EpisodeAction/EpisodeActionExtraData.php | 36 +++++++++---------- .../EpisodeAction/EpisodeActionReader.php | 4 +-- package-lock.json | 7 ++-- package.json | 1 + src/components/Feed/List.vue | 33 +++++++++++++++-- 6 files changed, 62 insertions(+), 30 deletions(-) diff --git a/lib/Controller/PodcastController.php b/lib/Controller/PodcastController.php index 45cdbf9..b283d52 100644 --- a/lib/Controller/PodcastController.php +++ b/lib/Controller/PodcastController.php @@ -26,10 +26,10 @@ class PodcastController extends Controller public function index(string $url): JSONResponse { - $podcasts = $this->podcastDataReader->getCachedOrFetchPodcastData($url, $this->userService->getUserUID()); + $podcast = $this->podcastDataReader->tryGetCachedPodcastData($url); - if ($podcasts) { - return new JSONResponse(['data' => $podcasts]); + if ($podcast) { + return new JSONResponse(['data' => $podcast]); } $client = $this->clientService->newClient(); @@ -40,8 +40,9 @@ class PodcastController extends Controller throw new \ErrorException("Web request returned non-2xx status code: {$statusCode}"); } - $podcasts = PodcastData::parseRssXml((string) $feed->getBody()); + $podcast = PodcastData::parseRssXml((string) $feed->getBody()); + $this->podcastDataReader->trySetCachedPodcastData($url, $podcast); - return new JSONResponse(['data' => $podcasts], $statusCode); + return new JSONResponse(['data' => $podcast], $statusCode); } } diff --git a/lib/Core/EpisodeAction/EpisodeActionExtraData.php b/lib/Core/EpisodeAction/EpisodeActionExtraData.php index 08ae327..a3bb7af 100644 --- a/lib/Core/EpisodeAction/EpisodeActionExtraData.php +++ b/lib/Core/EpisodeAction/EpisodeActionExtraData.php @@ -19,9 +19,9 @@ use OCA\GPodderSync\Core\EpisodeAction\EpisodeAction; * episodeImage: ?string, * episodeDescription: ?string, * fetchedAtUnix: int, - * pubDate: ?\DateTime, - * filesize: ?int, - * duration: ?int, + * episodePubDate: ?\DateTime, + * episodeFilesize: ?int, + * episodeDuration: ?int, * episodeAction: ?EpisodeActionType * } */ @@ -35,9 +35,9 @@ class EpisodeActionExtraData implements \JsonSerializable private ?string $episodeImage, private ?string $episodeDescription, private int $fetchedAtUnix, - private ?\DateTime $pubDate, - private ?int $filesize, - private ?int $duration, + private ?\DateTime $episodePubDate, + private ?int $episodeFilesize, + private ?int $episodeDuration, private ?EpisodeAction $episodeAction ) { $this->episodeUrl = $episodeUrl; @@ -47,9 +47,9 @@ class EpisodeActionExtraData implements \JsonSerializable $this->episodeImage = $episodeImage; $this->episodeDescription = $episodeDescription; $this->fetchedAtUnix = $fetchedAtUnix; - $this->pubDate = $pubDate; - $this->filesize = $filesize; - $this->duration = $duration; + $this->episodePubDate = $episodePubDate; + $this->episodeFilesize = $episodeFilesize; + $this->episodeDuration = $episodeDuration; $this->episodeAction = $episodeAction; } @@ -58,19 +58,19 @@ class EpisodeActionExtraData implements \JsonSerializable return $this->episodeUrl ?? '/no episodeUrl/'; } - public function getPubDate(): ?\DateTime + public function getEpisodePubDate(): ?\DateTime { - return $this->pubDate; + return $this->episodePubDate; } - public function getFilesize(): ?int + public function getEpisodeFilesize(): ?int { - return $this->filesize; + return $this->episodeFilesize; } - public function getDuration(): ?int + public function getEpisodeDuration(): ?int { - return $this->duration; + return $this->episodeDuration; } public function getEpisodeAction(): ?EpisodeAction @@ -97,9 +97,9 @@ class EpisodeActionExtraData implements \JsonSerializable 'episodeImage' => $this->episodeImage, 'episodeDescription' => $this->episodeDescription, 'fetchedAtUnix' => $this->fetchedAtUnix, - 'pubDate' => $this->pubDate, - 'filesize' => $this->filesize, - 'duration' => $this->duration, + 'episodePubDate' => $this->episodePubDate, + 'episodeFilesize' => $this->episodeFilesize, + 'episodeDuration' => $this->episodeDuration, 'episodeAction' => $this->episodeAction ? $this->episodeAction->toArray() : null, ]; } diff --git a/lib/Core/EpisodeAction/EpisodeActionReader.php b/lib/Core/EpisodeAction/EpisodeActionReader.php index 5dece7c..c922a91 100644 --- a/lib/Core/EpisodeAction/EpisodeActionReader.php +++ b/lib/Core/EpisodeAction/EpisodeActionReader.php @@ -104,8 +104,8 @@ class EpisodeActionReader extends GPodderSyncEpisodeActionReader $episodeDescription = $this->stringOrNull($item->description); } - // Open links in new browser window/tab - $episodeDescription = str_replace('stringOrNull($item->pubDate); diff --git a/package-lock.json b/package-lock.json index 86fdde4..23e6f2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@nextcloud/l10n": "^2.2.0", "@nextcloud/router": "^2.1.2", "@nextcloud/vue": "8.0.0-beta.3", + "date-format-parse": "^0.2.7", "vue": "^2", "vue-fragment": "^1.6.0", "vue-material-design-icons": "^5.2.0", @@ -6751,9 +6752,9 @@ "peer": true }, "node_modules/electron-to-chromium": { - "version": "1.4.500", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.500.tgz", - "integrity": "sha512-P38NO8eOuWOKY1sQk5yE0crNtrjgjJj6r3NrbIKtG18KzCHmHE2Bt+aQA7/y0w3uYsHWxDa6icOohzjLJ4vJ4A==" + "version": "1.4.501", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.501.tgz", + "integrity": "sha512-NCF5hZUg73MEP0guvIM+BjPs9W07UeAuc5XCNqRZZTKJxLjE0ZS/Zo5UsV8bbs2y/jeKRPFPzdWdBfOGEZTXKg==" }, "node_modules/elliptic": { "version": "6.5.4", diff --git a/package.json b/package.json index 0c56a01..5405a5f 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@nextcloud/l10n": "^2.2.0", "@nextcloud/router": "^2.1.2", "@nextcloud/vue": "8.0.0-beta.3", + "date-format-parse": "^0.2.7", "vue": "^2", "vue-fragment": "^1.6.0", "vue-material-design-icons": "^5.2.0", diff --git a/src/components/Feed/List.vue b/src/components/Feed/List.vue index 13a347c..1d24f89 100644 --- a/src/components/Feed/List.vue +++ b/src/components/Feed/List.vue @@ -4,22 +4,47 @@