2023-01-18 08:50:02 +01:00
|
|
|
import { defineComponent } from 'vue'
|
2023-02-01 21:38:27 +01:00
|
|
|
import FtShareButton from '../ft-share-button/ft-share-button.vue'
|
2023-01-15 11:43:29 +01:00
|
|
|
import { copyToClipboard, formatNumber, openExternalLink } from '../../helpers/utils'
|
2020-02-16 19:30:00 +01:00
|
|
|
|
2023-01-18 08:50:02 +01:00
|
|
|
export default defineComponent({
|
2021-06-15 16:42:00 +02:00
|
|
|
name: 'PlaylistInfo',
|
2020-02-16 19:30:00 +01:00
|
|
|
components: {
|
2023-02-01 21:38:27 +01:00
|
|
|
'ft-share-button': FtShareButton
|
2020-02-16 19:30:00 +01:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
data: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
id: '',
|
2021-06-15 16:42:00 +02:00
|
|
|
firstVideoId: '',
|
2023-06-30 18:18:43 +02:00
|
|
|
playlistThumbnail: '',
|
2020-02-16 19:30:00 +01:00
|
|
|
title: '',
|
|
|
|
channelThumbnail: '',
|
|
|
|
channelName: '',
|
2023-08-05 01:30:54 +02:00
|
|
|
channelId: null,
|
2020-02-16 19:30:00 +01:00
|
|
|
videoCount: 0,
|
|
|
|
viewCount: 0,
|
|
|
|
lastUpdated: '',
|
|
|
|
description: '',
|
2023-02-01 21:38:27 +01:00
|
|
|
infoSource: ''
|
2020-02-16 19:30:00 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2022-06-21 08:14:15 +02:00
|
|
|
hideSharingActions: function() {
|
|
|
|
return this.$store.getters.getHideSharingActions
|
|
|
|
},
|
|
|
|
|
2021-07-03 03:55:56 +02:00
|
|
|
currentInvidiousInstance: function () {
|
|
|
|
return this.$store.getters.getCurrentInvidiousInstance
|
2020-05-28 04:48:41 +02:00
|
|
|
},
|
2020-06-19 22:20:06 +02:00
|
|
|
|
2020-05-17 22:12:58 +02:00
|
|
|
thumbnailPreference: function () {
|
|
|
|
return this.$store.getters.getThumbnailPreference
|
|
|
|
},
|
|
|
|
|
2023-08-31 17:18:52 +02:00
|
|
|
blurThumbnails: function () {
|
|
|
|
return this.$store.getters.getBlurThumbnails
|
|
|
|
},
|
|
|
|
|
|
|
|
blurThumbnailsStyle: function () {
|
|
|
|
return this.blurThumbnails ? 'blur(20px)' : null
|
|
|
|
},
|
|
|
|
|
2023-05-23 14:24:03 +02:00
|
|
|
backendPreference: function () {
|
|
|
|
return this.$store.getters.getBackendPreference
|
|
|
|
},
|
|
|
|
|
2022-02-04 00:11:29 +01:00
|
|
|
hideViews: function () {
|
|
|
|
return this.$store.getters.getHideVideoViews
|
|
|
|
},
|
2020-08-12 05:26:49 +02:00
|
|
|
|
2020-05-17 22:12:58 +02:00
|
|
|
thumbnail: function () {
|
2023-08-31 17:18:52 +02:00
|
|
|
if (this.thumbnailPreference === 'hidden') {
|
|
|
|
return require('../../assets/img/thumbnail_placeholder.svg')
|
|
|
|
}
|
2023-05-23 14:24:03 +02:00
|
|
|
let baseUrl
|
|
|
|
if (this.backendPreference === 'invidious') {
|
|
|
|
baseUrl = this.currentInvidiousInstance
|
|
|
|
} else {
|
2023-06-30 18:18:43 +02:00
|
|
|
return this.data.playlistThumbnail
|
2023-05-23 14:24:03 +02:00
|
|
|
}
|
|
|
|
|
2020-05-17 22:12:58 +02:00
|
|
|
switch (this.thumbnailPreference) {
|
|
|
|
case 'start':
|
2023-05-23 14:24:03 +02:00
|
|
|
return `${baseUrl}/vi/${this.firstVideoId}/mq1.jpg`
|
2020-05-17 22:12:58 +02:00
|
|
|
case 'middle':
|
2023-05-23 14:24:03 +02:00
|
|
|
return `${baseUrl}/vi/${this.firstVideoId}/mq2.jpg`
|
2020-05-17 22:12:58 +02:00
|
|
|
case 'end':
|
2023-05-23 14:24:03 +02:00
|
|
|
return `${baseUrl}/vi/${this.firstVideoId}/mq3.jpg`
|
2020-05-17 22:12:58 +02:00
|
|
|
default:
|
2023-05-23 14:24:03 +02:00
|
|
|
return `${baseUrl}/vi/${this.firstVideoId}/mqdefault.jpg`
|
2020-05-17 22:12:58 +02:00
|
|
|
}
|
2020-02-16 19:30:00 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted: function () {
|
|
|
|
this.id = this.data.id
|
2021-06-15 16:42:00 +02:00
|
|
|
this.firstVideoId = this.data.firstVideoId
|
2020-02-16 19:30:00 +01:00
|
|
|
this.title = this.data.title
|
|
|
|
this.channelName = this.data.channelName
|
|
|
|
this.channelThumbnail = this.data.channelThumbnail
|
2021-06-15 16:18:08 +02:00
|
|
|
this.channelId = this.data.channelId
|
2020-02-16 19:30:00 +01:00
|
|
|
this.uploadedTime = this.data.uploaded_at
|
|
|
|
this.description = this.data.description
|
2020-05-17 22:12:58 +02:00
|
|
|
this.infoSource = this.data.infoSource
|
2020-02-16 19:30:00 +01:00
|
|
|
|
|
|
|
// Causes errors if not put inside of a check
|
2022-12-13 14:19:16 +01:00
|
|
|
if (typeof (this.data.viewCount) !== 'undefined' && !isNaN(this.data.viewCount)) {
|
2023-01-15 11:43:29 +01:00
|
|
|
this.viewCount = this.hideViews ? null : formatNumber(this.data.viewCount)
|
2020-02-16 19:30:00 +01:00
|
|
|
}
|
|
|
|
|
2022-12-13 14:19:16 +01:00
|
|
|
if (typeof (this.data.videoCount) !== 'undefined' && !isNaN(this.data.videoCount)) {
|
2023-01-15 11:43:29 +01:00
|
|
|
this.videoCount = formatNumber(this.data.videoCount)
|
2020-02-16 19:30:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.lastUpdated = this.data.lastUpdated
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
sharePlaylist: function (method) {
|
|
|
|
const youtubeUrl = `https://youtube.com/playlist?list=${this.id}`
|
2021-07-03 03:55:56 +02:00
|
|
|
const invidiousUrl = `${this.currentInvidiousInstance}/playlist?list=${this.id}`
|
2020-02-16 19:30:00 +01:00
|
|
|
|
|
|
|
switch (method) {
|
|
|
|
case 'copyYoutube':
|
2022-10-18 10:15:28 +02:00
|
|
|
copyToClipboard(youtubeUrl, { messageOnSuccess: this.$t('Share.YouTube URL copied to clipboard') })
|
2020-02-16 19:30:00 +01:00
|
|
|
break
|
|
|
|
case 'openYoutube':
|
2022-10-18 10:15:28 +02:00
|
|
|
openExternalLink(youtubeUrl)
|
2020-02-16 19:30:00 +01:00
|
|
|
break
|
|
|
|
case 'copyInvidious':
|
2022-10-18 10:15:28 +02:00
|
|
|
copyToClipboard(invidiousUrl, { messageOnSuccess: this.$t('Share.Invidious URL copied to clipboard') })
|
2020-02-16 19:30:00 +01:00
|
|
|
break
|
|
|
|
case 'openInvidious':
|
2022-10-18 10:15:28 +02:00
|
|
|
openExternalLink(invidiousUrl)
|
2020-02-16 19:30:00 +01:00
|
|
|
break
|
|
|
|
}
|
2022-10-18 10:15:28 +02:00
|
|
|
}
|
2020-02-16 19:30:00 +01:00
|
|
|
}
|
|
|
|
})
|