Start progress on fixing Search and Playlist for local API

This commit is contained in:
Preston 2020-12-13 23:17:43 -05:00
parent 0c8d510028
commit cb8cf1ef43
7 changed files with 39 additions and 47 deletions

18
package-lock.json generated
View File

@ -8962,9 +8962,9 @@
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
}, },
"ini": { "ini": {
"version": "1.3.7", "version": "1.3.8",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
"integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==", "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
"dev": true "dev": true
}, },
"internal-ip": { "internal-ip": {
@ -18576,9 +18576,9 @@
} }
}, },
"ytpl": { "ytpl": {
"version": "2.0.0-alpha.3", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/ytpl/-/ytpl-2.0.0-alpha.3.tgz", "resolved": "https://registry.npmjs.org/ytpl/-/ytpl-2.0.1.tgz",
"integrity": "sha512-c6I6Qc8NxJi2ZgCyNFnBBrGGw3tuBa1+ksMZTG7G8ltZN26wluvgSn9ZW2Xki4DzECdx4k0Bcm5fEvwwOEQsww==", "integrity": "sha512-FK6Qz43PKDqKcxI8K9tEOMJ7S/MVN6Ofc9flolPloMN4hJm+N6wZd3Y9oD+amQYHMCVkaXT0BvPMY4BUYg3FpQ==",
"requires": { "requires": {
"html-entities": "^1.3.1", "html-entities": "^1.3.1",
"miniget": "^4.1.0" "miniget": "^4.1.0"
@ -18592,9 +18592,9 @@
} }
}, },
"ytsr": { "ytsr": {
"version": "2.0.0-alpha.4", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/ytsr/-/ytsr-2.0.0-alpha.4.tgz", "resolved": "https://registry.npmjs.org/ytsr/-/ytsr-2.0.1.tgz",
"integrity": "sha512-iEXOu0kFwxr9O+mpG3tnZa6TovEOZ92N0rNmyZFEv5EdcFg9FWH8MEUJVMExCFhSYu1rSFv5napQCzDCozizdg==", "integrity": "sha512-1m/jmX8X1PJSnX1eJ3sm3s8Z2S/ixYKTZduuLsGn/RsxEI9nqV2iWCRi0qTQ8rOSaoEwkeWcJHLlZPbd499p/w==",
"requires": { "requires": {
"html-entities": "^1.3.1", "html-entities": "^1.3.1",
"miniget": "^4.1.0" "miniget": "^4.1.0"

View File

@ -48,8 +48,8 @@
"yt-trending-scraper": "^1.0.4", "yt-trending-scraper": "^1.0.4",
"yt-xml2vtt": "^1.1.3", "yt-xml2vtt": "^1.1.3",
"ytdl-core": "^4.1.4", "ytdl-core": "^4.1.4",
"ytpl": "^2.0.0-alpha.3", "ytpl": "^2.0.0",
"ytsr": "^2.0.0-alpha.4" "ytsr": "^2.0.0"
}, },
"description": "A private YouTube client", "description": "A private YouTube client",
"devDependencies": { "devDependencies": {

View File

@ -35,7 +35,7 @@ export default Vue.extend({
} }
}, },
mounted: function () { mounted: function () {
if (typeof (this.data.avatar) !== 'undefined') { if (typeof (this.data.avatars) !== 'undefined') {
this.parseLocalData() this.parseLocalData()
} else { } else {
this.parseInvidiousData() this.parseInvidiousData()
@ -43,18 +43,18 @@ export default Vue.extend({
}, },
methods: { methods: {
parseLocalData: function () { parseLocalData: function () {
this.thumbnail = this.data.avatar this.thumbnail = this.data.bestAvatar.url
if (!this.thumbnail.includes('https:')) { if (!this.thumbnail.includes('https:')) {
this.thumbnail = `https:${this.thumbnail}` this.thumbnail = `https:${this.thumbnail}`
} }
this.channelName = this.data.name this.channelName = this.data.name
this.id = this.data.channel_id this.id = this.data.channelID
if (this.hideChannelSubscriptions) { if (this.hideChannelSubscriptions) {
this.subscriberCount = null this.subscriberCount = null
} else { } else {
this.subscriberCount = this.data.followers.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') this.subscriberCount = this.data.subscribers.replace(/ subscriber(s)?/, '')
} }
this.videoCount = this.data.videos.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') this.videoCount = this.data.videos.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
this.description = this.data.description_short this.description = this.data.description_short

View File

@ -43,7 +43,7 @@ export default Vue.extend({
} }
}, },
mounted: function () { mounted: function () {
if (typeof (this.data.author) === 'object') { if (typeof (this.data.owner) === 'object') {
this.parseLocalData() this.parseLocalData()
} else { } else {
this.parseInvidiousData() this.parseInvidiousData()
@ -61,11 +61,11 @@ export default Vue.extend({
parseLocalData: function () { parseLocalData: function () {
this.title = this.data.title this.title = this.data.title
this.thumbnail = this.data.thumbnail this.thumbnail = this.data.firstVideo.bestThumbnail.url
this.channelName = this.data.author.name this.channelName = this.data.owner.name
this.channelLink = this.data.author.ref this.channelLink = this.data.owner.url
this.playlistLink = this.data.link this.playlistLink = this.data.url
this.videoCount = parseInt(this.data.length.split(' ')[0]) this.videoCount = this.data.length
} }
} }
}) })

View File

@ -283,17 +283,17 @@ export default Vue.extend({
this.playlistTitle = result.title this.playlistTitle = result.title
this.playlistItems = result.items this.playlistItems = result.items
this.videoCount = result.total_items this.videoCount = result.estimatedItemCount
this.channelName = '' // result.author.name this.channelName = result.author.name
this.channelThumbnail = '' // result.author.avatar this.channelThumbnail = result.author.bestAvatar.url
this.channelId = '' // result.author.id this.channelId = result.author.channelID
this.playlistItems = result.items.filter((video) => { this.playlistItems = result.items.filter((video) => {
return !(video.title === '[Private video]' || video.title === '[Deleted video]') return !(video.title === '[Private video]' || video.title === '[Deleted video]')
}).map((video) => { }).map((video) => {
if (typeof video.author !== 'undefined') { if (typeof video.author !== 'undefined') {
const channelName = video.author.name const channelName = video.author.name
const channelId = video.author.ref.replace(/https:\/\/(www\.)?youtube\.com\/(user|channel)\//g, '') const channelId = video.author.channelID
video.author = channelName video.author = channelName
video.authorId = channelId video.authorId = channelId
} else { } else {

View File

@ -78,7 +78,7 @@ export default Vue.extend({
console.log('done') console.log('done')
console.log(result) console.log(result)
const randomVideoIndex = Math.floor((Math.random() * result.items.length) + 1) const randomVideoIndex = Math.floor((Math.random() * result.items.length))
this.infoData = { this.infoData = {
id: result.id, id: result.id,
@ -86,18 +86,18 @@ export default Vue.extend({
description: result.description ? result.description : '', description: result.description ? result.description : '',
randomVideoId: result.items[randomVideoIndex].id, randomVideoId: result.items[randomVideoIndex].id,
viewCount: result.views, viewCount: result.views,
videoCount: result.estimated_items, videoCount: result.estimatedItemCount,
// lastUpdated: result.last_updated ? result.last_updated : '', lastUpdated: result.lastUpdated ? result.lastUpdated : '',
// channelName: result.author ? result.author.name : '', channelName: result.author ? result.author.name : '',
// channelThumbnail: result.author ? result.author.avatar : '', channelThumbnail: result.author ? result.author.bestAvatar.url : '',
// channelId: result.author ? result.author.id : '', channelId: result.author ? result.author.channelID : '',
infoSource: 'local' infoSource: 'local'
} }
this.playlistItems = result.items.map((video) => { this.playlistItems = result.items.map((video) => {
if (typeof video.author !== 'undefined') { if (typeof video.author !== 'undefined') {
const channelName = video.author.name const channelName = video.author.name
const channelId = video.author.ref.replace(/https:\/\/(www\.)?youtube\.com\/(user|channel)\//g, '') const channelId = video.author.channelID ? video.author.channelID : channelName
video.author = channelName video.author = channelName
video.authorId = channelId video.authorId = channelId
} else { } else {
@ -117,7 +117,6 @@ export default Vue.extend({
this.getPlaylistInvidious() this.getPlaylistInvidious()
} else { } else {
this.isLoading = false this.isLoading = false
// TODO: Show toast with error message
} }
}) })
}, },

View File

@ -132,20 +132,13 @@ export default Vue.extend({
const returnDataInvidious = [] const returnDataInvidious = []
returnData.forEach((video) => { returnData.forEach((video) => {
if (video.type === 'video') { if (video.type === 'video') {
let authId = video.author.ref.match(/user(.)*/) const authId = video.author.channelID
let publishDate = null const publishDate = video.uploadedAt
let videoDuration = null let videoDuration = video.duration
const videoId = video.link.match(/\?v=(.)*/)[0].split('=')[1] const videoId = video.id
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 && video.duration !== '') { if (video.duration !== null && video.duration !== '') {
videoDuration = ytTrendScraper.calculate_length_in_seconds(video.duration) videoDuration = ytTrendScraper.calculate_length_in_seconds(video.duration)
} }
authId = authId[0].replace(/(user|channel)\//, '')
returnDataInvidious.push( returnDataInvidious.push(
{ {
videoId: videoId, videoId: videoId,
@ -153,12 +146,12 @@ export default Vue.extend({
type: 'video', type: 'video',
author: video.author.name, author: video.author.name,
authorId: authId, authorId: authId,
authorUrl: video.author.ref, authorUrl: video.author.url,
videoThumbnails: video.thumbnail, videoThumbnails: video.thumbnail,
description: video.description, description: video.description,
viewCount: video.views, viewCount: video.views,
published: publishDate, published: publishDate,
publishedText: video.uploaded_at, publishedText: publishDate,
lengthSeconds: videoDuration, lengthSeconds: videoDuration,
liveNow: video.live, liveNow: video.live,
paid: false, paid: false,