Update search filters to work with updated search module
This commit is contained in:
parent
cb8cf1ef43
commit
1a9cdacd75
|
@ -51,13 +51,18 @@ export default Vue.extend({
|
||||||
|
|
||||||
this.channelName = this.data.name
|
this.channelName = this.data.name
|
||||||
this.id = this.data.channelID
|
this.id = this.data.channelID
|
||||||
if (this.hideChannelSubscriptions) {
|
if (this.hideChannelSubscriptions || this.data.subscribers === null) {
|
||||||
this.subscriberCount = null
|
this.subscriberCount = null
|
||||||
} else {
|
} else {
|
||||||
this.subscriberCount = this.data.subscribers.replace(/ subscriber(s)?/, '')
|
this.subscriberCount = this.data.subscribers.replace(/ subscriber(s)?/, '')
|
||||||
}
|
}
|
||||||
this.videoCount = this.data.videos.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
if (this.data.videos === null) {
|
||||||
this.description = this.data.description_short
|
this.videoCount = 0
|
||||||
|
} else {
|
||||||
|
this.videoCount = this.data.videos.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||||||
|
}
|
||||||
|
|
||||||
|
this.description = this.data.descriptionShort
|
||||||
},
|
},
|
||||||
|
|
||||||
parseInvidiousData: function () {
|
parseInvidiousData: function () {
|
||||||
|
|
|
@ -39,7 +39,9 @@ const actions = {
|
||||||
payload.options.nextpageRef = filter
|
payload.options.nextpageRef = filter
|
||||||
}
|
}
|
||||||
|
|
||||||
ytsr(payload.query, payload.options).then((result) => {
|
const query = filter || payload.query
|
||||||
|
|
||||||
|
ytsr(query, payload.options).then((result) => {
|
||||||
console.log(result)
|
console.log(result)
|
||||||
console.log('done')
|
console.log('done')
|
||||||
resolve(result)
|
resolve(result)
|
||||||
|
@ -51,6 +53,7 @@ const actions = {
|
||||||
})
|
})
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
commit('toggleIsYtSearchRunning')
|
||||||
reject(err)
|
reject(err)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
@ -68,52 +71,88 @@ const actions = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
ytSearchGetFilters ({ rootState }, payload) {
|
async ytSearchGetFilters ({ rootState }, payload) {
|
||||||
return new Promise((resolve, reject) => {
|
let filter = await ytsr.getFilters(payload.query)
|
||||||
let filter = payload.query
|
let filterUrl = null
|
||||||
let searchSettings = payload.searchSettings
|
let searchSettings = payload.searchSettings
|
||||||
|
|
||||||
if (typeof (searchSettings) === 'undefined') {
|
if (typeof (searchSettings) === 'undefined') {
|
||||||
searchSettings = rootState.utils.searchSettings
|
searchSettings = rootState.utils.searchSettings
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(searchSettings)
|
||||||
|
console.log(filter)
|
||||||
|
|
||||||
|
if (searchSettings.sortBy !== 'relevance') {
|
||||||
|
let filterValue
|
||||||
|
switch (searchSettings.sortBy) {
|
||||||
|
case 'rating':
|
||||||
|
filterValue = 'Rating'
|
||||||
|
break
|
||||||
|
case 'upload_date':
|
||||||
|
filterValue = 'Upload date'
|
||||||
|
break
|
||||||
|
case 'view_count':
|
||||||
|
filterValue = 'View count'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
filterUrl = filter.get('Sort by').get(filterValue).url
|
||||||
|
filter = await ytsr.getFilters(filterUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Current ref: ${filterUrl}`)
|
||||||
|
|
||||||
|
if (searchSettings.duration !== '') {
|
||||||
|
let filterValue = null
|
||||||
|
if (searchSettings.duration === 'short') {
|
||||||
|
filterValue = 'Short (< 4 minutes)'
|
||||||
|
} else if (searchSettings.duration === 'long') {
|
||||||
|
filterValue = 'Long (> 20 minutes)'
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(searchSettings)
|
filterUrl = filter.get('Duration').get(filterValue).url
|
||||||
|
filter = await ytsr.getFilters(filterUrl)
|
||||||
|
}
|
||||||
|
|
||||||
// This is extremely ugly, though this is the recommended way to accomplish this
|
console.log(`Current ref: ${filterUrl}`)
|
||||||
// in the GitHub documentation
|
|
||||||
console.log(`Current ref: ${filter}`)
|
|
||||||
ytsr.getFilters(filter).then((filters) => {
|
|
||||||
if (searchSettings.type !== 'all') {
|
|
||||||
filter = filters.get('Type').find(o => o.name.toLowerCase().includes(rootState.utils.searchSettings.type)).ref
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Current ref: ${filter}`)
|
if (searchSettings.time !== '') {
|
||||||
ytsr.getFilters(filter).then((filters) => {
|
let filterValue = null
|
||||||
if (searchSettings.time !== '') {
|
|
||||||
filter = filters.get('Upload date').find(o => o.name.toLowerCase().includes(rootState.utils.searchSettings.time)).ref
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Current ref: ${filter}`)
|
switch (searchSettings.time) {
|
||||||
ytsr.getFilters(filter).then((filters) => {
|
case 'hour':
|
||||||
if (searchSettings.duration !== '') {
|
filterValue = 'Last Hour'
|
||||||
filter = filters.get('Duration').find(o => o.name.toLowerCase().includes(rootState.utils.searchSettings.duration)).ref
|
break
|
||||||
}
|
case 'today':
|
||||||
|
filterValue = 'Today'
|
||||||
|
break
|
||||||
|
case 'week':
|
||||||
|
filterValue = 'This week'
|
||||||
|
break
|
||||||
|
case 'month':
|
||||||
|
filterValue = 'This month'
|
||||||
|
break
|
||||||
|
case 'year':
|
||||||
|
filterValue = 'This year'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`Current ref: ${filter}`)
|
filterUrl = filter.get('Upload date').get(filterValue).url
|
||||||
ytsr.getFilters(filter).then((filters) => {
|
filter = await ytsr.getFilters(filterUrl)
|
||||||
if (searchSettings.sortBy !== 'relevance') {
|
}
|
||||||
const sortBy = rootState.utils.searchSettings.sortBy.replace('_', ' ')
|
|
||||||
filter = filters.get('Sort by').find(o => o.name.toLowerCase().includes(sortBy)).ref
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Final ref: ${filter}`)
|
console.log(`Current ref: ${filterUrl}`)
|
||||||
resolve(filter)
|
|
||||||
})
|
if (searchSettings.type !== 'all') {
|
||||||
})
|
const filterValue = searchSettings.type.charAt(0).toUpperCase() + searchSettings.type.slice(1)
|
||||||
})
|
filterUrl = filter.get('Type').get(filterValue).url
|
||||||
}).catch((err) => {
|
filter = await ytsr.getFilters(filterUrl)
|
||||||
reject(err)
|
}
|
||||||
})
|
|
||||||
|
console.log(`Current ref: ${filterUrl}`)
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
resolve(filterUrl)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue