2020-02-16 18:30:00 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import FtCard from '../ft-card/ft-card.vue'
|
|
|
|
import FtButton from '../ft-button/ft-button.vue'
|
|
|
|
import FtListDropdown from '../ft-list-dropdown/ft-list-dropdown.vue'
|
|
|
|
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
|
2020-03-24 13:22:29 +00:00
|
|
|
// import { shell } from 'electron'
|
2020-02-16 18:30:00 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
name: 'WatchVideoInfo',
|
|
|
|
components: {
|
|
|
|
'ft-card': FtCard,
|
|
|
|
'ft-button': FtButton,
|
|
|
|
'ft-list-dropdown': FtListDropdown,
|
|
|
|
'ft-flex-box': FtFlexBox
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
channelId: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
channelName: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
channelThumbnail: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
viewCount: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
subscriptionCountText: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
likeCount: {
|
|
|
|
type: Number,
|
2020-05-17 20:12:58 +00:00
|
|
|
default: 0
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
|
|
|
dislikeCount: {
|
|
|
|
type: Number,
|
2020-05-17 20:12:58 +00:00
|
|
|
default: 0
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
formatTypeLabel: 'VIDEO FORMATS',
|
|
|
|
formatTypeNames: [
|
|
|
|
'USE DASH FORMATS',
|
2020-06-01 02:47:22 +00:00
|
|
|
'USE LEGACY FORMATS',
|
|
|
|
'USE AUDIO FORMATS'
|
2020-02-16 18:30:00 +00:00
|
|
|
],
|
|
|
|
formatTypeValues: [
|
|
|
|
'dash',
|
|
|
|
'legacy',
|
2020-06-01 02:47:22 +00:00
|
|
|
'audio'
|
2020-02-16 18:30:00 +00:00
|
|
|
],
|
|
|
|
shareLabel: 'SHARE VIDEO',
|
|
|
|
shareNames: [
|
|
|
|
'COPY INVIDIOUS LINK',
|
|
|
|
'OPEN INVIDIOUS LINK',
|
|
|
|
'COPY YOUTUBE LINK',
|
2020-05-28 02:48:41 +00:00
|
|
|
'OPEN YOUTUBE LINK'
|
2020-02-16 18:30:00 +00:00
|
|
|
],
|
|
|
|
shareValues: [
|
|
|
|
'copyInvidious',
|
|
|
|
'openInvidious',
|
|
|
|
'copyYoutube',
|
2020-05-28 02:48:41 +00:00
|
|
|
'openYoutube'
|
2020-02-16 18:30:00 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
invidiousInstance: function () {
|
|
|
|
return this.$store.getters.getInvidiousInstance
|
|
|
|
},
|
|
|
|
|
2020-05-17 20:12:58 +00:00
|
|
|
usingElectron: function () {
|
|
|
|
return this.$store.getters.getUsingElectron
|
|
|
|
},
|
|
|
|
|
2020-02-16 18:30:00 +00:00
|
|
|
invidiousUrl: function () {
|
|
|
|
return `${this.invidiousInstance}/watch?v=${this.id}`
|
|
|
|
},
|
|
|
|
|
|
|
|
youtubeUrl: function () {
|
|
|
|
return `https://www.youtube.com/watch?v=${this.id}`
|
|
|
|
},
|
|
|
|
|
|
|
|
youtubeEmbedUrl: function () {
|
|
|
|
return `https://www.youtube-nocookie.com/embed/${this.id}`
|
|
|
|
},
|
|
|
|
|
|
|
|
totalLikeCount: function () {
|
|
|
|
return this.likeCount + this.dislikeCount
|
|
|
|
},
|
|
|
|
|
|
|
|
likePercentageRatio: function () {
|
|
|
|
return parseInt(this.likeCount / this.totalLikeCount * 100)
|
|
|
|
},
|
|
|
|
|
|
|
|
parsedViewCount: function () {
|
|
|
|
return this.viewCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' views'
|
|
|
|
},
|
|
|
|
|
|
|
|
subscribedText: function () {
|
|
|
|
return `SUBSCRIBE ${this.subscriptionCountText}`
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
goToChannel: function () {
|
2020-05-17 20:12:58 +00:00
|
|
|
this.$router.push({ path: `/channel/${this.channelId}` })
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
handleSubscription: function () {
|
|
|
|
console.log('TODO: Handle subscription logic')
|
|
|
|
},
|
|
|
|
|
2020-02-19 03:31:10 +00:00
|
|
|
handleFormatChange: function (format) {
|
|
|
|
switch (format) {
|
|
|
|
case 'dash':
|
|
|
|
this.$parent.enableDashFormat()
|
|
|
|
break
|
|
|
|
case 'legacy':
|
|
|
|
this.$parent.enableLegacyFormat()
|
|
|
|
break
|
2020-06-01 02:47:22 +00:00
|
|
|
case 'audio':
|
|
|
|
this.$parent.enableAudioFormat()
|
|
|
|
break
|
2020-02-19 03:31:10 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-02-16 18:30:00 +00:00
|
|
|
handleShare: function (method) {
|
|
|
|
console.log('Handling share')
|
|
|
|
|
|
|
|
switch (method) {
|
|
|
|
case 'copyYoutube':
|
|
|
|
navigator.clipboard.writeText(this.youtubeUrl)
|
|
|
|
break
|
|
|
|
case 'openYoutube':
|
2020-05-17 20:12:58 +00:00
|
|
|
if (this.usingElectron) {
|
|
|
|
const shell = require('electron').shell
|
|
|
|
shell.openExternal(this.youtubeUrl)
|
|
|
|
}
|
2020-02-16 18:30:00 +00:00
|
|
|
break
|
|
|
|
case 'copyYoutubeEmbed':
|
|
|
|
navigator.clipboard.writeText(this.youtubeEmbedUrl)
|
|
|
|
break
|
|
|
|
case 'openYoutubeEmbed':
|
2020-05-17 20:12:58 +00:00
|
|
|
if (this.usingElectron) {
|
|
|
|
const shell = require('electron').shell
|
|
|
|
shell.openExternal(this.youtubeEmbedUrl)
|
|
|
|
}
|
2020-02-16 18:30:00 +00:00
|
|
|
break
|
|
|
|
case 'copyInvidious':
|
|
|
|
navigator.clipboard.writeText(this.invidiousUrl)
|
|
|
|
break
|
|
|
|
case 'openInvidious':
|
2020-05-17 20:12:58 +00:00
|
|
|
if (this.usingElectron) {
|
|
|
|
const shell = require('electron').shell
|
|
|
|
shell.openExternal(this.invidiousUrl)
|
|
|
|
}
|
2020-02-16 18:30:00 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|