mirror of
https://github.com/Syncplay/syncplay
synced 2025-02-09 07:27:01 +00:00
Re-enable youtube-dl on macOS plus mpv and IINA (#381)
* Determine correct PYTHONPATH for youtube-dl and pass it to mpv subprocess (follows c07206c
)
* Homebrew on arm64 has a different prefix
This commit is contained in:
parent
f791faca91
commit
03cde67c72
@ -590,15 +590,25 @@ class MpvPlayer(BasePlayer):
|
||||
# to allow that version of python to be executed in the mpv subprocess.
|
||||
if isMacOS():
|
||||
try:
|
||||
pythonLibs = subprocess.check_output(['/usr/bin/python', '-E', '-c',
|
||||
env['PATH'] = '/opt/homebrew/bin:/usr/local/bin:/usr/bin'
|
||||
ytdl_path = subprocess.check_output(['which', 'youtube-dl'], text=True, env=env).rstrip('\n')
|
||||
with open(ytdl_path, 'rb') as f:
|
||||
ytdl_shebang = f.readline()
|
||||
ytdl_python = ytdl_shebang.decode('utf-8').lstrip('!#').rstrip('\n')
|
||||
if '/usr/bin/env' in ytdl_python:
|
||||
python_name = ytdl_python.split(' ')[1]
|
||||
python_executable = subprocess.check_output(['which', python_name], text=True, env=env).rstrip('\n')
|
||||
else:
|
||||
python_executable = ytdl_python
|
||||
pythonLibs = subprocess.check_output([python_executable, '-E', '-c',
|
||||
'import sys; print(sys.path)'],
|
||||
text=True, env=dict())
|
||||
pythonLibs = ast.literal_eval(pythonLibs)
|
||||
pythonPath = ':'.join(pythonLibs[1:])
|
||||
except:
|
||||
except Exception as e:
|
||||
pythonPath = None
|
||||
if pythonPath is not None:
|
||||
env['PATH'] = '/usr/bin:/usr/local/bin'
|
||||
env['PATH'] = python_executable + ':' + env['PATH']
|
||||
env['PYTHONPATH'] = pythonPath
|
||||
try:
|
||||
socket = self.mpv_arguments.get('input-ipc-server')
|
||||
|
@ -211,7 +211,7 @@ class MPVProcess:
|
||||
self._start_process(ipc_socket, args, env=env)
|
||||
|
||||
def _start_process(self, ipc_socket, args, env):
|
||||
self.process = subprocess.Popen(args)
|
||||
self.process = subprocess.Popen(args, env=env)
|
||||
ipc_exists = False
|
||||
for _ in range(100): # Give MPV 10 seconds to start.
|
||||
time.sleep(0.1)
|
||||
|
Loading…
Reference in New Issue
Block a user