Quick web searches

You need to use the &'s if you're defining a user command, right? However, I cannot seem to get it to work either.

I had trouble getting the following to work:

"http://www.google.com/search?q=%%22&QUERY&%%22"

where QUERY is the template variable. However, this does not allow you to pass multiple strings in the QUERY (e.g. "g directory opus") without using quotes around the parameters. I finally :unamused: figured that all you you have to do is to define the template as QUERY/M.

So, define a User Command as follows:

Name: g
Template QUERY/M
Tip: Google Search
Function: "http://www.google.com/search?q=%%22&QUERY&%%22"

Now it works! :smiley:

And, as added bonus:

Name: drc
Template QUERY/M
Tip: Google Search
Function: "http://resource.dopus.com/search.php?search_keywords=%%22&QUERY&%%22"

Have fun with more...

Cheers,
Marcel

1 Like

Cheers m8! I will try this as soon as I get a chance. :o)

Sorry mvdlaan, I didn't realise you were trying to make a user command with argument template. The &-symbols you were using make perfect sense now.

Glad it's all working for you now!

Is it possible to use the custom searches we've already got saved in Chrome or Firefox with this?

For example, I've got "wiki" setup to search Wikipedia. "dopus" setup to search the Directory Opus forum. It always gets messy to duplicate all of these custom searches in another location. If there isn't a normal way to achieve this from the command line, any idea how to get that search engine configuration out of Chrome and Firefox and into a format easily usable by Opus?

From the forum, for Google, but should work for others (replace search-command and set button as script):

function OnClick(data) {
  data.func.command.ClearFiles();
  var objEnum = new Enumerator(data.func.sourcetab.selected);
  while (!objEnum.atEnd()) {
   var item = objEnum.item().name_stem; objEnum.moveNext();
   var encoded = encodeURIComponent(item);
   var search = encoded.replace(/%/g,"%%");
   data.func.command.RunCommand("http://www.google.de/search?q=" + search);
  }
}

I have written an elementary button JScript that performs web searches from within DOpus. It can use any number of search engines, which are easily configured into the script, and allows searching with one of those engines or with all of them at once. It also allows a choice from multiple browsers, which can also be configured into the script. This script may address some of the questions in the thread above.

It's not very elaborate, but because it is a script rather than DOpus code, I have posted it in the scripts forum instead of here. I hope it's useful to others.

@set searchterm = {dlgstring|Enter search term|{clip}}
"http://www.google.com/search?q={$searchterm}"

using above script the button actually pops up the clipboard text ..so i have to press enter and it opens in browser.
how to just open browser directly when pressing the button?

{dlgstring|...} is used to prompt you for input.

If you just want the clipboard text, use {clip} on its own.

:ok_hand:

what script if i want selected text to be searched with google.Not even copied to clipboard.
plz write full script..i know nothing about scripting.
THX leo

Selected text from where?

sorry for being unclear earlier..
like selected text of any file or folder.
i mean instead of searching whole folder or file name on google e.g
The.Killing.Fields.1984.1080p.BluRay.x264.DTS-FGT
if i could only select The.Killing.Fields.1984 and then click on button which searches google.

You could use this to prompt you with the current filename, which you could then edit if you wanted something else, before pushing return to search for whatever was left in the prompt:

"https://www.google.com/search?q={dlgstring|Enter search term|{file|noext}}"
1 Like

thx leo

one more thing
could u plz tell me if i wanted to use another browser instead of my default browser which is chrome then what would be the command?
i want to create another button for my son who uses firefox.
thx in advance

Putting the path to Firefox.exe before the command might work, but it will depend on the browser and you might have to look up the browser's documentation on how to run it from the command line.

Try something like this:

"C:\Program Files\Mozilla\Firefox.exe" "https://www.google.com/search?q={dlgstring|Enter search term|{file|noext}}"

I don't know if that is the correct path to Firefox.exe as I do not have it installed. If it doesn't work, check the Firefox documentation for how to run it.

1 Like

Yeah ..thats works like charm..
No need to check documentation..
i just changed path of firefox.
:ok_hand:

Did you get this working with multiple engine searches? If so could I see the code? Thanks

I'm reading old but usefull posts, so forgive me if I wake up them with my questions :slight_smile:
How should I modify the button to search with google, using the tags of the selected file, please ?
I tried to replace with the argument with {mp3artist} (for example) but DO just send this as a string.

Thanks in advance for your help !

I reply myself :slightly_smiling_face:

In fact if I understand correctly, the tags are only accessible with the SET and RENAME functions, correct me if I'm wrong, please.
To get around this, I used 2 external programs :

  • exiftool.exe to extract the tags I want and store them in the clipboard for reuse in DO.
  • nircmd.exe to open a new browser window, with the default browser.

Now when I click on a correctly tagged music, I can display the Wikipedia page of the artist, search for a cover, lyrics, the corresponding Youtube video, the Facebook / Twitter page of the artist, etc ...

To make it works I installed exiftool.exe and nircmd.exe in a "Tools" folder, in the home of DO.
And I used this code :

Wikipedia :

@runmode:hide
@codepage 65001
"/home\Tools\exiftool.exe" -quiet -quiet -p "${artist}" {filepath$} | clip
"/home\tools\nircmd.exe" shexec "open" "https://www.wikiwand.com/fr/~$clipboard$"

Youtube :

@runmode:hide
@codepage 65001
"/home\Tools\exiftool.exe" -quiet -quiet -p "${artist} ${title}" {filepath$} | clip
"/home\Tools\nircmd.exe" shexec "open" "https://www.youtube.com/results?search_query=~$clipboard$"

Covers :

@runmode:hide
@codepage 65001
"/home\Tools\exiftool.exe" -quiet -quiet -p "${artist} ${title}" {filepath$} | clip
"/home\Tools\nircmd.exe" shexec "open" "http://www.google.fr/search?q=~$clipboard$+Covers&tbs=isz:m&tbm=isch"

Lyrics :

@runmode:hide
@codepage 65001
"/home\Tools\exiftool.exe" -quiet -quiet -p "${artist} ${title}" {filepath$} | clip
"/home\Tools\nircmd.exe" shexec "open" "http://www.google.fr/search?q=~$clipboard$+Lyrics"

Facebook :

@runmode:hide
@codepage 65001
"/home\Tools\exiftool.exe" -quiet -quiet -p "${artist}" {filepath$} | clip
"/home\tools\nircmd.exe" shexec "open" "https://www.facebook.com/search/top/?q=~$clipboard$"

Twitter :

@runmode:hide
@codepage 65001
"/home\Tools\exiftool.exe" -quiet -quiet -p "${artist}" {filepath$} | clip
"/home\tools\nircmd.exe" shexec "open" "https://twitter.com/search?q=~$clipboard$&src=typd&lang=fr"

I'm really happy with the result :slight_smile:
Hope you like it too...

There's an AudioMeta object you can use in scripting to get the data.

The Rename command is the only thing that can access the tags without scripting.