2020-02-16 18:30:00 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import FtListDropdown from '../ft-list-dropdown/ft-list-dropdown.vue'
|
2020-09-20 18:22:39 +00:00
|
|
|
import { shell } from 'electron'
|
2020-02-16 18:30:00 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
name: 'FtElementList',
|
|
|
|
components: {
|
|
|
|
'ft-list-dropdown': FtListDropdown
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
data: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
id: '',
|
2020-05-17 20:12:58 +00:00
|
|
|
randomVideoId: '',
|
2020-02-16 18:30:00 +00:00
|
|
|
title: '',
|
|
|
|
channelThumbnail: '',
|
|
|
|
channelName: '',
|
|
|
|
channelId: '',
|
|
|
|
videoCount: 0,
|
|
|
|
viewCount: 0,
|
|
|
|
lastUpdated: '',
|
|
|
|
description: '',
|
2020-05-17 20:12:58 +00:00
|
|
|
infoSource: '',
|
2020-02-16 18:30:00 +00:00
|
|
|
shareValues: [
|
|
|
|
'copyYoutube',
|
|
|
|
'openYoutube',
|
|
|
|
'copyInvidious',
|
|
|
|
'openInvidious'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2020-05-28 02:48:41 +00:00
|
|
|
invidiousInstance: function () {
|
|
|
|
return this.$store.getters.getInvidiousInstance
|
|
|
|
},
|
2020-06-19 20:20:06 +00:00
|
|
|
|
2020-02-16 18:30:00 +00:00
|
|
|
listType: function () {
|
|
|
|
return this.$store.getters.getListType
|
2020-05-17 20:12:58 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
thumbnailPreference: function () {
|
|
|
|
return this.$store.getters.getThumbnailPreference
|
|
|
|
},
|
|
|
|
|
2020-08-12 03:26:49 +00:00
|
|
|
shareHeaders: function () {
|
|
|
|
return [
|
|
|
|
this.$t('Playlist.Share Playlist.Copy YouTube Link'),
|
|
|
|
this.$t('Playlist.Share Playlist.Open in YouTube'),
|
|
|
|
this.$t('Playlist.Share Playlist.Copy Invidious Link'),
|
|
|
|
this.$t('Playlist.Share Playlist.Open in Invidious')
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2020-05-17 20:12:58 +00:00
|
|
|
thumbnail: function () {
|
|
|
|
switch (this.thumbnailPreference) {
|
|
|
|
case 'start':
|
|
|
|
return `https://i.ytimg.com/vi/${this.randomVideoId}/mq1.jpg`
|
|
|
|
case 'middle':
|
|
|
|
return `https://i.ytimg.com/vi/${this.randomVideoId}/mq2.jpg`
|
|
|
|
case 'end':
|
|
|
|
return `https://i.ytimg.com/vi/${this.randomVideoId}/mq3.jpg`
|
|
|
|
default:
|
|
|
|
return `https://i.ytimg.com/vi/${this.randomVideoId}/mqdefault.jpg`
|
|
|
|
}
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted: function () {
|
|
|
|
console.log(this.data)
|
|
|
|
this.id = this.data.id
|
2020-05-17 20:12:58 +00:00
|
|
|
this.randomVideoId = this.data.randomVideoId
|
2020-02-16 18:30:00 +00:00
|
|
|
this.title = this.data.title
|
|
|
|
this.channelName = this.data.channelName
|
|
|
|
this.channelThumbnail = this.data.channelThumbnail
|
|
|
|
this.uploadedTime = this.data.uploaded_at
|
|
|
|
this.description = this.data.description
|
2020-05-17 20:12:58 +00:00
|
|
|
this.infoSource = this.data.infoSource
|
2020-02-16 18:30:00 +00:00
|
|
|
|
|
|
|
// Causes errors if not put inside of a check
|
|
|
|
if (typeof (this.data.viewCount) !== 'undefined') {
|
|
|
|
this.viewCount = this.data.viewCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof (this.data.videoCount) !== 'undefined') {
|
|
|
|
this.videoCount = this.data.videoCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
|
|
}
|
|
|
|
|
|
|
|
this.lastUpdated = this.data.lastUpdated
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
sharePlaylist: function (method) {
|
|
|
|
const youtubeUrl = `https://youtube.com/playlist?list=${this.id}`
|
2020-05-28 02:48:41 +00:00
|
|
|
const invidiousUrl = `${this.invidiousInstance}/playlist?list=${this.id}`
|
2020-02-16 18:30:00 +00:00
|
|
|
|
|
|
|
switch (method) {
|
|
|
|
case 'copyYoutube':
|
|
|
|
navigator.clipboard.writeText(youtubeUrl)
|
|
|
|
break
|
|
|
|
case 'openYoutube':
|
2020-09-20 18:22:39 +00:00
|
|
|
shell.openExternal(youtubeUrl)
|
2020-02-16 18:30:00 +00:00
|
|
|
break
|
|
|
|
case 'copyInvidious':
|
|
|
|
navigator.clipboard.writeText(invidiousUrl)
|
|
|
|
break
|
|
|
|
case 'openInvidious':
|
2020-09-20 18:22:39 +00:00
|
|
|
shell.openExternal(invidiousUrl)
|
2020-02-16 18:30:00 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|