Add command line arg to search FreeTube

https://github.com/FreeTubeApp/FreeTube/issues/1619
This commit is contained in:
ChunkyProgrammer 2023-11-07 22:53:14 -05:00
parent 6bbf11f464
commit 5e5e6d2af2
5 changed files with 23 additions and 5 deletions

View File

@ -1116,6 +1116,11 @@ function runApp() {
}
function baseUrl(arg) {
// freetube.exe s="query"
if (arg.startsWith('s=')) {
return `https://www.youtube.com/results?search_query=${arg.substring(2)}`
}
let newArg = arg.replace('freetube://', '')
// add support for authority free url
.replace('freetube:', '')

View File

@ -473,7 +473,7 @@ export default defineComponent({
enableSetSearchQueryText: function () {
ipcRenderer.on('updateSearchInputText', (event, searchQueryText) => {
if (searchQueryText) {
this.$refs.topNav.updateSearchInputText(searchQueryText)
this.$refs.topNav.updateSearchInputText({ detail: { query: searchQueryText } })
}
})

View File

@ -0,0 +1,2 @@
const events = new EventTarget()
export default events

View File

@ -3,6 +3,7 @@ import { mapActions } from 'vuex'
import FtInput from '../ft-input/ft-input.vue'
import FtSearchFilters from '../ft-search-filters/ft-search-filters.vue'
import FtProfileSelector from '../ft-profile-selector/ft-profile-selector.vue'
import TopNavEvents from './top-nav-events'
import debounce from 'lodash.debounce'
import { IpcChannels } from '../../../constants'
@ -103,6 +104,11 @@ export default defineComponent({
})
this.debounceSearchResults = debounce(this.getSearchSuggestions, 200)
TopNavEvents.addEventListener('updateSearchInput', this.updateSearchInputText)
},
beforeDestroy: function () {
TopNavEvents.removeEventListener('updateSearchInput', this.updateSearchInputText)
},
methods: {
goToSearch: async function (query, { event }) {
@ -334,8 +340,8 @@ export default defineComponent({
hideFilters: function () {
this.showFilters = false
},
updateSearchInputText: function (text) {
this.$refs.searchInput.updateInputData(text)
updateSearchInputText: function ({ detail: { query } }) {
this.$refs.searchInput.updateInputData(query)
},
...mapActions([
'getYoutubeUrlInfo',

View File

@ -5,6 +5,7 @@ import FtElementList from '../../components/ft-element-list/ft-element-list.vue'
import { copyToClipboard, searchFiltersMatch, showToast } from '../../helpers/utils'
import { getLocalSearchContinuation, getLocalSearchResults } from '../../helpers/api/local'
import { invidiousAPICall } from '../../helpers/api/invidious'
import TopNavEvents from '../../components/top-nav/top-nav-events'
export default defineComponent({
name: 'Search',
@ -47,6 +48,7 @@ export default defineComponent({
// react to route changes...
const query = this.$route.params.query
TopNavEvents.dispatchEvent(new CustomEvent('updateSearchInput', { detail: { query } }))
const searchSettings = {
sortBy: this.$route.query.sortBy,
time: this.$route.query.time,
@ -66,7 +68,10 @@ export default defineComponent({
}
},
mounted: function () {
this.query = this.$route.params.query
const query = this.$route.params.query
this.query = query
TopNavEvents.dispatchEvent(new CustomEvent('updateSearchInput', { detail: { query } }))
this.searchSettings = {
sortBy: this.$route.query.sortBy,
@ -76,7 +81,7 @@ export default defineComponent({
}
const payload = {
query: this.query,
query,
options: {},
searchSettings: this.searchSettings
}