2020-11-27 06:46:36 +00:00
|
|
|
<template>
|
2021-06-06 18:47:43 +00:00
|
|
|
<ErrorHandler v-if="channel && channel.error" :message="channel.message" :error="channel.error" />
|
|
|
|
|
|
|
|
<div v-if="channel" v-show="!channel.error">
|
2021-12-27 14:46:30 +00:00
|
|
|
<div class="flex justify-center place-items-center">
|
|
|
|
<img height="48" width="48" class="rounded-full m-1" :src="channel.avatarUrl" />
|
2021-12-27 16:29:25 +00:00
|
|
|
<h1 v-text="channel.name" />
|
2022-02-11 02:57:38 +00:00
|
|
|
<font-awesome-icon class="ml-1.5 !text-3xl" v-if="channel.verified" icon="check" />
|
2021-12-27 14:46:30 +00:00
|
|
|
</div>
|
|
|
|
<img v-if="channel.bannerUrl" :src="channel.bannerUrl" class="w-full pb-1.5" loading="lazy" />
|
2021-10-08 18:52:51 +00:00
|
|
|
<!-- eslint-disable-next-line vue/no-v-html -->
|
2022-01-12 11:27:08 +00:00
|
|
|
<p class="whitespace-pre-wrap">
|
2021-12-27 22:33:55 +00:00
|
|
|
<span v-html="purifyHTML(urlify(channel.description))" />
|
|
|
|
</p>
|
2020-11-27 06:46:36 +00:00
|
|
|
|
2021-12-27 16:29:25 +00:00
|
|
|
<button
|
|
|
|
class="btn"
|
|
|
|
@click="subscribeHandler"
|
2022-03-30 16:34:47 +00:00
|
|
|
v-t="{
|
|
|
|
path: `actions.${subscribed ? 'unsubscribe' : 'subscribe'}`,
|
|
|
|
args: { count: numberFormat(channel.subscriberCount) },
|
|
|
|
}"
|
|
|
|
></button>
|
2021-07-16 22:56:41 +00:00
|
|
|
|
2022-09-08 21:24:33 +00:00
|
|
|
<!-- RSS Feed button -->
|
|
|
|
<a
|
|
|
|
aria-label="RSS feed"
|
|
|
|
title="RSS feed"
|
|
|
|
role="button"
|
|
|
|
v-if="channel.id"
|
2022-09-09 10:40:18 +00:00
|
|
|
:href="`${apiUrl()}/feed/unauthenticated/rss?channels=${channel.id}`"
|
2022-09-08 21:24:33 +00:00
|
|
|
target="_blank"
|
|
|
|
class="btn flex-col ml-3"
|
|
|
|
>
|
|
|
|
<font-awesome-icon icon="rss" />
|
|
|
|
</a>
|
|
|
|
|
2022-11-01 11:31:45 +00:00
|
|
|
<div class="flex mt-4 mb-2">
|
|
|
|
<button v-for="(tab, index) in tabs" :key="tab.name" class="btn mr-2" @click="loadTab(index)">
|
|
|
|
<span v-text="tab.translatedName"></span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2020-11-27 06:46:36 +00:00
|
|
|
<hr />
|
|
|
|
|
2021-12-27 14:46:22 +00:00
|
|
|
<div class="video-grid">
|
2022-11-01 11:31:45 +00:00
|
|
|
<ContentItem
|
|
|
|
v-for="item in contentItems"
|
|
|
|
:key="item.url"
|
|
|
|
:content-item="item"
|
2021-12-27 14:46:39 +00:00
|
|
|
height="94"
|
|
|
|
width="168"
|
|
|
|
hide-channel
|
|
|
|
/>
|
2020-11-27 06:46:36 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-04-08 15:46:49 +00:00
|
|
|
import ErrorHandler from "./ErrorHandler.vue";
|
2022-11-01 11:31:45 +00:00
|
|
|
import ContentItem from "./ContentItem.vue";
|
2020-11-27 06:46:36 +00:00
|
|
|
|
|
|
|
export default {
|
2021-10-08 18:52:51 +00:00
|
|
|
components: {
|
|
|
|
ErrorHandler,
|
2022-11-01 11:31:45 +00:00
|
|
|
ContentItem,
|
2021-10-08 18:52:51 +00:00
|
|
|
},
|
2020-11-27 06:46:36 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-07 11:45:40 +00:00
|
|
|
channel: null,
|
2022-08-02 08:41:35 +00:00
|
|
|
subscribed: false,
|
2022-11-01 11:31:45 +00:00
|
|
|
tabs: [],
|
|
|
|
selectedTab: 0,
|
|
|
|
contentItems: [],
|
|
|
|
tabNextPage: null,
|
2020-11-27 06:46:36 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.getChannelData();
|
2021-07-07 14:18:09 +00:00
|
|
|
},
|
|
|
|
activated() {
|
2021-07-21 10:59:53 +00:00
|
|
|
if (this.channel && !this.channel.error) document.title = this.channel.name + " - Piped";
|
2020-11-27 06:46:36 +00:00
|
|
|
window.addEventListener("scroll", this.handleScroll);
|
2021-08-22 10:27:09 +00:00
|
|
|
if (this.channel && !this.channel.error) this.updateWatched(this.channel.relatedStreams);
|
2020-11-27 06:46:36 +00:00
|
|
|
},
|
2021-07-07 14:18:09 +00:00
|
|
|
deactivated() {
|
2020-11-27 06:46:36 +00:00
|
|
|
window.removeEventListener("scroll", this.handleScroll);
|
|
|
|
},
|
2021-09-05 20:53:59 +00:00
|
|
|
unmounted() {
|
|
|
|
window.removeEventListener("scroll", this.handleScroll);
|
|
|
|
},
|
2020-11-27 06:46:36 +00:00
|
|
|
methods: {
|
2021-07-16 22:56:41 +00:00
|
|
|
async fetchSubscribedStatus() {
|
2022-08-02 08:41:35 +00:00
|
|
|
if (!this.channel.id) return;
|
|
|
|
if (!this.authenticated) {
|
|
|
|
this.subscribed = this.isSubscribedLocally(this.channel.id);
|
|
|
|
return;
|
|
|
|
}
|
2022-08-01 14:16:06 +00:00
|
|
|
|
2021-07-16 22:56:41 +00:00
|
|
|
this.fetchJson(
|
2022-07-21 04:04:57 +00:00
|
|
|
this.authApiUrl() + "/subscribed",
|
2021-07-16 22:56:41 +00:00
|
|
|
{
|
|
|
|
channelId: this.channel.id,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
headers: {
|
|
|
|
Authorization: this.getAuthToken(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
).then(json => {
|
|
|
|
this.subscribed = json.subscribed;
|
|
|
|
});
|
|
|
|
},
|
2020-11-27 06:46:36 +00:00
|
|
|
async fetchChannel() {
|
2021-07-04 18:26:02 +00:00
|
|
|
const url = this.apiUrl() + "/" + this.$route.params.path + "/" + this.$route.params.channelId;
|
2021-05-28 18:40:54 +00:00
|
|
|
return await this.fetchJson(url);
|
2020-11-27 06:46:36 +00:00
|
|
|
},
|
|
|
|
async getChannelData() {
|
|
|
|
this.fetchChannel()
|
|
|
|
.then(data => (this.channel = data))
|
2021-06-06 18:47:43 +00:00
|
|
|
.then(() => {
|
2021-07-16 22:56:41 +00:00
|
|
|
if (!this.channel.error) {
|
|
|
|
document.title = this.channel.name + " - Piped";
|
2022-11-01 11:31:45 +00:00
|
|
|
this.contentItems = this.channel.relatedStreams;
|
2022-08-02 08:41:35 +00:00
|
|
|
this.fetchSubscribedStatus();
|
2021-08-22 10:27:09 +00:00
|
|
|
this.updateWatched(this.channel.relatedStreams);
|
2022-11-01 11:31:45 +00:00
|
|
|
this.tabs.push({
|
|
|
|
translatedName: this.$t("video.videos"),
|
|
|
|
});
|
|
|
|
for (let i = 0; i < this.channel.tabs.length; i++) {
|
|
|
|
let tab = this.channel.tabs[i];
|
|
|
|
tab.translatedName = this.getTranslatedTabName(tab.name);
|
|
|
|
this.tabs.push(tab);
|
|
|
|
}
|
2021-07-16 22:56:41 +00:00
|
|
|
}
|
2021-06-06 18:47:43 +00:00
|
|
|
});
|
2020-11-27 06:46:36 +00:00
|
|
|
},
|
|
|
|
handleScroll() {
|
2021-06-05 19:35:14 +00:00
|
|
|
if (this.loading || !this.channel || !this.channel.nextpage) return;
|
2021-04-07 11:45:40 +00:00
|
|
|
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
|
2020-11-27 06:46:36 +00:00
|
|
|
this.loading = true;
|
2021-07-04 18:26:02 +00:00
|
|
|
this.fetchJson(this.apiUrl() + "/nextpage/channel/" + this.channel.id, {
|
2021-06-15 11:37:35 +00:00
|
|
|
nextpage: this.channel.nextpage,
|
|
|
|
}).then(json => {
|
2021-02-24 09:35:41 +00:00
|
|
|
this.channel.nextpage = json.nextpage;
|
|
|
|
this.loading = false;
|
2021-08-22 10:27:09 +00:00
|
|
|
this.updateWatched(json.relatedStreams);
|
2022-11-01 11:31:45 +00:00
|
|
|
json.relatedStreams.map(stream => this.contentItems.push(stream));
|
2021-02-24 09:35:41 +00:00
|
|
|
});
|
2020-11-27 06:46:36 +00:00
|
|
|
}
|
2021-04-07 11:45:40 +00:00
|
|
|
},
|
2021-07-16 22:56:41 +00:00
|
|
|
subscribeHandler() {
|
2022-08-01 14:16:06 +00:00
|
|
|
if (this.authenticated) {
|
|
|
|
this.fetchJson(this.authApiUrl() + (this.subscribed ? "/unsubscribe" : "/subscribe"), null, {
|
|
|
|
method: "POST",
|
|
|
|
body: JSON.stringify({
|
|
|
|
channelId: this.channel.id,
|
|
|
|
}),
|
|
|
|
headers: {
|
|
|
|
Authorization: this.getAuthToken(),
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.handleLocalSubscriptions(this.channel.id);
|
|
|
|
}
|
2021-07-16 22:56:41 +00:00
|
|
|
this.subscribed = !this.subscribed;
|
|
|
|
},
|
2022-11-01 11:31:45 +00:00
|
|
|
getTranslatedTabName(tabName) {
|
|
|
|
let translatedTabName = tabName;
|
|
|
|
switch (tabName) {
|
|
|
|
case "Livestreams":
|
|
|
|
translatedTabName = this.$t("titles.livestreams");
|
|
|
|
break;
|
|
|
|
case "Playlists":
|
|
|
|
translatedTabName = this.$t("titles.playlists");
|
|
|
|
break;
|
|
|
|
case "Channels":
|
|
|
|
translatedTabName = this.$t("titles.channels");
|
|
|
|
break;
|
|
|
|
case "Shorts":
|
|
|
|
translatedTabName = this.$t("video.shorts");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return translatedTabName;
|
|
|
|
},
|
|
|
|
loadTab(index) {
|
|
|
|
if (index == 0) {
|
|
|
|
this.contentItems = this.channel.relatedStreams;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.fetchJson(this.apiUrl() + "/channels/tabs", {
|
|
|
|
data: this.tabs[index].data,
|
|
|
|
}).then(tab => {
|
|
|
|
this.contentItems = tab.content;
|
|
|
|
this.tabNextPage = tab.nextpage;
|
|
|
|
});
|
|
|
|
},
|
2021-04-07 11:45:40 +00:00
|
|
|
},
|
2020-11-27 06:46:36 +00:00
|
|
|
};
|
|
|
|
</script>
|