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
{
$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);
}
}

View File

@ -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,
];
}

View File

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

7
package-lock.json generated
View File

@ -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",

View File

@ -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",

View File

@ -4,22 +4,47 @@
<ul v-if="!loading">
<NcListItem v-for="episode in episodes"
: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>
</fragment>
</template>
<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 { format } from 'date-format-parse'
import { formatTimeAgo } from '../../utils/time.js'
import { generateUrl } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
export default {
name: 'List',
components: {
NcActionButton,
NcAvatar,
NcListItem,
NcLoadingIcon,
Play,
},
data() {
return {
@ -44,5 +69,9 @@ export default {
this.loading = false
}
},
methods: {
format,
formatTimeAgo,
},
}
</script>