Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable youtube-dl on macOS plus mpv and IINA #381

Merged
merged 2 commits into from Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions syncplay/players/mpv.py
Expand Up @@ -590,15 +590,25 @@ def __init__(self, playerController, playerIPCHandler, playerPath, filePath, arg
# 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')
Expand Down
2 changes: 1 addition & 1 deletion syncplay/vendor/python_mpv_jsonipc/python_mpv_jsonipc.py
Expand Up @@ -211,7 +211,7 @@ def __init__(self, ipc_socket, mpv_location=None, env=None, **kwargs):
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)
Expand Down