Skip to content

Commit

Permalink
Prefer system binaries attempt 2
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Nov 30, 2024
1 parent 69b95ac commit 25489c6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/onthespot/otsconfig.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import os
import json
import platform
import shutil
from shutil import which
import uuid

def config_dir():
if platform.system() == "Windows":
if os.name == "nt":
if 'APPDATA' in os.environ:
return os.environ["APPDATA"]
elif 'LOCALAPPDATA' in os.environ:
Expand All @@ -20,7 +19,7 @@ def config_dir():
return os.path.join(os.path.expanduser("~"), ".config")

def cache_dir():
if platform.system() == "Windows":
if os.name == "nt":
if 'TEMP' in os.environ:
return os.environ["TEMP"]
else:
Expand All @@ -36,8 +35,7 @@ def __init__(self, cfg_path=None):
if cfg_path is None or not os.path.isfile(cfg_path):
cfg_path = os.path.join(config_dir(), "onthespot", "otsconfig.json")
self.__cfg_path = cfg_path
self.platform = platform.system()
self.ext_ = ".exe" if self.platform == "Windows" else ""
self.ext_ = ".exe" if os.name == "nt" else ""
self.session_uuid = str(uuid.uuid4())
self.__template_data = {
"version": "", # Application version
Expand Down Expand Up @@ -182,9 +180,12 @@ def __init__(self, cfg_path=None):
os.makedirs(self.get("download_root"), exist_ok=True)
# Set ffmpeg path
self.app_root = os.path.dirname(os.path.realpath(__file__))
if which('ffmpeg'):
if os.name != 'nt' and os.path.exists('/usr/bin/ffmpeg'):
# Try system binaries first
print('Attempting to use system ffmpeg binary !')
self.set_('_ffmpeg_bin_path', '/usr/bin/ffmpeg')
elif which('ffmpeg'):
print('Attempting to use ffmpeg binary in path !')
self.set_('_ffmpeg_bin_path', os.path.abspath(which('ffmpeg')))
elif os.path.isfile(os.path.join(self.app_root, 'bin', 'ffmpeg', 'ffmpeg' + self.ext_)):
# Try embedded binary next
Expand Down

0 comments on commit 25489c6

Please sign in to comment.