Merge pull request #92 from GilgusMaximus/master

French and Russian, Brazilian portuguese, Languages in alphabetic order, Video inconsistency Fix
This commit is contained in:
Preston 2020-08-22 13:53:42 -04:00 committed by GitHub
commit 7524dc9010
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 74 deletions

View File

@ -140,19 +140,7 @@ export default Vue.extend({
} }
}, },
mounted: function () { mounted: function () {
// Check if data came from Invidious or from local backend this.parseVideoData()
if (typeof (this.data.descriptionHtml) !== 'undefined' ||
typeof (this.data.index) !== 'undefined' ||
typeof (this.data.authorId) !== 'undefined' ||
typeof (this.data.publishedText) !== 'undefined' ||
typeof (this.data.authorThumbnails) === 'object'
) {
this.parseInvidiousData()
} else {
this.parseLocalData()
}
this.checkIfWatched() this.checkIfWatched()
}, },
methods: { methods: {
@ -243,7 +231,7 @@ export default Vue.extend({
return durationText return durationText
}, },
parseInvidiousData: function () { parseVideoData: function () {
this.id = this.data.videoId this.id = this.data.videoId
this.title = this.data.title this.title = this.data.title
// this.thumbnail = this.data.videoThumbnails[4].url // this.thumbnail = this.data.videoThumbnails[4].url
@ -281,61 +269,6 @@ export default Vue.extend({
} }
}, },
parseLocalData: function () {
if (typeof (this.data.id) !== 'undefined') {
this.id = this.data.id
} else {
this.id = this.data.link.replace('https://www.youtube.com/watch?v=', '')
}
this.title = this.data.title
if (typeof (this.data.author) === 'string') {
this.channelName = this.data.author
this.channelId = this.data.ucid
this.viewCount = this.data.views
// Data is returned as a literal string named 'undefined'
if (this.data.length_seconds !== 'undefined') {
this.duration = this.calculateVideoDuration(parseInt(this.data.length_seconds))
}
} else {
this.channelName = this.data.author.name
this.duration = this.data.duration
this.description = this.data.description
this.channelId = this.data.author.ref.replace('https://www.youtube.com/user/', '')
this.channelId = this.channelId.replace('https://www.youtube.com/channel/', '')
}
if (typeof (this.data.uploaded_at) !== 'undefined' && !this.data.live) {
this.toLocalePublicationString({
publishText: this.data.uploaded_at,
templateString: this.$t('Video.Publicationtemplate'),
timeStrings: this.$t('Video.Published'),
liveStreamString: this.$t('Video.Watching'),
upcomingString: this.$t('Video.Published.Upcoming'),
isLive: this.data.live,
isUpcoming: false
}).then((data) => {
this.uploadedTime = data
}).catch((error) => {
console.error(error)
})
this.uploadedTime = this.data.uploaded_at
}
if (this.data.views !== null && typeof (this.data.views) !== 'undefined') {
this.parsedViewCount = this.data.views.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
} else if (typeof (this.data.view_count) !== 'undefined') {
const viewCount = this.data.view_count.replace(',', '')
this.parsedViewCount = viewCount.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
} else {
this.hideViews = true
}
this.isLive = this.data.live
},
checkIfWatched: function () { checkIfWatched: function () {
const historyIndex = this.historyCache.findIndex((video) => { const historyIndex = this.historyCache.findIndex((video) => {
return video.videoId === this.id return video.videoId === this.id

View File

@ -23,7 +23,7 @@ Vue.component('font-awesome-icon', FontAwesomeIcon)
Vue.use(VueI18n) Vue.use(VueI18n)
// List of locales approved for use // List of locales approved for use
const activeLocales = ['en-US', 'de-DE', 'pt-PT', 'fi', 'pt-BR', 'vi', 'zh-CN', 'zh-TW'] const activeLocales = ['en-US', 'de-DE', 'fi', 'fr-FR', 'pt-BR', 'pt-PT', 'ru', 'vi', 'zh-CN', 'zh-TW']
const messages = {} const messages = {}
// Take active locales and load respective YAML file // Take active locales and load respective YAML file

View File

@ -4,6 +4,7 @@ import IsEqual from 'lodash.isequal'
import FtLoader from '../../components/ft-loader/ft-loader.vue' import FtLoader from '../../components/ft-loader/ft-loader.vue'
import FtCard from '../../components/ft-card/ft-card.vue' import FtCard from '../../components/ft-card/ft-card.vue'
import FtElementList from '../../components/ft-element-list/ft-element-list.vue' import FtElementList from '../../components/ft-element-list/ft-element-list.vue'
import ytTrendScraper from 'yt-trending-scraper'
export default Vue.extend({ export default Vue.extend({
name: 'Search', name: 'Search',
@ -124,12 +125,52 @@ export default Vue.extend({
return item.type === 'video' || item.type === 'channel' || item.type === 'playlist' return item.type === 'video' || item.type === 'channel' || item.type === 'playlist'
}) })
console.log(returnData) const returnDataInvidious = []
returnData.forEach((video) => {
if (video.type === 'video') {
let authId = video.author.ref.match(/user(.)*/)
let publishDate = null
let videoDuration = null
const videoId = video.link.match(/\?v=(.)*/)[0].split('=')[1]
if (authId === null) {
authId = video.author.ref.match(/channel(.)*/)
}
if (video.uploaded_at !== null) {
publishDate = ytTrendScraper.calculate_published(video.uploaded_at, Date.now())
}
if (video.duration !== null) {
videoDuration = ytTrendScraper.calculate_length_in_seconds(video.duration)
}
returnDataInvidious.push(
{
videoId: videoId,
title: video.title,
type: 'video',
author: video.author.name,
authorId: authId,
authorUrl: video.author.ref,
videoThumbnails: video.thumbnail,
description: video.description,
viewCount: video.views,
published: publishDate,
publishedText: video.uploaded_at,
lengthSeconds: videoDuration,
liveNow: video.live,
paid: false,
premium: false,
isUpcoming: false,
timeText: video.duration
}
)
} else {
returnDataInvidious.push(video)
}
})
if (payload.nextPage) { if (payload.nextPage) {
this.shownResults = this.shownResults.concat(returnData) this.shownResults = this.shownResults.concat(returnDataInvidious)
} else { } else {
this.shownResults = returnData this.shownResults = returnDataInvidious
} }
this.nextPageRef = result.nextpageRef this.nextPageRef = result.nextpageRef
@ -169,7 +210,6 @@ export default Vue.extend({
if (this.searchPage === 1) { if (this.searchPage === 1) {
this.isLoading = true this.isLoading = true
} }
console.log(payload) console.log(payload)
const searchPayload = { const searchPayload = {