1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-15 14:50:28 +05:30
Piped/src/components/Playlist.vue

94 lines
3.4 KiB
Vue
Raw Normal View History

<template>
<div v-if="playlist">
<h1 class="uk-text-center">
2021-04-24 00:41:51 +05:30
<img v-bind:src="playlist.avatarUrl" height="48" width="48" loading="lazy" />
2021-02-24 15:05:41 +05:30
{{ playlist.name }}
</h1>
<b
><router-link class="uk-text-justify" v-bind:to="playlist.uploaderUrl || '/'">
2021-02-24 15:05:41 +05:30
<img v-bind:src="playlist.uploaderAvatar" loading="lazy" />
{{ playlist.uploader }}</router-link
></b
>
<b class="uk-align-right">{{ playlist.videos }} Videos</b>
<hr />
<div class="uk-grid-xl" uk-grid="parallax: 0">
<div
class="uk-width-1-2 uk-width-1-3@m uk-width-1-4@l uk-width-1-5@xl"
v-bind:key="item.url"
v-for="item in this.playlist.relatedStreams"
>
<router-link class="uk-link-muted uk-text-justify" v-bind:to="item.url || '/'">
2021-04-24 00:41:51 +05:30
<img style="width: 100%" height="94" width="168" v-bind:src="item.thumbnail" loading="lazy" />
<a>{{ item.title }}</a>
</router-link>
<br />
<div>
<b class="uk-text-small uk-align-left">
<router-link class="uk-text-justify" v-bind:to="item.uploaderUrl || '/'">{{
item.uploaderName
}}</router-link>
</b>
<b class="uk-text-small uk-align-right">
{{ timeFormat(item.duration) }}
</b>
</div>
</div>
</div>
</div>
</template>
<script>
import Constants from "@/Constants.js";
export default {
data() {
return {
playlist: null,
};
},
mounted() {
this.getPlaylistData();
window.addEventListener("scroll", this.handleScroll);
},
unmounted() {
window.removeEventListener("scroll", this.handleScroll);
},
methods: {
async fetchPlaylist() {
return await await this.fetchJson(Constants.BASE_URL + "/playlists/" + this.$route.query.list);
},
async getPlaylistData() {
this.fetchPlaylist()
.then(data => (this.playlist = data))
.then(() => (document.title = this.playlist.name + " - Piped"));
},
handleScroll() {
2021-04-21 19:33:56 +05:30
if (this.loading || !this.playlist || !this.playlist.nextpage || !this.playlist.nextbody) return;
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
this.loading = true;
2021-02-24 15:05:41 +05:30
this.fetchJson(
Constants.BASE_URL +
"/nextpage/playlists/" +
this.$route.query.list +
"?url=" +
2021-03-30 15:09:23 +05:30
encodeURIComponent(this.playlist.nextpage) +
"&id=" +
2021-04-21 19:33:56 +05:30
encodeURIComponent(this.playlist.nextbody),
2021-02-24 15:05:41 +05:30
).then(json => {
this.playlist.relatedStreams.concat(json.relatedStreams);
this.playlist.nextpage = json.nextpage;
2021-04-21 19:33:56 +05:30
this.playlist.nextbody = json.nextbody;
2021-02-24 15:05:41 +05:30
this.loading = false;
json.relatedStreams.map(stream => this.playlist.relatedStreams.push(stream));
2021-02-24 15:05:41 +05:30
});
}
},
},
};
</script>