Start progress on fixing Search and Playlist for local API
This commit is contained in:
parent
0c8d510028
commit
cb8cf1ef43
|
@ -8962,9 +8962,9 @@
|
|||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.7",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz",
|
||||
"integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==",
|
||||
"version": "1.3.8",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
|
||||
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
|
||||
"dev": true
|
||||
},
|
||||
"internal-ip": {
|
||||
|
@ -18576,9 +18576,9 @@
|
|||
}
|
||||
},
|
||||
"ytpl": {
|
||||
"version": "2.0.0-alpha.3",
|
||||
"resolved": "https://registry.npmjs.org/ytpl/-/ytpl-2.0.0-alpha.3.tgz",
|
||||
"integrity": "sha512-c6I6Qc8NxJi2ZgCyNFnBBrGGw3tuBa1+ksMZTG7G8ltZN26wluvgSn9ZW2Xki4DzECdx4k0Bcm5fEvwwOEQsww==",
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ytpl/-/ytpl-2.0.1.tgz",
|
||||
"integrity": "sha512-FK6Qz43PKDqKcxI8K9tEOMJ7S/MVN6Ofc9flolPloMN4hJm+N6wZd3Y9oD+amQYHMCVkaXT0BvPMY4BUYg3FpQ==",
|
||||
"requires": {
|
||||
"html-entities": "^1.3.1",
|
||||
"miniget": "^4.1.0"
|
||||
|
@ -18592,9 +18592,9 @@
|
|||
}
|
||||
},
|
||||
"ytsr": {
|
||||
"version": "2.0.0-alpha.4",
|
||||
"resolved": "https://registry.npmjs.org/ytsr/-/ytsr-2.0.0-alpha.4.tgz",
|
||||
"integrity": "sha512-iEXOu0kFwxr9O+mpG3tnZa6TovEOZ92N0rNmyZFEv5EdcFg9FWH8MEUJVMExCFhSYu1rSFv5napQCzDCozizdg==",
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ytsr/-/ytsr-2.0.1.tgz",
|
||||
"integrity": "sha512-1m/jmX8X1PJSnX1eJ3sm3s8Z2S/ixYKTZduuLsGn/RsxEI9nqV2iWCRi0qTQ8rOSaoEwkeWcJHLlZPbd499p/w==",
|
||||
"requires": {
|
||||
"html-entities": "^1.3.1",
|
||||
"miniget": "^4.1.0"
|
||||
|
|
|
@ -48,8 +48,8 @@
|
|||
"yt-trending-scraper": "^1.0.4",
|
||||
"yt-xml2vtt": "^1.1.3",
|
||||
"ytdl-core": "^4.1.4",
|
||||
"ytpl": "^2.0.0-alpha.3",
|
||||
"ytsr": "^2.0.0-alpha.4"
|
||||
"ytpl": "^2.0.0",
|
||||
"ytsr": "^2.0.0"
|
||||
},
|
||||
"description": "A private YouTube client",
|
||||
"devDependencies": {
|
||||
|
|
|
@ -35,7 +35,7 @@ export default Vue.extend({
|
|||
}
|
||||
},
|
||||
mounted: function () {
|
||||
if (typeof (this.data.avatar) !== 'undefined') {
|
||||
if (typeof (this.data.avatars) !== 'undefined') {
|
||||
this.parseLocalData()
|
||||
} else {
|
||||
this.parseInvidiousData()
|
||||
|
@ -43,18 +43,18 @@ export default Vue.extend({
|
|||
},
|
||||
methods: {
|
||||
parseLocalData: function () {
|
||||
this.thumbnail = this.data.avatar
|
||||
this.thumbnail = this.data.bestAvatar.url
|
||||
|
||||
if (!this.thumbnail.includes('https:')) {
|
||||
this.thumbnail = `https:${this.thumbnail}`
|
||||
}
|
||||
|
||||
this.channelName = this.data.name
|
||||
this.id = this.data.channel_id
|
||||
this.id = this.data.channelID
|
||||
if (this.hideChannelSubscriptions) {
|
||||
this.subscriberCount = null
|
||||
} 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.description = this.data.description_short
|
||||
|
|
|
@ -43,7 +43,7 @@ export default Vue.extend({
|
|||
}
|
||||
},
|
||||
mounted: function () {
|
||||
if (typeof (this.data.author) === 'object') {
|
||||
if (typeof (this.data.owner) === 'object') {
|
||||
this.parseLocalData()
|
||||
} else {
|
||||
this.parseInvidiousData()
|
||||
|
@ -61,11 +61,11 @@ export default Vue.extend({
|
|||
|
||||
parseLocalData: function () {
|
||||
this.title = this.data.title
|
||||
this.thumbnail = this.data.thumbnail
|
||||
this.channelName = this.data.author.name
|
||||
this.channelLink = this.data.author.ref
|
||||
this.playlistLink = this.data.link
|
||||
this.videoCount = parseInt(this.data.length.split(' ')[0])
|
||||
this.thumbnail = this.data.firstVideo.bestThumbnail.url
|
||||
this.channelName = this.data.owner.name
|
||||
this.channelLink = this.data.owner.url
|
||||
this.playlistLink = this.data.url
|
||||
this.videoCount = this.data.length
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -283,17 +283,17 @@ export default Vue.extend({
|
|||
|
||||
this.playlistTitle = result.title
|
||||
this.playlistItems = result.items
|
||||
this.videoCount = result.total_items
|
||||
this.channelName = '' // result.author.name
|
||||
this.channelThumbnail = '' // result.author.avatar
|
||||
this.channelId = '' // result.author.id
|
||||
this.videoCount = result.estimatedItemCount
|
||||
this.channelName = result.author.name
|
||||
this.channelThumbnail = result.author.bestAvatar.url
|
||||
this.channelId = result.author.channelID
|
||||
|
||||
this.playlistItems = result.items.filter((video) => {
|
||||
return !(video.title === '[Private video]' || video.title === '[Deleted video]')
|
||||
}).map((video) => {
|
||||
if (typeof video.author !== 'undefined') {
|
||||
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.authorId = channelId
|
||||
} else {
|
||||
|
|
|
@ -78,7 +78,7 @@ export default Vue.extend({
|
|||
console.log('done')
|
||||
console.log(result)
|
||||
|
||||
const randomVideoIndex = Math.floor((Math.random() * result.items.length) + 1)
|
||||
const randomVideoIndex = Math.floor((Math.random() * result.items.length))
|
||||
|
||||
this.infoData = {
|
||||
id: result.id,
|
||||
|
@ -86,18 +86,18 @@ export default Vue.extend({
|
|||
description: result.description ? result.description : '',
|
||||
randomVideoId: result.items[randomVideoIndex].id,
|
||||
viewCount: result.views,
|
||||
videoCount: result.estimated_items,
|
||||
// lastUpdated: result.last_updated ? result.last_updated : '',
|
||||
// channelName: result.author ? result.author.name : '',
|
||||
// channelThumbnail: result.author ? result.author.avatar : '',
|
||||
// channelId: result.author ? result.author.id : '',
|
||||
videoCount: result.estimatedItemCount,
|
||||
lastUpdated: result.lastUpdated ? result.lastUpdated : '',
|
||||
channelName: result.author ? result.author.name : '',
|
||||
channelThumbnail: result.author ? result.author.bestAvatar.url : '',
|
||||
channelId: result.author ? result.author.channelID : '',
|
||||
infoSource: 'local'
|
||||
}
|
||||
|
||||
this.playlistItems = result.items.map((video) => {
|
||||
if (typeof video.author !== 'undefined') {
|
||||
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.authorId = channelId
|
||||
} else {
|
||||
|
@ -117,7 +117,6 @@ export default Vue.extend({
|
|||
this.getPlaylistInvidious()
|
||||
} else {
|
||||
this.isLoading = false
|
||||
// TODO: Show toast with error message
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
|
@ -132,20 +132,13 @@ export default Vue.extend({
|
|||
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())
|
||||
}
|
||||
const authId = video.author.channelID
|
||||
const publishDate = video.uploadedAt
|
||||
let videoDuration = video.duration
|
||||
const videoId = video.id
|
||||
if (video.duration !== null && video.duration !== '') {
|
||||
videoDuration = ytTrendScraper.calculate_length_in_seconds(video.duration)
|
||||
}
|
||||
authId = authId[0].replace(/(user|channel)\//, '')
|
||||
returnDataInvidious.push(
|
||||
{
|
||||
videoId: videoId,
|
||||
|
@ -153,12 +146,12 @@ export default Vue.extend({
|
|||
type: 'video',
|
||||
author: video.author.name,
|
||||
authorId: authId,
|
||||
authorUrl: video.author.ref,
|
||||
authorUrl: video.author.url,
|
||||
videoThumbnails: video.thumbnail,
|
||||
description: video.description,
|
||||
viewCount: video.views,
|
||||
published: publishDate,
|
||||
publishedText: video.uploaded_at,
|
||||
publishedText: publishDate,
|
||||
lengthSeconds: videoDuration,
|
||||
liveNow: video.live,
|
||||
paid: false,
|
||||
|
|
Loading…
Reference in New Issue