Add play button
All checks were successful
repod / nextcloud (push) Successful in 1m6s
repod / nodejs (push) Successful in 1m36s

This commit is contained in:
Michel Roux 2023-08-24 20:53:54 +02:00
parent 11026af80e
commit 7dbe046ad3
6 changed files with 62 additions and 30 deletions

View File

@ -26,10 +26,10 @@ class PodcastController extends Controller
public function index(string $url): JSONResponse public function index(string $url): JSONResponse
{ {
$podcasts = $this->podcastDataReader->getCachedOrFetchPodcastData($url, $this->userService->getUserUID()); $podcast = $this->podcastDataReader->tryGetCachedPodcastData($url);
if ($podcasts) { if ($podcast) {
return new JSONResponse(['data' => $podcasts]); return new JSONResponse(['data' => $podcast]);
} }
$client = $this->clientService->newClient(); $client = $this->clientService->newClient();
@ -40,8 +40,9 @@ class PodcastController extends Controller
throw new \ErrorException("Web request returned non-2xx status code: {$statusCode}"); 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);
} }
} }

View File

@ -19,9 +19,9 @@ use OCA\GPodderSync\Core\EpisodeAction\EpisodeAction;
* episodeImage: ?string, * episodeImage: ?string,
* episodeDescription: ?string, * episodeDescription: ?string,
* fetchedAtUnix: int, * fetchedAtUnix: int,
* pubDate: ?\DateTime, * episodePubDate: ?\DateTime,
* filesize: ?int, * episodeFilesize: ?int,
* duration: ?int, * episodeDuration: ?int,
* episodeAction: ?EpisodeActionType * episodeAction: ?EpisodeActionType
* } * }
*/ */
@ -35,9 +35,9 @@ class EpisodeActionExtraData implements \JsonSerializable
private ?string $episodeImage, private ?string $episodeImage,
private ?string $episodeDescription, private ?string $episodeDescription,
private int $fetchedAtUnix, private int $fetchedAtUnix,
private ?\DateTime $pubDate, private ?\DateTime $episodePubDate,
private ?int $filesize, private ?int $episodeFilesize,
private ?int $duration, private ?int $episodeDuration,
private ?EpisodeAction $episodeAction private ?EpisodeAction $episodeAction
) { ) {
$this->episodeUrl = $episodeUrl; $this->episodeUrl = $episodeUrl;
@ -47,9 +47,9 @@ class EpisodeActionExtraData implements \JsonSerializable
$this->episodeImage = $episodeImage; $this->episodeImage = $episodeImage;
$this->episodeDescription = $episodeDescription; $this->episodeDescription = $episodeDescription;
$this->fetchedAtUnix = $fetchedAtUnix; $this->fetchedAtUnix = $fetchedAtUnix;
$this->pubDate = $pubDate; $this->episodePubDate = $episodePubDate;
$this->filesize = $filesize; $this->episodeFilesize = $episodeFilesize;
$this->duration = $duration; $this->episodeDuration = $episodeDuration;
$this->episodeAction = $episodeAction; $this->episodeAction = $episodeAction;
} }
@ -58,19 +58,19 @@ class EpisodeActionExtraData implements \JsonSerializable
return $this->episodeUrl ?? '/no episodeUrl/'; 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 public function getEpisodeAction(): ?EpisodeAction
@ -97,9 +97,9 @@ class EpisodeActionExtraData implements \JsonSerializable
'episodeImage' => $this->episodeImage, 'episodeImage' => $this->episodeImage,
'episodeDescription' => $this->episodeDescription, 'episodeDescription' => $this->episodeDescription,
'fetchedAtUnix' => $this->fetchedAtUnix, 'fetchedAtUnix' => $this->fetchedAtUnix,
'pubDate' => $this->pubDate, 'episodePubDate' => $this->episodePubDate,
'filesize' => $this->filesize, 'episodeFilesize' => $this->episodeFilesize,
'duration' => $this->duration, 'episodeDuration' => $this->episodeDuration,
'episodeAction' => $this->episodeAction ? $this->episodeAction->toArray() : null, 'episodeAction' => $this->episodeAction ? $this->episodeAction->toArray() : null,
]; ];
} }

View File

@ -104,8 +104,8 @@ class EpisodeActionReader extends GPodderSyncEpisodeActionReader
$episodeDescription = $this->stringOrNull($item->description); $episodeDescription = $this->stringOrNull($item->description);
} }
// Open links in new browser window/tab // Remove tags
$episodeDescription = str_replace('<a ', '<a class="description-link" target="_blank" ', $episodeDescription ?? ''); $episodeDescription = strip_tags($episodeDescription ?? '');
// Get episode pubDate // Get episode pubDate
$rawPubDate = $this->stringOrNull($item->pubDate); $rawPubDate = $this->stringOrNull($item->pubDate);

7
package-lock.json generated
View File

@ -14,6 +14,7 @@
"@nextcloud/l10n": "^2.2.0", "@nextcloud/l10n": "^2.2.0",
"@nextcloud/router": "^2.1.2", "@nextcloud/router": "^2.1.2",
"@nextcloud/vue": "8.0.0-beta.3", "@nextcloud/vue": "8.0.0-beta.3",
"date-format-parse": "^0.2.7",
"vue": "^2", "vue": "^2",
"vue-fragment": "^1.6.0", "vue-fragment": "^1.6.0",
"vue-material-design-icons": "^5.2.0", "vue-material-design-icons": "^5.2.0",
@ -6751,9 +6752,9 @@
"peer": true "peer": true
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.4.500", "version": "1.4.501",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.500.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.501.tgz",
"integrity": "sha512-P38NO8eOuWOKY1sQk5yE0crNtrjgjJj6r3NrbIKtG18KzCHmHE2Bt+aQA7/y0w3uYsHWxDa6icOohzjLJ4vJ4A==" "integrity": "sha512-NCF5hZUg73MEP0guvIM+BjPs9W07UeAuc5XCNqRZZTKJxLjE0ZS/Zo5UsV8bbs2y/jeKRPFPzdWdBfOGEZTXKg=="
}, },
"node_modules/elliptic": { "node_modules/elliptic": {
"version": "6.5.4", "version": "6.5.4",

View File

@ -23,6 +23,7 @@
"@nextcloud/l10n": "^2.2.0", "@nextcloud/l10n": "^2.2.0",
"@nextcloud/router": "^2.1.2", "@nextcloud/router": "^2.1.2",
"@nextcloud/vue": "8.0.0-beta.3", "@nextcloud/vue": "8.0.0-beta.3",
"date-format-parse": "^0.2.7",
"vue": "^2", "vue": "^2",
"vue-fragment": "^1.6.0", "vue-fragment": "^1.6.0",
"vue-material-design-icons": "^5.2.0", "vue-material-design-icons": "^5.2.0",

View File

@ -4,22 +4,47 @@
<ul v-if="!loading"> <ul v-if="!loading">
<NcListItem v-for="episode in episodes" <NcListItem v-for="episode in episodes"
:key="episode.episodeUrl" :key="episode.episodeUrl"
:name="episode.episodeName" /> :details="formatTimeAgo(new Date(episode.episodePubDate.date))"
:force-display-actions="true"
:name="episode.episodeName"
:title="episode.episodeDescription">
<template #icon>
<NcAvatar :display-name="episode.episodeName"
:is-no-user="true"
:url="episode.episodeImage" />
</template>
<template #subname>
{{ format(new Date(episode.episodeDuration*1000), 'HH:mm:ss') }}
</template>
<template #actions>
<NcActionButton>
<template #icon>
<Play :size="20" />
</template>
</NcActionButton>
</template>
</NcListItem>
</ul> </ul>
</fragment> </fragment>
</template> </template>
<script> <script>
import { NcListItem, NcLoadingIcon } from '@nextcloud/vue' import { NcActionButton, NcAvatar, NcListItem, NcLoadingIcon } from '@nextcloud/vue'
import Play from 'vue-material-design-icons/Play.vue'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { format } from 'date-format-parse'
import { formatTimeAgo } from '../../utils/time.js'
import { generateUrl } from '@nextcloud/router' import { generateUrl } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs' import { showError } from '@nextcloud/dialogs'
export default { export default {
name: 'List', name: 'List',
components: { components: {
NcActionButton,
NcAvatar,
NcListItem, NcListItem,
NcLoadingIcon, NcLoadingIcon,
Play,
}, },
data() { data() {
return { return {
@ -44,5 +69,9 @@ export default {
this.loading = false this.loading = false
} }
}, },
methods: {
format,
formatTimeAgo,
},
} }
</script> </script>