.mkv - open imdb site

What I want to do is right click an mkv file and via context menu open the corresponding imdb url.

I can do 2 things to have the imdb url.
1- I can add the imdb.url with mkvtoolnix as attachment to mkv.
2- I can have a separate imdb.url file in the same folder as the mkv.

Which method is easier to script DOpus to launch the .url file? And how to do it. Need general direction.

In the first method DOpus has to read the mkv attachments which I suppose is not possible.

In the second method, DOpus has to read the list of the files in the current folder and launch (double click) the .url file. This also has to work in the search result pane.

That's the easiest one to set up.

Just add this as a .MKV context menu item via Settings > File Types:

{filepath|..}\imdb.url

1 Like

Thank you. That looks so much easier than what I was thinking. I have one problem.
This works
{sourcepath}imdb.url
But I have imdb files with the code in the name like .imdb.tt7280898.url
so I need a wildcard and this doesn't work
{sourcepath}imdb.*.url

Set the Function drop-down to MS-DOS Batch Function and change the command to the following (untested):

for /f "delims=" %a IN ('dir /a-d /b /s imdb*.url') do call "%a"

Possibly you might need a line before it to change the current directory, something like cd {filepath|..} may work if so.

The batch command works when I use it in a command prompt window outside of DOpus.

When I use it inside DOpus, a dos window shows and closes instantly like it is crashing and nothing happens. Even if I add a PAUSE as second line, I can't see what's happening.

Try doubling the % signs, DOS batch scripts have funny parsing rules.

for /f "delims=" %%a IN ('dir /a-d /b /s imdb*.url') do call "%%a"

(FYI if you add @leavedoswindowopen to the top of the function the window will stay open so you can read the error message)

1 Like

Thank you. Now it works. However there is a problem.

It works when I'm in a normal view inside a folder. If I'm in a search results view with several mkvs, it opens multiple imdb pages. How to do, to open only the "right clicked" file imdb page in a search results view?

Also, the point of this, is to use it in a search results pane when you have multiple mkvs in one view. If I was in a normal view inside a folder, I could easily click on the .url file itself. I'm not that lazy. :grinning:

Did you try the cd {filepath|..} line Jon mentioned?

1 Like

Wow, thank you so much. Yes now it works and it's like magic.

@runmode:hide
cd {filepath|..}
for /f "delims=" %%a IN ('dir /a-d /b /s .imdb*.url') do call "%%a"

I also just spent several hours to write an elaborate, complex script myself before you replied! I'm going to share it once done!

I wrote this script that works also with multiple selections in a search results view. If you select several files, it goes into each folder of those files and opens all .url files inside.

However this works as a button and it does not work as a context menu script. I suppose because context menu has no OnClick function. How can I modify this to work in the context menu also? I have already spent 5-6 hours on this and my brain is not working anymore to find it myself!

function OnClick(clickData)
{
	DOpus.ClearOutput();
	// --------------------------------------------------------
	var cmd = clickData.func.command;
	cmd.deselect = false; // Prevent automatic deselection
	// --------------------------------------------------------
		
	if (clickData.func.sourcetab.selected.count == 0)
	{
		DOpus.Output("  (none)");
	}
	else
	{

		for (var eFile = new Enumerator(clickData.func.sourcetab.selected_files); !eFile.atEnd(); eFile.moveNext())
		{
		
			var sDir = eFile.item().Path;
			var eSel = DOpus.FSUtil.ReadDir(sDir);
			var eItem;
			var file;
			var fileext;

			while (eSel.complete == false)
			{
				eItem = eSel.Next();
			
				file = eItem.RealPath;
				fileext = eItem.ext;
			
				DOpus.Output(file);

				if (fileext == ".url")
				{
					DOpus.Output("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
					cmd.RunCommand(file);
				}
			}
			DOpus.Output("-----------------------------------------------------------------------------------");
		}
	
	}

}

Context menu scripts do have OnClick. It should work there as well.

It says
3/1/2019 6:42 PM Error at line 2, position 1
3/1/2019 6:42 PM {
3/1/2019 6:42 PM ^
3/1/2019 6:42 PM Invalid character (0x800a0408)
3/1/2019 6:42 PM Parse error - script aborted

The { is correct. It's the exact same code I copy pasted.

I have noticed that in the context menu when I hit Edit I don't get the Script Code tab that allows you to choose JScript or VBScript.

I think you have to move your script into a user command and insert this command as the action of your File Types context menu. You can reuse the user command in your regular button.

You don't have to use a user command.

Zolder, please show a screenshot of the context menu definition. We should be able to see what is wrong from there. My guess is it is not set to the right script language.

There is no option to select a script language in the File Types Context Menu.

Looks identical to the Standard function.

1 Like

You use @script jscript at the top of the script there, after choosing Script Function from the dropdown.

1 Like

Thank you. Now it works.

Interesting that there is no script language in the File Types Context Menu. Is there a reason?

can you show how you are adding the imdb url to a file or folder as I would like to try this out

That's how it used to work everywhere (and still does behind the scenes, if you look at the button data in a text editor). We just added the language drop-down in the button editor to make things easier in the place that 99% of scripts get written.