As the title states, I'm trying to create a basic streamlink GUI with PySimpleGUI.
I've got
[gui.Text('Stream link:'), gui.InputText()],
and a bunch of other code (as of yet unimplemented options) which takes a stream link as an input, and runCommand('streamlink ' + values[0] + ' best -o output.ts')
to use streamlink to download the stream to output.ts in the best quality.
runCommand is:
def runCommand(cmd, timeout=None, window=None):
os.path.dirname(os.path.realpath(__file__))
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = ''
for line in p.stdout:
line = line.decode(errors='replace' if (sys.version_info) < (3, 5) else 'backslashreplace').rstrip()
output += line
print(line)
window.Refresh() if window else None
retval = p.wait(timeout)
return (retval, output)
if __name__ == '__main__':
main()
(Which I found here)
And this works as such:
[cli][info] Found matching plugin youtube for URL
[cli][info] Available streams: audio_mp4a, audio_opus, 144p (worst), 240p, 360p, 480p, 720p, 720p60, 1080p60 (best)
[cli][info] Opening stream: 1080p60 (muxed-stream)
error: Failed to open output: output.ts ([Errno 13] Permission denied: 'output.ts')
[cli][info] Closing currently open stream...
As you can see, when I run streamlink through runCommand, it gets a permission denied error. I'm trying to get the output file in the same directory as the .py script is ran in, but I think runCommand might be specifying a directory I don't have permission to write to.
I don't know how I would go about specifying a directory for this command, can anyone help?