mkvmerge "could not be opened for reading" in a post-process script

Come up with a useful post-processing script? Share it here!
Post Reply
pangoo
Newbie
Newbie
Posts: 2
Joined: August 15th, 2022, 12:34 pm

mkvmerge "could not be opened for reading" in a post-process script

Post by pangoo »

I get a an error when trying to run mkvmerge with a Python 3 script as a post-process script in SAB.

Not sure why. I can make the script work outside SAB, but once SAB triggers this script I get the error.

Any pointers in the right direction would be much appreciated.

Code: Select all

#!/usr/bin/env python3

import os
import sys
import subprocess

for i,file in enumerate(os.listdir(os.environ['SAB_COMPLETE_DIR'])):
	if file.endswith(".mkv"):
		file = os.path.basename(file)
		result = subprocess.run(
			["mkvmerge", "--identify", "--identification-format", "json", str(file)],
			capture_output=True,
			shell=False,
			encoding="utf-8",
		)
		if result.returncode != 0:
			print(f"Error in mkvmerge while parsing: {file}")
			print(result.stdout.strip())  # Show the actual error (it's in stdout).
			exit(1)
sys.exit(0)

Code: Select all

Error in mkvmerge while parsing: Some.Show.S06E12.HDTV.x264-CRiMSON.mkv
{
"errors": [
"The file 'Some.Show.S06E12.HDTV.x264-CRiMSON.mkv' could not be opened for reading: open file error.\n"
],
"warnings": []
}
User avatar
sander
Release Testers
Release Testers
Posts: 8811
Joined: January 22nd, 2008, 2:22 pm

Re: mkvmerge "could not be opened for reading" in a post-process script

Post by sander »

you have to feed the whole path + filename to mkvmerge (not just the filename)
pangoo
Newbie
Newbie
Posts: 2
Joined: August 15th, 2022, 12:34 pm

Re: mkvmerge "could not be opened for reading" in a post-process script

Post by pangoo »

Thanks. I realized that just now.

Is it possible to re-run scripts if they failed initially? Or do you have to re-download?
User avatar
sander
Release Testers
Release Testers
Posts: 8811
Joined: January 22nd, 2008, 2:22 pm

Re: mkvmerge "could not be opened for reading" in a post-process script

Post by sander »

Not from SAB. So ... re-run script by hand?
Post Reply