From b99b762a39bf70f5680ab1ad08d9c9d5f368f947 Mon Sep 17 00:00:00 2001 From: Luca Date: Sat, 22 Aug 2020 14:57:37 +0200 Subject: [PATCH 1/4] French and Russian, Brazilian portuguese, Languages in alphabetic order Added: French and Russian - Both languages are translated enough to be usable. Fixed: Brazilian portuguese - The YAML file had an underscore instead of a hyphen in its name, so it was not displayed as an optiom Refactored: Languages in alphabetic order - Rearranged the languages according to their alphabetic order, except for english, which is the standard and most used language --- src/renderer/main.js | 2 +- static/locales/{pt_BR.yaml => pt-BR.yaml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename static/locales/{pt_BR.yaml => pt-BR.yaml} (100%) diff --git a/src/renderer/main.js b/src/renderer/main.js index dc79120d..1222c3cb 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -23,7 +23,7 @@ Vue.component('font-awesome-icon', FontAwesomeIcon) Vue.use(VueI18n) // 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 = {} // Take active locales and load respective YAML file diff --git a/static/locales/pt_BR.yaml b/static/locales/pt-BR.yaml similarity index 100% rename from static/locales/pt_BR.yaml rename to static/locales/pt-BR.yaml From 972ed2f1ca0825a35ea6749d5a233094b5c6f868 Mon Sep 17 00:00:00 2001 From: Luca Date: Sat, 22 Aug 2020 16:21:49 +0200 Subject: [PATCH 2/4] Local Video Search Results, List-Video Parsers Added: Local Video Search Results - The results returned from ytdl are now transformed into the same format as with the Invidious API, so that no distinction for these is require Removed List-Video Parsers - The differentiation between Invidious and Local video data in yt-video-list.js is removed because of the transformation --- .../components/ft-list-video/ft-list-video.js | 71 +------------------ src/renderer/views/Search/Search.js | 50 +++++++++++-- 2 files changed, 48 insertions(+), 73 deletions(-) diff --git a/src/renderer/components/ft-list-video/ft-list-video.js b/src/renderer/components/ft-list-video/ft-list-video.js index da3825f7..8f38e1b0 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.js +++ b/src/renderer/components/ft-list-video/ft-list-video.js @@ -140,19 +140,7 @@ export default Vue.extend({ } }, mounted: function () { - // Check if data came from Invidious or from local backend - - 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.parseVideoData() this.checkIfWatched() }, methods: { @@ -243,7 +231,7 @@ export default Vue.extend({ return durationText }, - parseInvidiousData: function () { + parseVideoData: function () { this.id = this.data.videoId this.title = this.data.title // 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 () { const historyIndex = this.historyCache.findIndex((video) => { return video.videoId === this.id diff --git a/src/renderer/views/Search/Search.js b/src/renderer/views/Search/Search.js index ca69def5..c2570a92 100644 --- a/src/renderer/views/Search/Search.js +++ b/src/renderer/views/Search/Search.js @@ -4,6 +4,7 @@ import IsEqual from 'lodash.isequal' import FtLoader from '../../components/ft-loader/ft-loader.vue' import FtCard from '../../components/ft-card/ft-card.vue' import FtElementList from '../../components/ft-element-list/ft-element-list.vue' +import ytTrendScraper from 'yt-trending-scraper' export default Vue.extend({ name: 'Search', @@ -124,12 +125,53 @@ export default Vue.extend({ 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, + test: "test" + } + ) + } else { + returnDataInvidious.push(video) + } + }) if (payload.nextPage) { - this.shownResults = this.shownResults.concat(returnData) + this.shownResults = this.shownResults.concat(returnDataInvidious) } else { - this.shownResults = returnData + this.shownResults = returnDataInvidious } this.nextPageRef = result.nextpageRef @@ -169,7 +211,7 @@ export default Vue.extend({ if (this.searchPage === 1) { this.isLoading = true } - + console.log("DATA 2") console.log(payload) const searchPayload = { From f174fe1c9e61a9aac52449512debefb693d02b91 Mon Sep 17 00:00:00 2001 From: Luca Date: Sat, 22 Aug 2020 16:28:18 +0200 Subject: [PATCH 3/4] Removed debugging log --- src/renderer/views/Search/Search.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/renderer/views/Search/Search.js b/src/renderer/views/Search/Search.js index c2570a92..ef4ee104 100644 --- a/src/renderer/views/Search/Search.js +++ b/src/renderer/views/Search/Search.js @@ -211,7 +211,6 @@ export default Vue.extend({ if (this.searchPage === 1) { this.isLoading = true } - console.log("DATA 2") console.log(payload) const searchPayload = { From b75d378c746713be43df0a0494ecc2fa4d07e888 Mon Sep 17 00:00:00 2001 From: Luca Date: Sat, 22 Aug 2020 16:30:31 +0200 Subject: [PATCH 4/4] Lint Fixes --- src/renderer/views/Search/Search.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/renderer/views/Search/Search.js b/src/renderer/views/Search/Search.js index ef4ee104..96540404 100644 --- a/src/renderer/views/Search/Search.js +++ b/src/renderer/views/Search/Search.js @@ -138,7 +138,7 @@ export default Vue.extend({ if (video.uploaded_at !== null) { publishDate = ytTrendScraper.calculate_published(video.uploaded_at, Date.now()) } - if(video.duration !== null) { + if (video.duration !== null) { videoDuration = ytTrendScraper.calculate_length_in_seconds(video.duration) } returnDataInvidious.push( @@ -159,8 +159,7 @@ export default Vue.extend({ paid: false, premium: false, isUpcoming: false, - timeText: video.duration, - test: "test" + timeText: video.duration } ) } else {