2021-01-04 05:48:18 +00:00
|
|
|
<template>
|
2021-06-06 18:47:43 +00:00
|
|
|
<ErrorHandler v-if="playlist && playlist.error" :message="playlist.message" :error="playlist.error" />
|
|
|
|
|
|
|
|
<div v-if="playlist" v-show="!playlist.error">
|
2021-12-27 16:29:25 +00:00
|
|
|
<h1 class="text-center" v-text="playlist.name" />
|
2021-01-04 05:48:18 +00:00
|
|
|
|
2021-12-27 14:46:22 +00:00
|
|
|
<div class="grid grid-cols-2">
|
|
|
|
<div>
|
2022-01-12 11:27:08 +00:00
|
|
|
<router-link class="link" :to="playlist.uploaderUrl || '/'">
|
2021-12-28 01:13:55 +00:00
|
|
|
<img :src="playlist.uploaderAvatar" loading="lazy" class="rounded-full" />
|
|
|
|
<strong v-text="playlist.uploader" />
|
|
|
|
</router-link>
|
2021-12-27 14:46:22 +00:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div class="right-2vw absolute">
|
2021-12-27 16:29:25 +00:00
|
|
|
<strong v-text="`${playlist.videos} ${$t('video.videos')}`" />
|
2021-12-27 14:46:22 +00:00
|
|
|
<br />
|
2021-12-27 22:33:55 +00:00
|
|
|
<a :href="getRssUrl">
|
|
|
|
<font-awesome-icon icon="rss" />
|
|
|
|
</a>
|
2021-12-27 14:46:22 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-04 18:57:57 +00:00
|
|
|
</div>
|
2021-01-04 05:48:18 +00:00
|
|
|
|
|
|
|
<hr />
|
|
|
|
|
2021-12-27 14:46:22 +00:00
|
|
|
<div class="video-grid">
|
2021-12-27 14:46:39 +00:00
|
|
|
<VideoItem
|
2022-04-07 02:33:25 +00:00
|
|
|
v-for="(video, index) in playlist.relatedStreams"
|
2021-12-27 14:46:39 +00:00
|
|
|
:key="video.url"
|
|
|
|
:video="video"
|
2022-04-07 02:33:25 +00:00
|
|
|
:index="index"
|
|
|
|
:playlist-id="$route.query.list"
|
|
|
|
:admin="admin"
|
|
|
|
@remove="removeVideo(index)"
|
2021-12-27 14:46:39 +00:00
|
|
|
height="94"
|
|
|
|
width="168"
|
|
|
|
/>
|
2021-01-04 05:48:18 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-04-08 15:46:49 +00:00
|
|
|
import ErrorHandler from "./ErrorHandler.vue";
|
|
|
|
import VideoItem from "./VideoItem.vue";
|
2021-01-04 05:48:18 +00:00
|
|
|
|
|
|
|
export default {
|
2021-10-08 18:52:51 +00:00
|
|
|
components: {
|
|
|
|
ErrorHandler,
|
|
|
|
VideoItem,
|
|
|
|
},
|
2021-01-04 05:48:18 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-07 11:45:40 +00:00
|
|
|
playlist: null,
|
2022-04-07 02:33:25 +00:00
|
|
|
admin: false,
|
2021-01-04 05:48:18 +00:00
|
|
|
};
|
|
|
|
},
|
2021-10-08 18:52:51 +00:00
|
|
|
computed: {
|
|
|
|
getRssUrl: _this => {
|
|
|
|
return _this.apiUrl() + "/rss/playlists/" + _this.$route.query.list;
|
|
|
|
},
|
|
|
|
},
|
2021-01-04 05:48:18 +00:00
|
|
|
mounted() {
|
|
|
|
this.getPlaylistData();
|
2022-04-07 02:33:25 +00:00
|
|
|
const playlistId = this.$route.query.list;
|
|
|
|
if (this.authenticated && playlistId?.length == 36)
|
|
|
|
this.fetchJson(this.apiUrl() + "/user/playlists", null, {
|
|
|
|
headers: {
|
|
|
|
Authorization: this.getAuthToken(),
|
|
|
|
},
|
|
|
|
}).then(json => {
|
|
|
|
if (json.error) alert(json.error);
|
|
|
|
else if (json.filter(playlist => playlist.id === playlistId).length > 0) this.admin = true;
|
|
|
|
});
|
2021-07-07 14:18:09 +00:00
|
|
|
},
|
|
|
|
activated() {
|
2021-01-04 05:48:18 +00:00
|
|
|
window.addEventListener("scroll", this.handleScroll);
|
2022-04-08 21:29:50 +00:00
|
|
|
if (this.playlist) this.updateTitle();
|
2021-01-04 05:48:18 +00:00
|
|
|
},
|
2021-07-07 14:18:09 +00:00
|
|
|
deactivated() {
|
2021-01-04 05:48:18 +00:00
|
|
|
window.removeEventListener("scroll", this.handleScroll);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async fetchPlaylist() {
|
2021-07-04 18:26:02 +00:00
|
|
|
return await await this.fetchJson(this.apiUrl() + "/playlists/" + this.$route.query.list);
|
2021-01-04 05:48:18 +00:00
|
|
|
},
|
|
|
|
async getPlaylistData() {
|
|
|
|
this.fetchPlaylist()
|
|
|
|
.then(data => (this.playlist = data))
|
2022-04-08 21:29:50 +00:00
|
|
|
.then(() => this.updateTitle());
|
|
|
|
},
|
|
|
|
async updateTitle() {
|
|
|
|
document.title = this.playlist.name + " - Piped";
|
2021-01-04 05:48:18 +00:00
|
|
|
},
|
|
|
|
handleScroll() {
|
2021-06-05 19:35:14 +00:00
|
|
|
if (this.loading || !this.playlist || !this.playlist.nextpage) return;
|
2021-04-07 11:45:40 +00:00
|
|
|
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
|
2021-01-04 05:48:18 +00:00
|
|
|
this.loading = true;
|
2021-07-04 18:26:02 +00:00
|
|
|
this.fetchJson(this.apiUrl() + "/nextpage/playlists/" + this.$route.query.list, {
|
2021-06-15 11:37:35 +00:00
|
|
|
nextpage: this.playlist.nextpage,
|
|
|
|
}).then(json => {
|
2021-02-24 09:35:41 +00:00
|
|
|
this.playlist.relatedStreams.concat(json.relatedStreams);
|
|
|
|
this.playlist.nextpage = json.nextpage;
|
|
|
|
this.loading = false;
|
2021-04-07 11:45:40 +00:00
|
|
|
json.relatedStreams.map(stream => this.playlist.relatedStreams.push(stream));
|
2021-02-24 09:35:41 +00:00
|
|
|
});
|
2021-01-04 05:48:18 +00:00
|
|
|
}
|
2021-04-07 11:45:40 +00:00
|
|
|
},
|
2022-04-07 02:33:25 +00:00
|
|
|
removeVideo(index) {
|
|
|
|
this.playlist.relatedStreams.splice(index, 1);
|
|
|
|
},
|
2021-04-07 11:45:40 +00:00
|
|
|
},
|
2021-01-04 05:48:18 +00:00
|
|
|
};
|
|
|
|
</script>
|