2020-02-16 18:30:00 +00:00
|
|
|
import Vue from 'vue'
|
2020-08-05 03:44:34 +00:00
|
|
|
import { mapActions } from 'vuex'
|
2020-02-16 18:30:00 +00:00
|
|
|
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-06-06 03:15:44 +00:00
|
|
|
import FtIconButton from '../ft-icon-button/ft-icon-button.vue'
|
2020-06-17 12:15:36 +00:00
|
|
|
import FtShareButton from '../ft-share-button/ft-share-button.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,
|
2020-06-06 03:15:44 +00:00
|
|
|
'ft-flex-box': FtFlexBox,
|
2020-06-17 12:15:36 +00:00
|
|
|
'ft-icon-button': FtIconButton,
|
|
|
|
'ft-share-button': FtShareButton
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
|
|
|
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
|
|
|
|
},
|
2020-06-16 21:42:38 +00:00
|
|
|
published: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
|
|
|
},
|
2020-02-16 18:30:00 +00:00
|
|
|
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-09-11 03:48:06 +00:00
|
|
|
},
|
2020-09-12 03:20:26 +00:00
|
|
|
getTimestamp: {
|
|
|
|
type: Function,
|
|
|
|
required: true
|
2020-09-16 02:07:54 +00:00
|
|
|
},
|
2020-10-31 14:57:51 +00:00
|
|
|
isLive: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
isLiveContent: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
},
|
2020-09-16 02:07:54 +00:00
|
|
|
isUpcoming: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
2020-10-08 19:01:46 +00:00
|
|
|
},
|
|
|
|
downloadLinks: {
|
|
|
|
type: Array,
|
|
|
|
required: true
|
2021-01-13 04:13:36 +00:00
|
|
|
},
|
|
|
|
watchingPlaylist: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
theatrePossible: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
2021-01-14 23:03:23 +00:00
|
|
|
},
|
|
|
|
lengthSeconds: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
formatTypeLabel: 'VIDEO FORMATS',
|
|
|
|
formatTypeValues: [
|
|
|
|
'dash',
|
|
|
|
'legacy',
|
2020-06-01 02:47:22 +00:00
|
|
|
'audio'
|
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-08-31 21:35:22 +00:00
|
|
|
profileList: function () {
|
|
|
|
return this.$store.getters.getProfileList
|
|
|
|
},
|
|
|
|
|
|
|
|
activeProfile: function () {
|
|
|
|
return this.$store.getters.getActiveProfile
|
|
|
|
},
|
|
|
|
|
2020-10-06 13:38:35 +00:00
|
|
|
hideRecommendedVideos: function () {
|
|
|
|
return this.$store.getters.getHideRecommendedVideos
|
|
|
|
},
|
|
|
|
|
2021-01-13 04:13:36 +00:00
|
|
|
hideLiveChat: function () {
|
|
|
|
return this.$store.getters.getHideLiveChat
|
|
|
|
},
|
|
|
|
|
2020-10-08 19:01:46 +00:00
|
|
|
hideVideoLikesAndDislikes: function () {
|
|
|
|
return this.$store.getters.getHideVideoLikesAndDislikes
|
|
|
|
},
|
|
|
|
|
|
|
|
hideVideoViews: function () {
|
|
|
|
return this.$store.getters.getHideVideoViews
|
|
|
|
},
|
|
|
|
|
2021-01-14 23:03:23 +00:00
|
|
|
favoritesPlaylist: function () {
|
|
|
|
return this.$store.getters.getFavorites
|
|
|
|
},
|
|
|
|
|
|
|
|
inFavoritesPlaylist: function () {
|
|
|
|
const index = this.favoritesPlaylist.videos.findIndex((video) => {
|
|
|
|
return video.videoId === this.id
|
|
|
|
})
|
|
|
|
|
|
|
|
return index !== -1
|
|
|
|
},
|
|
|
|
|
|
|
|
favoriteIconTheme: function () {
|
|
|
|
return this.inFavoritesPlaylist ? 'base favorite' : 'base'
|
|
|
|
},
|
|
|
|
|
2020-10-08 19:01:46 +00:00
|
|
|
downloadLinkNames: function () {
|
|
|
|
return this.downloadLinks.map((download) => {
|
|
|
|
return download.label
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
downloadLinkValues: function () {
|
|
|
|
return this.downloadLinks.map((download) => {
|
|
|
|
return download.url
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2020-08-07 00:20:42 +00:00
|
|
|
formatTypeNames: function () {
|
|
|
|
return [
|
|
|
|
this.$t('Change Format.Use Dash Formats').toUpperCase(),
|
|
|
|
this.$t('Change Format.Use Legacy Formats').toUpperCase(),
|
|
|
|
this.$t('Change Format.Use Audio Formats').toUpperCase()
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2020-02-16 18:30:00 +00:00
|
|
|
totalLikeCount: function () {
|
|
|
|
return this.likeCount + this.dislikeCount
|
|
|
|
},
|
|
|
|
|
|
|
|
likePercentageRatio: function () {
|
|
|
|
return parseInt(this.likeCount / this.totalLikeCount * 100)
|
|
|
|
},
|
|
|
|
|
|
|
|
parsedViewCount: function () {
|
2020-10-06 02:27:32 +00:00
|
|
|
if (this.hideVideoViews) {
|
|
|
|
return null
|
|
|
|
}
|
2020-08-07 00:20:42 +00:00
|
|
|
return this.viewCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ` ${this.$t('Video.Views').toLowerCase()}`
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
|
|
|
|
2020-08-31 21:35:22 +00:00
|
|
|
isSubscribed: function () {
|
|
|
|
const subIndex = this.profileList[this.activeProfile].subscriptions.findIndex((channel) => {
|
|
|
|
return channel.id === this.channelId
|
|
|
|
})
|
|
|
|
|
|
|
|
if (subIndex === -1) {
|
|
|
|
return false
|
|
|
|
} else {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-02-16 18:30:00 +00:00
|
|
|
subscribedText: function () {
|
2020-08-31 21:35:22 +00:00
|
|
|
if (this.isSubscribed) {
|
|
|
|
return `${this.$t('Channel.Unsubscribe').toUpperCase()} ${this.subscriptionCountText}`
|
|
|
|
} else {
|
|
|
|
return `${this.$t('Channel.Subscribe').toUpperCase()} ${this.subscriptionCountText}`
|
|
|
|
}
|
2020-06-19 13:43:08 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
dateString() {
|
|
|
|
const date = new Date(this.published)
|
|
|
|
const dateSplit = date.toDateString().split(' ')
|
2020-08-07 00:20:42 +00:00
|
|
|
const localeDateString = `Video.Published.${dateSplit[1]}`
|
|
|
|
return `${this.$t(localeDateString)} ${dateSplit[2]}, ${dateSplit[3]}`
|
2020-10-31 14:57:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
publishedString() {
|
|
|
|
if (this.isLiveContent && this.isLive) {
|
|
|
|
return this.$t('Video.Started streaming on')
|
|
|
|
} else if (this.isLiveContent && !this.isLive) {
|
|
|
|
return this.$t('Video.Streamed on')
|
|
|
|
} else {
|
|
|
|
return this.$t('Video.Published on')
|
|
|
|
}
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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
|
|
|
},
|
|
|
|
|
2021-01-14 23:03:23 +00:00
|
|
|
toggleSave: function () {
|
|
|
|
if (this.inFavoritesPlaylist) {
|
|
|
|
this.removeFromPlaylist()
|
|
|
|
} else {
|
|
|
|
this.addToPlaylist()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-02-16 18:30:00 +00:00
|
|
|
handleSubscription: function () {
|
2020-12-02 18:36:08 +00:00
|
|
|
if (this.channelId === '') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-08-31 21:35:22 +00:00
|
|
|
const currentProfile = JSON.parse(JSON.stringify(this.profileList[this.activeProfile]))
|
|
|
|
const primaryProfile = JSON.parse(JSON.stringify(this.profileList[0]))
|
|
|
|
|
|
|
|
if (this.isSubscribed) {
|
|
|
|
currentProfile.subscriptions = currentProfile.subscriptions.filter((channel) => {
|
|
|
|
return channel.id !== this.channelId
|
|
|
|
})
|
|
|
|
|
|
|
|
this.updateProfile(currentProfile)
|
|
|
|
this.showToast({
|
2020-09-16 12:51:24 +00:00
|
|
|
message: this.$t('Channel.Channel has been removed from your subscriptions')
|
2020-08-31 21:35:22 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
if (this.activeProfile === 0) {
|
|
|
|
// Check if a subscription exists in a different profile.
|
|
|
|
// Remove from there as well.
|
|
|
|
let duplicateSubscriptions = 0
|
|
|
|
|
|
|
|
this.profileList.forEach((profile) => {
|
|
|
|
if (profile._id === 'allChannels') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const parsedProfile = JSON.parse(JSON.stringify(profile))
|
|
|
|
const index = parsedProfile.subscriptions.findIndex((channel) => {
|
|
|
|
return channel.id === this.channelId
|
|
|
|
})
|
|
|
|
|
|
|
|
if (index !== -1) {
|
|
|
|
duplicateSubscriptions++
|
|
|
|
|
|
|
|
parsedProfile.subscriptions = parsedProfile.subscriptions.filter((x) => {
|
|
|
|
return x.id !== this.channelId
|
|
|
|
})
|
|
|
|
|
|
|
|
this.updateProfile(parsedProfile)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
if (duplicateSubscriptions > 0) {
|
2020-09-16 12:51:24 +00:00
|
|
|
const message = this.$t('Channel.Removed subscription from $ other channel(s)')
|
2020-08-31 21:35:22 +00:00
|
|
|
this.showToast({
|
2020-09-16 12:51:24 +00:00
|
|
|
message: message.replace('$', duplicateSubscriptions)
|
2020-08-31 21:35:22 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const subscription = {
|
|
|
|
id: this.channelId,
|
|
|
|
name: this.channelName,
|
|
|
|
thumbnail: this.channelThumbnail
|
|
|
|
}
|
|
|
|
currentProfile.subscriptions.push(subscription)
|
|
|
|
|
|
|
|
this.updateProfile(currentProfile)
|
|
|
|
this.showToast({
|
2020-09-16 12:51:24 +00:00
|
|
|
message: this.$t('Channel.Added channel to your subscriptions')
|
2020-08-31 21:35:22 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
if (this.activeProfile !== 0) {
|
|
|
|
const index = primaryProfile.subscriptions.findIndex((channel) => {
|
|
|
|
return channel.id === this.channelId
|
|
|
|
})
|
|
|
|
|
|
|
|
if (index === -1) {
|
|
|
|
primaryProfile.subscriptions.push(subscription)
|
|
|
|
this.updateProfile(primaryProfile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
|
|
|
|
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-08-05 03:44:34 +00:00
|
|
|
},
|
|
|
|
|
2020-10-08 19:01:46 +00:00
|
|
|
handleDownloadLink: function (url) {
|
|
|
|
const shell = require('electron').shell
|
|
|
|
shell.openExternal(url)
|
|
|
|
},
|
|
|
|
|
2021-01-14 23:03:23 +00:00
|
|
|
addToPlaylist: function () {
|
|
|
|
const videoData = {
|
|
|
|
videoId: this.id,
|
|
|
|
title: this.title,
|
|
|
|
author: this.channelName,
|
|
|
|
authorId: this.channelId,
|
|
|
|
published: '',
|
|
|
|
description: this.description,
|
|
|
|
viewCount: this.viewCount,
|
|
|
|
lengthSeconds: this.lengthSeconds,
|
|
|
|
timeAdded: new Date().getTime(),
|
|
|
|
isLive: false,
|
|
|
|
paid: false,
|
|
|
|
type: 'video'
|
|
|
|
}
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
playlistName: 'Favorites',
|
|
|
|
videoData: videoData
|
|
|
|
}
|
|
|
|
|
|
|
|
this.addVideo(payload)
|
|
|
|
|
|
|
|
this.showToast({
|
2021-01-15 03:37:52 +00:00
|
|
|
message: this.$t('Video.Video has been saved')
|
2021-01-14 23:03:23 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
removeFromPlaylist: function () {
|
|
|
|
const payload = {
|
|
|
|
playlistName: 'Favorites',
|
|
|
|
videoId: this.id
|
|
|
|
}
|
|
|
|
|
|
|
|
this.removeVideo(payload)
|
2021-01-15 03:37:52 +00:00
|
|
|
|
|
|
|
this.showToast({
|
|
|
|
message: this.$t('Video.Video has been removed from your saved list')
|
|
|
|
})
|
2021-01-14 23:03:23 +00:00
|
|
|
},
|
|
|
|
|
2020-08-05 03:44:34 +00:00
|
|
|
...mapActions([
|
2020-08-31 21:35:22 +00:00
|
|
|
'showToast',
|
2021-01-14 23:03:23 +00:00
|
|
|
'updateProfile',
|
|
|
|
'addVideo',
|
|
|
|
'removeVideo'
|
2020-08-05 03:44:34 +00:00
|
|
|
])
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
})
|