2021-06-16 19:14:46 +00:00
|
|
|
<template>
|
2023-07-27 11:46:05 +00:00
|
|
|
<div v-if="showVideo" class="flex flex-col flex-justify-between">
|
2022-04-08 21:29:50 +00:00
|
|
|
<router-link
|
2023-08-13 17:31:57 +00:00
|
|
|
class="inline-block w-full focus:underline hover:underline"
|
2022-04-08 21:29:50 +00:00
|
|
|
:to="{
|
|
|
|
path: '/watch',
|
|
|
|
query: {
|
2022-11-01 12:12:54 +00:00
|
|
|
v: item.url.substr(-11),
|
2022-04-08 21:29:50 +00:00
|
|
|
...(playlistId && { list: playlistId }),
|
|
|
|
...(index >= 0 && { index: index + 1 }),
|
2024-03-19 21:20:02 +00:00
|
|
|
...(preferListen && { listen: 1 }),
|
2022-04-08 21:29:50 +00:00
|
|
|
},
|
|
|
|
}"
|
|
|
|
>
|
2023-02-16 17:26:14 +00:00
|
|
|
<div class="w-full">
|
|
|
|
<img
|
2023-12-18 16:20:23 +00:00
|
|
|
loading="lazy"
|
2023-08-13 17:31:57 +00:00
|
|
|
class="aspect-video w-full object-contain"
|
2023-07-19 00:40:12 +00:00
|
|
|
:src="thumbnail"
|
|
|
|
:alt="title"
|
2023-03-01 16:06:10 +00:00
|
|
|
:class="{ 'shorts-img': item.isShort, 'opacity-75': item.watched }"
|
2023-02-16 17:26:14 +00:00
|
|
|
/>
|
|
|
|
<!-- progress bar -->
|
2023-08-13 17:31:57 +00:00
|
|
|
<div class="relative h-1 w-full">
|
2023-02-16 17:26:14 +00:00
|
|
|
<div
|
|
|
|
v-if="item.watched && item.duration > 0"
|
2023-07-27 11:46:05 +00:00
|
|
|
class="absolute bottom-0 left-0 h-1 bg-red-600"
|
2023-02-16 17:26:14 +00:00
|
|
|
:style="{ width: `clamp(0%, ${(item.currentTime / item.duration) * 100}%, 100%` }"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-12-27 14:46:33 +00:00
|
|
|
<div class="relative text-sm">
|
2021-12-27 16:29:25 +00:00
|
|
|
<span
|
2022-11-01 12:12:54 +00:00
|
|
|
v-if="item.duration > 0"
|
2023-07-27 11:46:05 +00:00
|
|
|
class="thumbnail-overlay thumbnail-right"
|
2022-11-01 12:12:54 +00:00
|
|
|
v-text="timeFormat(item.duration)"
|
2021-12-27 16:29:25 +00:00
|
|
|
/>
|
2022-06-25 11:00:45 +00:00
|
|
|
<!-- shorts thumbnail -->
|
2023-07-27 11:46:05 +00:00
|
|
|
<span v-if="item.isShort" v-t="'video.shorts'" class="thumbnail-overlay thumbnail-left" />
|
2022-06-25 11:00:45 +00:00
|
|
|
<span
|
2022-11-02 23:59:32 +00:00
|
|
|
v-else-if="item.duration >= 0"
|
2023-07-27 11:46:05 +00:00
|
|
|
class="thumbnail-overlay thumbnail-right"
|
2022-11-01 12:12:54 +00:00
|
|
|
v-text="timeFormat(item.duration)"
|
2022-06-25 11:00:45 +00:00
|
|
|
/>
|
2022-01-30 23:48:27 +00:00
|
|
|
<i18n-t v-else keypath="video.live" class="thumbnail-overlay thumbnail-right !bg-red-600" tag="div">
|
2024-03-06 19:45:31 +00:00
|
|
|
<i class="i-fa6-solid:tower-broadcast w-3" />
|
2022-01-30 23:48:27 +00:00
|
|
|
</i18n-t>
|
2023-07-27 11:46:05 +00:00
|
|
|
<span v-if="item.watched" v-t="'video.watched'" class="thumbnail-overlay bottom-5px left-5px" />
|
2021-07-21 10:15:07 +00:00
|
|
|
</div>
|
2021-09-02 10:28:32 +00:00
|
|
|
|
|
|
|
<div>
|
2021-10-07 22:44:54 +00:00
|
|
|
<p
|
2021-12-28 14:39:20 +00:00
|
|
|
style="display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical"
|
2023-08-13 17:31:57 +00:00
|
|
|
class="link flex overflow-hidden pt-2 font-bold"
|
2023-07-19 00:40:12 +00:00
|
|
|
:title="title"
|
|
|
|
v-text="title"
|
2021-12-27 16:29:25 +00:00
|
|
|
/>
|
2021-09-02 10:28:32 +00:00
|
|
|
</div>
|
2021-06-16 19:14:46 +00:00
|
|
|
</router-link>
|
|
|
|
|
2022-01-12 11:59:50 +00:00
|
|
|
<div class="flex">
|
2022-11-01 12:12:54 +00:00
|
|
|
<router-link :to="item.uploaderUrl">
|
2021-10-07 22:44:54 +00:00
|
|
|
<img
|
2022-11-01 12:12:54 +00:00
|
|
|
v-if="item.uploaderAvatar"
|
2023-12-19 15:44:16 +00:00
|
|
|
loading="lazy"
|
2022-11-01 12:12:54 +00:00
|
|
|
:src="item.uploaderAvatar"
|
2023-08-13 17:31:57 +00:00
|
|
|
class="mr-0.5 mt-0.5 h-32px w-32px rounded-full"
|
2021-12-27 14:46:31 +00:00
|
|
|
width="68"
|
|
|
|
height="68"
|
2021-10-07 22:44:54 +00:00
|
|
|
/>
|
2021-09-02 10:28:32 +00:00
|
|
|
</router-link>
|
|
|
|
|
2023-08-13 17:31:57 +00:00
|
|
|
<div class="flex-1 px-2">
|
2021-10-07 22:44:54 +00:00
|
|
|
<router-link
|
2022-11-01 12:12:54 +00:00
|
|
|
v-if="item.uploaderUrl && item.uploaderName && !hideChannel"
|
2023-08-13 17:31:57 +00:00
|
|
|
class="link-secondary block overflow-hidden text-sm"
|
2022-11-01 12:12:54 +00:00
|
|
|
:to="item.uploaderUrl"
|
|
|
|
:title="item.uploaderName"
|
2021-10-07 22:44:54 +00:00
|
|
|
>
|
2022-11-01 12:12:54 +00:00
|
|
|
<span v-text="item.uploaderName" />
|
2024-03-06 19:45:31 +00:00
|
|
|
<i v-if="item.uploaderVerified" class="i-fa6-solid:check ml-1.5" />
|
2021-06-16 19:14:46 +00:00
|
|
|
</router-link>
|
|
|
|
|
2023-12-19 15:44:16 +00:00
|
|
|
<div v-if="item.views >= 0 || item.uploadedDate" class="mt-1 text-xs text-gray-300 font-normal">
|
2022-11-01 12:12:54 +00:00
|
|
|
<span v-if="item.views >= 0">
|
2024-03-06 19:45:31 +00:00
|
|
|
<i class="i-fa6-solid:eye" />
|
2023-03-19 10:10:21 +00:00
|
|
|
<span class="pl-1" v-text="`${numberFormat(item.views)} •`" />
|
2021-09-02 10:28:32 +00:00
|
|
|
</span>
|
2022-11-01 12:12:54 +00:00
|
|
|
<span v-if="item.uploaded > 0" class="pl-0.5" v-text="timeAgo(item.uploaded)" />
|
|
|
|
<span v-else-if="item.uploadedDate" class="pl-0.5" v-text="item.uploadedDate" />
|
2023-03-19 10:10:21 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-03-19 14:33:07 +00:00
|
|
|
<div class="flex items-center gap-2.5">
|
2023-03-19 10:10:21 +00:00
|
|
|
<router-link
|
|
|
|
:to="{
|
|
|
|
path: '/watch',
|
|
|
|
query: {
|
|
|
|
v: item.url.substr(-11),
|
|
|
|
...(playlistId && { list: playlistId }),
|
|
|
|
...(index >= 0 && { index: index + 1 }),
|
2024-03-19 21:20:02 +00:00
|
|
|
...(!preferListen && { listen: 1 }),
|
2023-03-19 10:10:21 +00:00
|
|
|
},
|
|
|
|
}"
|
2024-03-19 21:20:02 +00:00
|
|
|
:aria-label="preferListen ? title : 'Listen to ' + title"
|
|
|
|
:title="preferListen ? title : 'Listen to ' + title"
|
2023-03-19 10:10:21 +00:00
|
|
|
>
|
2024-03-20 18:25:30 +00:00
|
|
|
<i :class="preferListen ? 'i-fa6-solid:tv' : 'i-fa6-solid:headphones'" />
|
2023-03-19 10:10:21 +00:00
|
|
|
</router-link>
|
2024-01-09 16:12:22 +00:00
|
|
|
<button :title="$t('actions.add_to_playlist')" @click="showPlaylistModal = !showPlaylistModal">
|
2024-03-06 19:45:31 +00:00
|
|
|
<i class="i-fa6-solid:circle-plus" />
|
2023-03-19 10:10:21 +00:00
|
|
|
</button>
|
2024-01-09 16:12:22 +00:00
|
|
|
<button :title="$t('actions.share')" @click="showShareModal = !showShareModal">
|
2024-03-06 19:45:31 +00:00
|
|
|
<i class="i-fa6-solid:share" />
|
2024-01-09 16:12:22 +00:00
|
|
|
</button>
|
2023-03-19 10:10:21 +00:00
|
|
|
<button
|
|
|
|
v-if="admin"
|
|
|
|
ref="removeButton"
|
2023-07-27 11:46:05 +00:00
|
|
|
:title="$t('actions.remove_from_playlist')"
|
2023-05-30 13:02:20 +00:00
|
|
|
@click="showConfirmRemove = true"
|
2023-03-19 10:10:21 +00:00
|
|
|
>
|
2024-03-06 19:45:31 +00:00
|
|
|
<i class="i-fa6-solid:circle-minus" />
|
2023-03-19 10:10:21 +00:00
|
|
|
</button>
|
2023-05-30 13:02:20 +00:00
|
|
|
<ConfirmModal
|
|
|
|
v-if="showConfirmRemove"
|
2023-07-27 11:46:05 +00:00
|
|
|
:message="$t('actions.delete_playlist_video_confirm')"
|
2023-05-30 13:02:20 +00:00
|
|
|
@close="showConfirmRemove = false"
|
|
|
|
@confirm="removeVideo(item.url.substr(-11))"
|
|
|
|
/>
|
2023-06-15 15:32:32 +00:00
|
|
|
<PlaylistAddModal
|
2024-01-09 16:12:22 +00:00
|
|
|
v-if="showPlaylistModal"
|
2023-06-15 15:32:32 +00:00
|
|
|
:video-id="item.url.substr(-11)"
|
2023-06-15 17:18:47 +00:00
|
|
|
:video-info="item"
|
2024-01-09 16:12:22 +00:00
|
|
|
@close="showPlaylistModal = false"
|
|
|
|
/>
|
|
|
|
<ShareModal
|
|
|
|
v-if="showShareModal"
|
|
|
|
:video-id="item.url.substr(-11)"
|
|
|
|
:current-time="0"
|
|
|
|
@close="showShareModal = false"
|
2023-06-15 15:32:32 +00:00
|
|
|
/>
|
2021-06-16 19:14:46 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-04-07 02:33:25 +00:00
|
|
|
import PlaylistAddModal from "./PlaylistAddModal.vue";
|
2024-01-09 16:12:22 +00:00
|
|
|
import ShareModal from "./ShareModal.vue";
|
2023-05-30 13:02:20 +00:00
|
|
|
import ConfirmModal from "./ConfirmModal.vue";
|
2022-04-07 02:33:25 +00:00
|
|
|
|
2021-06-16 19:14:46 +00:00
|
|
|
export default {
|
2024-01-09 16:12:22 +00:00
|
|
|
components: { PlaylistAddModal, ConfirmModal, ShareModal },
|
2021-06-16 19:14:46 +00:00
|
|
|
props: {
|
2022-11-01 12:12:54 +00:00
|
|
|
item: {
|
2021-10-08 18:52:51 +00:00
|
|
|
type: Object,
|
|
|
|
default: () => {
|
|
|
|
return {};
|
|
|
|
},
|
|
|
|
},
|
2022-09-10 17:08:50 +00:00
|
|
|
isFeed: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-10-08 18:52:51 +00:00
|
|
|
height: { type: String, default: "118" },
|
|
|
|
width: { type: String, default: "210" },
|
|
|
|
hideChannel: { type: Boolean, default: false },
|
2022-04-07 02:33:25 +00:00
|
|
|
index: { type: Number, default: -1 },
|
|
|
|
playlistId: { type: String, default: null },
|
2024-03-19 21:20:02 +00:00
|
|
|
preferListen: { type: Boolean, default: false },
|
2022-04-07 02:33:25 +00:00
|
|
|
admin: { type: Boolean, default: false },
|
|
|
|
},
|
2023-07-27 11:46:05 +00:00
|
|
|
emits: ["remove"],
|
2022-04-07 02:33:25 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2024-01-09 16:12:22 +00:00
|
|
|
showPlaylistModal: false,
|
|
|
|
showShareModal: false,
|
2022-09-10 17:08:50 +00:00
|
|
|
showVideo: true,
|
2023-05-30 13:02:20 +00:00
|
|
|
showConfirmRemove: false,
|
2022-04-07 02:33:25 +00:00
|
|
|
};
|
|
|
|
},
|
2023-07-19 00:40:12 +00:00
|
|
|
computed: {
|
|
|
|
title() {
|
|
|
|
return this.item.dearrow?.titles[0]?.title ?? this.item.title;
|
|
|
|
},
|
|
|
|
thumbnail() {
|
|
|
|
return this.item.dearrow?.thumbnails[0]?.thumbnail ?? this.item.thumbnail;
|
|
|
|
},
|
|
|
|
},
|
2023-07-27 11:46:05 +00:00
|
|
|
mounted() {
|
|
|
|
this.shouldShowVideo();
|
|
|
|
},
|
2022-04-07 02:33:25 +00:00
|
|
|
methods: {
|
|
|
|
removeVideo() {
|
2023-05-30 13:02:20 +00:00
|
|
|
this.$refs.removeButton.disabled = true;
|
2023-06-16 06:39:44 +00:00
|
|
|
this.removeVideoFromPlaylist(this.playlistId, this.index).then(json => {
|
2023-05-30 13:02:20 +00:00
|
|
|
if (json.error) alert(json.error);
|
|
|
|
else this.$emit("remove");
|
|
|
|
});
|
2022-04-07 02:33:25 +00:00
|
|
|
},
|
2022-09-10 17:08:50 +00:00
|
|
|
shouldShowVideo() {
|
|
|
|
if (!this.isFeed || !this.getPreferenceBoolean("hideWatched", false)) return;
|
|
|
|
|
|
|
|
const objectStore = window.db.transaction("watch_history", "readonly").objectStore("watch_history");
|
2022-11-01 12:12:54 +00:00
|
|
|
const request = objectStore.get(this.item.url.substr(-11));
|
2022-10-02 13:42:49 +00:00
|
|
|
request.onsuccess = event => {
|
|
|
|
const video = event.target.result;
|
|
|
|
if (video && (video.currentTime ?? 0) > video.duration * 0.9) {
|
|
|
|
this.showVideo = false;
|
|
|
|
return;
|
2022-09-10 17:08:50 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
2021-06-16 19:14:46 +00:00
|
|
|
},
|
|
|
|
};
|
2021-07-21 12:32:17 +00:00
|
|
|
</script>
|
2023-07-27 11:46:05 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.shorts-img {
|
|
|
|
@apply w-full object-contain;
|
|
|
|
}
|
|
|
|
</style>
|