mirror of
https://github.com/Syncplay/syncplay
synced 2025-02-09 23:46:58 +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.
|
# to allow that version of python to be executed in the mpv subprocess.
|
||||||
if isMacOS():
|
if isMacOS():
|
||||||
try:
|
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)'],
|
'import sys; print(sys.path)'],
|
||||||
text=True, env=dict())
|
text=True, env=dict())
|
||||||
pythonLibs = ast.literal_eval(pythonLibs)
|
pythonLibs = ast.literal_eval(pythonLibs)
|
||||||
pythonPath = ':'.join(pythonLibs[1:])
|
pythonPath = ':'.join(pythonLibs[1:])
|
||||||
except:
|
except Exception as e:
|
||||||
pythonPath = None
|
pythonPath = None
|
||||||
if pythonPath is not None:
|
if pythonPath is not None:
|
||||||
env['PATH'] = '/usr/bin:/usr/local/bin'
|
env['PATH'] = python_executable + ':' + env['PATH']
|
||||||
env['PYTHONPATH'] = pythonPath
|
env['PYTHONPATH'] = pythonPath
|
||||||
try:
|
try:
|
||||||
socket = self.mpv_arguments.get('input-ipc-server')
|
socket = self.mpv_arguments.get('input-ipc-server')
|
||||||
|
@ -211,7 +211,7 @@ class MPVProcess:
|
|||||||
self._start_process(ipc_socket, args, env=env)
|
self._start_process(ipc_socket, args, env=env)
|
||||||
|
|
||||||
def _start_process(self, ipc_socket, args, env):
|
def _start_process(self, ipc_socket, args, env):
|
||||||
self.process = subprocess.Popen(args)
|
self.process = subprocess.Popen(args, env=env)
|
||||||
ipc_exists = False
|
ipc_exists = False
|
||||||
for _ in range(100): # Give MPV 10 seconds to start.
|
for _ in range(100): # Give MPV 10 seconds to start.
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
Loading…
Reference in New Issue
Block a user