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" />
|
|
|
|
|
2023-03-13 13:39:07 +00:00
|
|
|
<LoadingIndicatorPage :show-content="channel != null && !channel.error">
|
2023-03-15 23:38:29 +00:00
|
|
|
<img
|
|
|
|
v-if="channel.bannerUrl"
|
2023-12-19 15:44:16 +00:00
|
|
|
loading="lazy"
|
2023-03-15 23:38:29 +00:00
|
|
|
:src="channel.bannerUrl"
|
2023-08-13 17:31:57 +00:00
|
|
|
class="h-30 w-full object-cover py-1.5 md:h-50"
|
2023-03-15 23:38:29 +00:00
|
|
|
/>
|
2023-08-13 17:31:57 +00:00
|
|
|
<div class="flex flex-col items-center justify-between md:flex-row">
|
2023-03-15 14:38:30 +00:00
|
|
|
<div class="flex place-items-center">
|
2023-08-13 17:31:57 +00:00
|
|
|
<img height="48" width="48" class="m-1 rounded-full" :src="channel.avatarUrl" />
|
|
|
|
<div class="flex items-center gap-1">
|
2023-07-27 11:46:05 +00:00
|
|
|
<h1 class="!text-xl" v-text="channel.name" />
|
2024-03-06 19:45:31 +00:00
|
|
|
<i v-if="channel.verified" class="i-fa6-solid:check !text-xl" />
|
2023-03-15 14:38:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-27 06:46:36 +00:00
|
|
|
|
2023-03-15 14:38:30 +00:00
|
|
|
<div class="flex gap-2">
|
|
|
|
<button
|
2023-07-27 11:46:05 +00:00
|
|
|
class="btn"
|
|
|
|
@click="subscribeHandler"
|
2023-12-19 16:04:21 +00:00
|
|
|
v-text="
|
|
|
|
$t('actions.' + (subscribed ? 'unsubscribe' : 'subscribe')) +
|
|
|
|
' - ' +
|
|
|
|
numberFormat(channel.subscriberCount)
|
|
|
|
"
|
2023-03-15 14:38:30 +00:00
|
|
|
></button>
|
|
|
|
|
2023-09-14 15:04:04 +00:00
|
|
|
<button
|
|
|
|
v-if="subscribed"
|
|
|
|
v-t="'actions.add_to_group'"
|
|
|
|
class="btn"
|
|
|
|
@click="showGroupModal = true"
|
|
|
|
></button>
|
|
|
|
|
2023-03-15 14:38:30 +00:00
|
|
|
<!-- RSS Feed button -->
|
|
|
|
<a
|
2023-07-27 11:46:05 +00:00
|
|
|
v-if="channel.id"
|
2023-03-15 14:38:30 +00:00
|
|
|
aria-label="RSS feed"
|
|
|
|
title="RSS feed"
|
|
|
|
role="button"
|
|
|
|
:href="`${apiUrl()}/feed/unauthenticated/rss?channels=${channel.id}`"
|
|
|
|
target="_blank"
|
|
|
|
class="btn flex-col"
|
|
|
|
>
|
2024-03-06 19:45:31 +00:00
|
|
|
<i class="i-fa6-solid:rss" />
|
2023-03-15 14:38:30 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-16 22:56:41 +00:00
|
|
|
|
2023-05-23 16:24:32 +00:00
|
|
|
<CollapsableText :text="channel.description" />
|
2022-09-08 21:24:33 +00:00
|
|
|
|
2023-07-27 11:46:05 +00:00
|
|
|
<WatchOnButton :link="`https://youtube.com/channel/${channel.id}`" />
|
2022-11-02 16:10:27 +00:00
|
|
|
|
2023-08-13 17:31:57 +00:00
|
|
|
<div class="mx-1 my-2 flex">
|
2022-11-01 12:07:31 +00:00
|
|
|
<button
|
|
|
|
v-for="(tab, index) in tabs"
|
|
|
|
:key="tab.name"
|
|
|
|
class="btn mr-2"
|
|
|
|
:class="{ active: selectedTab == index }"
|
2023-07-27 11:46:05 +00:00
|
|
|
@click="loadTab(index)"
|
2022-11-01 12:07:31 +00:00
|
|
|
>
|
2022-11-01 11:31:45 +00:00
|
|
|
<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"
|
2022-11-01 12:12:54 +00:00
|
|
|
: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>
|
2023-09-14 15:04:04 +00:00
|
|
|
|
2024-01-11 19:28:36 +00:00
|
|
|
<AddToGroupModal v-if="showGroupModal" :channel-id="channel.id.substr(-24)" @close="showGroupModal = false" />
|
2023-03-13 13:39:07 +00:00
|
|
|
</LoadingIndicatorPage>
|
2020-11-27 06:46:36 +00:00
|
|
|
</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";
|
2023-06-16 15:07:35 +00:00
|
|
|
import WatchOnButton from "./WatchOnButton.vue";
|
2023-03-13 13:39:07 +00:00
|
|
|
import LoadingIndicatorPage from "./LoadingIndicatorPage.vue";
|
2023-05-23 16:24:32 +00:00
|
|
|
import CollapsableText from "./CollapsableText.vue";
|
2023-09-14 15:04:04 +00:00
|
|
|
import AddToGroupModal from "./AddToGroupModal.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,
|
2023-06-16 15:07:35 +00:00
|
|
|
WatchOnButton,
|
2023-03-13 13:39:07 +00:00
|
|
|
LoadingIndicatorPage,
|
2023-05-23 16:24:32 +00:00
|
|
|
CollapsableText,
|
2023-09-14 15:04:04 +00:00
|
|
|
AddToGroupModal,
|
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: [],
|
2023-09-14 15:04:04 +00:00
|
|
|
showGroupModal: false,
|
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;
|
2022-08-01 14:16:06 +00:00
|
|
|
|
2024-01-19 14:24:12 +00:00
|
|
|
this.subscribed = await this.fetchSubscriptionStatus(this.channel.id);
|
2021-07-16 22:56:41 +00:00
|
|
|
},
|
2020-11-27 06:46:36 +00:00
|
|
|
async fetchChannel() {
|
2023-03-11 18:44:07 +00:00
|
|
|
const url = this.$route.path.includes("@")
|
2023-04-27 12:31:46 +00:00
|
|
|
? this.apiUrl() + "/@/" + this.$route.params.channelId
|
2023-03-11 18:44:07 +00:00
|
|
|
: 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);
|
2023-07-21 20:07:53 +00:00
|
|
|
this.fetchDeArrowContent(this.channel.relatedStreams);
|
2022-11-01 11:31:45 +00:00
|
|
|
this.tabs.push({
|
|
|
|
translatedName: this.$t("video.videos"),
|
|
|
|
});
|
2023-01-26 18:36:20 +00:00
|
|
|
const tabQuery = this.$route.query.tab;
|
2022-11-01 11:31:45 +00:00
|
|
|
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);
|
2023-01-26 18:36:20 +00:00
|
|
|
if (tab.name === tabQuery) this.loadTab(i + 1);
|
2022-11-01 11:31:45 +00:00
|
|
|
}
|
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() {
|
2022-11-01 15:15:12 +00:00
|
|
|
if (
|
|
|
|
this.loading ||
|
|
|
|
!this.channel ||
|
|
|
|
!this.channel.nextpage ||
|
|
|
|
(this.selectedTab != 0 && !this.tabs[this.selectedTab].tabNextPage)
|
|
|
|
)
|
|
|
|
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;
|
2022-11-01 11:39:01 +00:00
|
|
|
if (this.selectedTab == 0) {
|
|
|
|
this.fetchChannelNextPage();
|
|
|
|
} else {
|
|
|
|
this.fetchChannelTabNextPage();
|
|
|
|
}
|
2020-11-27 06:46:36 +00:00
|
|
|
}
|
2021-04-07 11:45:40 +00:00
|
|
|
},
|
2022-11-01 11:39:01 +00:00
|
|
|
fetchChannelNextPage() {
|
|
|
|
this.fetchJson(this.apiUrl() + "/nextpage/channel/" + this.channel.id, {
|
|
|
|
nextpage: this.channel.nextpage,
|
|
|
|
}).then(json => {
|
|
|
|
this.channel.nextpage = json.nextpage;
|
|
|
|
this.loading = false;
|
|
|
|
this.updateWatched(json.relatedStreams);
|
|
|
|
json.relatedStreams.map(stream => this.contentItems.push(stream));
|
2023-07-21 20:07:53 +00:00
|
|
|
this.fetchDeArrowContent(this.contentItems);
|
2022-11-01 11:39:01 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
fetchChannelTabNextPage() {
|
|
|
|
this.fetchJson(this.apiUrl() + "/channels/tabs", {
|
|
|
|
data: this.tabs[this.selectedTab].data,
|
2022-11-01 15:15:12 +00:00
|
|
|
nextpage: this.tabs[this.selectedTab].tabNextPage,
|
2022-11-01 11:39:01 +00:00
|
|
|
}).then(json => {
|
2022-11-01 15:15:12 +00:00
|
|
|
this.tabs[this.selectedTab].tabNextPage = json.nextpage;
|
2022-11-01 11:39:01 +00:00
|
|
|
this.loading = false;
|
|
|
|
json.content.map(item => this.contentItems.push(item));
|
2023-07-21 20:07:53 +00:00
|
|
|
this.fetchDeArrowContent(this.contentItems);
|
2022-11-01 15:15:12 +00:00
|
|
|
this.tabs[this.selectedTab].content = this.contentItems;
|
2022-11-01 11:39:01 +00:00
|
|
|
});
|
|
|
|
},
|
2021-07-16 22:56:41 +00:00
|
|
|
subscribeHandler() {
|
2024-01-19 14:24:12 +00:00
|
|
|
this.toggleSubscriptionState(this.channel.id, this.subscribed).then(success => {
|
|
|
|
if (success) this.subscribed = !this.subscribed;
|
|
|
|
});
|
2021-07-16 22:56:41 +00:00
|
|
|
},
|
2022-11-01 11:31:45 +00:00
|
|
|
getTranslatedTabName(tabName) {
|
|
|
|
let translatedTabName = tabName;
|
|
|
|
switch (tabName) {
|
2022-11-15 21:35:56 +00:00
|
|
|
case "livestreams":
|
2022-11-01 11:31:45 +00:00
|
|
|
translatedTabName = this.$t("titles.livestreams");
|
|
|
|
break;
|
2022-11-15 21:35:56 +00:00
|
|
|
case "playlists":
|
2022-11-01 11:31:45 +00:00
|
|
|
translatedTabName = this.$t("titles.playlists");
|
|
|
|
break;
|
2024-03-13 17:09:38 +00:00
|
|
|
case "albums":
|
|
|
|
translatedTabName = this.$t("titles.albums");
|
2022-11-01 11:31:45 +00:00
|
|
|
break;
|
2022-11-15 21:35:56 +00:00
|
|
|
case "shorts":
|
2022-11-01 11:31:45 +00:00
|
|
|
translatedTabName = this.$t("video.shorts");
|
|
|
|
break;
|
2022-11-01 12:22:23 +00:00
|
|
|
default:
|
|
|
|
console.error(`Tab name "${tabName}" is not translated yet!`);
|
|
|
|
break;
|
2022-11-01 11:31:45 +00:00
|
|
|
}
|
|
|
|
return translatedTabName;
|
|
|
|
},
|
|
|
|
loadTab(index) {
|
2022-11-01 11:39:01 +00:00
|
|
|
this.selectedTab = index;
|
2023-01-27 15:42:20 +00:00
|
|
|
|
|
|
|
// update the tab query in the url path
|
|
|
|
const url = new URL(window.location);
|
|
|
|
url.searchParams.set("tab", this.tabs[index].name ?? "videos");
|
|
|
|
window.history.replaceState(window.history.state, "", url);
|
2023-01-26 18:43:07 +00:00
|
|
|
|
2022-11-01 11:31:45 +00:00
|
|
|
if (index == 0) {
|
|
|
|
this.contentItems = this.channel.relatedStreams;
|
|
|
|
return;
|
|
|
|
}
|
2023-01-26 18:43:07 +00:00
|
|
|
|
2022-11-01 15:15:12 +00:00
|
|
|
if (this.tabs[index].content) {
|
|
|
|
this.contentItems = this.tabs[index].content;
|
|
|
|
return;
|
|
|
|
}
|
2022-11-01 11:31:45 +00:00
|
|
|
this.fetchJson(this.apiUrl() + "/channels/tabs", {
|
|
|
|
data: this.tabs[index].data,
|
|
|
|
}).then(tab => {
|
2022-11-01 15:15:12 +00:00
|
|
|
this.contentItems = this.tabs[index].content = tab.content;
|
2023-07-21 20:07:53 +00:00
|
|
|
this.fetchDeArrowContent(this.contentItems);
|
2022-11-01 15:15:12 +00:00
|
|
|
this.tabs[this.selectedTab].tabNextPage = tab.nextpage;
|
2022-11-01 11:31:45 +00:00
|
|
|
});
|
|
|
|
},
|
2021-04-07 11:45:40 +00:00
|
|
|
},
|
2020-11-27 06:46:36 +00:00
|
|
|
};
|
|
|
|
</script>
|
2022-11-01 12:07:31 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.active {
|
|
|
|
border: 0.1rem outset red;
|
|
|
|
}
|
|
|
|
</style>
|