mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 12:59:36 -07:00
Fix ffmpeg test
This commit is contained in:
parent
5a0ac9dfa2
commit
a25b15d72f
2 changed files with 38 additions and 33 deletions
|
@ -35,14 +35,15 @@ except ImportError:
|
||||||
sys.exit('Please install pywin32')
|
sys.exit('Please install pywin32')
|
||||||
|
|
||||||
|
|
||||||
def which(name):
|
def which(name) -> pathlib.Path | None:
|
||||||
with subprocess.Popen(['which', name], stdout=PIPE) as proc:
|
with subprocess.Popen(['which', name], stdout=PIPE) as proc:
|
||||||
try:
|
try:
|
||||||
proc_out, proc_err = proc.communicate()
|
proc_out, proc_err = proc.communicate()
|
||||||
except Exception:
|
except Exception:
|
||||||
return ''
|
return None
|
||||||
else:
|
else:
|
||||||
return proc_out.strip().decode()
|
location = proc_out.strip().decode()
|
||||||
|
return pathlib.Path(location)
|
||||||
|
|
||||||
|
|
||||||
def module_path(module=__file__):
|
def module_path(module=__file__):
|
||||||
|
@ -166,7 +167,7 @@ MOUNTED = None
|
||||||
GETSUBS = False
|
GETSUBS = False
|
||||||
TRANSCODE = None
|
TRANSCODE = None
|
||||||
CONCAT = None
|
CONCAT = None
|
||||||
FFMPEG_PATH = ''
|
FFMPEG_PATH: pathlib.Path | None = None
|
||||||
SYS_PATH = None
|
SYS_PATH = None
|
||||||
DUPLICATE = None
|
DUPLICATE = None
|
||||||
IGNOREEXTENSIONS = []
|
IGNOREEXTENSIONS = []
|
||||||
|
@ -313,7 +314,7 @@ def configure_general():
|
||||||
GIT_USER = CFG['General']['git_user'] or 'clinton-hall'
|
GIT_USER = CFG['General']['git_user'] or 'clinton-hall'
|
||||||
GIT_BRANCH = CFG['General']['git_branch'] or 'master'
|
GIT_BRANCH = CFG['General']['git_branch'] or 'master'
|
||||||
FORCE_CLEAN = int(CFG['General']['force_clean'])
|
FORCE_CLEAN = int(CFG['General']['force_clean'])
|
||||||
FFMPEG_PATH = CFG['General']['ffmpeg_path']
|
FFMPEG_PATH = pathlib.Path(CFG['General']['ffmpeg_path'])
|
||||||
SYS_PATH = CFG['General']['sys_path']
|
SYS_PATH = CFG['General']['sys_path']
|
||||||
CHECK_MEDIA = int(CFG['General']['check_media'])
|
CHECK_MEDIA = int(CFG['General']['check_media'])
|
||||||
REQUIRE_LAN = None if not CFG['General']['require_lan'] else CFG['General']['require_lan'].split(',')
|
REQUIRE_LAN = None if not CFG['General']['require_lan'] else CFG['General']['require_lan'].split(',')
|
||||||
|
@ -672,11 +673,12 @@ def configure_utility_locations():
|
||||||
global PAR2CMD
|
global PAR2CMD
|
||||||
# Setup FFMPEG, FFPROBE and SEVENZIP locations
|
# Setup FFMPEG, FFPROBE and SEVENZIP locations
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
FFMPEG = os.path.join(FFMPEG_PATH, 'ffmpeg.exe')
|
if FFMPEG_PATH:
|
||||||
FFPROBE = os.path.join(FFMPEG_PATH, 'ffprobe.exe')
|
FFMPEG = FFMPEG_PATH / 'ffmpeg.exe'
|
||||||
SEVENZIP = os.path.join(APP_ROOT, 'nzb2media', 'extractor', 'bin', platform.machine(), '7z.exe')
|
FFPROBE = FFMPEG_PATH / 'ffprobe.exe'
|
||||||
|
SEVENZIP = APP_ROOT / f'nzb2media/extractor/bin{platform.machine()}/7z.exe'
|
||||||
SHOWEXTRACT = int(str(CFG['Windows']['show_extraction']), 0)
|
SHOWEXTRACT = int(str(CFG['Windows']['show_extraction']), 0)
|
||||||
if not os.path.isfile(FFMPEG): # problem
|
if FFMPEG and FFMPEG.exists(): # problem
|
||||||
FFMPEG = None
|
FFMPEG = None
|
||||||
log.warning('Failed to locate ffmpeg.exe. Transcoding disabled!')
|
log.warning('Failed to locate ffmpeg.exe. Transcoding disabled!')
|
||||||
log.warning('Install ffmpeg with x264 support to enable this feature ...')
|
log.warning('Install ffmpeg with x264 support to enable this feature ...')
|
||||||
|
@ -695,26 +697,31 @@ def configure_utility_locations():
|
||||||
if not PAR2CMD:
|
if not PAR2CMD:
|
||||||
PAR2CMD = None
|
PAR2CMD = None
|
||||||
log.warning('Failed to locate par2. Repair and rename using par files will not be possible!')
|
log.warning('Failed to locate par2. Repair and rename using par files will not be possible!')
|
||||||
ffmpeg_bin = os.path.join(FFMPEG_PATH, 'ffmpeg')
|
if FFMPEG_PATH:
|
||||||
avconv_bin = os.path.join(FFMPEG_PATH, 'avconv')
|
ffmpeg_bin = FFMPEG_PATH / 'ffmpeg'
|
||||||
if os.path.isfile(ffmpeg_bin) or os.access(ffmpeg_bin, os.X_OK):
|
avconv_bin = FFMPEG_PATH / 'avconv'
|
||||||
|
if ffmpeg_bin.is_file() or os.access(ffmpeg_bin, os.X_OK):
|
||||||
FFMPEG = ffmpeg_bin
|
FFMPEG = ffmpeg_bin
|
||||||
elif os.path.isfile(avconv_bin) or os.access(avconv_bin, os.X_OK):
|
elif avconv_bin.is_file() or os.access(avconv_bin, os.X_OK):
|
||||||
FFMPEG = avconv_bin
|
FFMPEG = avconv_bin
|
||||||
else:
|
if not FFMPEG:
|
||||||
FFMPEG = which('ffmpeg') or which('avconv')
|
FFMPEG = which('ffmpeg') or which('avconv')
|
||||||
if not FFMPEG:
|
if not FFMPEG:
|
||||||
FFMPEG = None
|
FFMPEG = None
|
||||||
log.warning('Failed to locate ffmpeg. Transcoding disabled!')
|
log.warning('Failed to locate ffmpeg. Transcoding disabled!')
|
||||||
log.warning('Install ffmpeg with x264 support to enable this feature ...')
|
log.warning('Install ffmpeg with x264 support to enable this feature ...')
|
||||||
ffprobe_bin = os.path.join(FFMPEG_PATH, 'ffprobe')
|
|
||||||
avprobe_bin = os.path.join(FFMPEG_PATH, 'avprobe')
|
if not FFMPEG_PATH:
|
||||||
if os.path.isfile(ffprobe_bin) or os.access(ffprobe_bin, os.X_OK):
|
ffprobe_bin = FFMPEG_PATH / 'ffprobe'
|
||||||
|
avprobe_bin = FFMPEG_PATH / 'avprobe'
|
||||||
|
if ffprobe_bin.is_file() or os.access(ffprobe_bin, os.X_OK):
|
||||||
FFPROBE = ffprobe_bin
|
FFPROBE = ffprobe_bin
|
||||||
elif os.path.isfile(avprobe_bin) or os.access(avprobe_bin, os.X_OK):
|
elif avprobe_bin.is_file() or os.access(avprobe_bin, os.X_OK):
|
||||||
FFPROBE = avprobe_bin
|
FFPROBE = avprobe_bin
|
||||||
else:
|
|
||||||
|
if not FFPROBE:
|
||||||
FFPROBE = which('ffprobe') or which('avprobe')
|
FFPROBE = which('ffprobe') or which('avprobe')
|
||||||
|
|
||||||
if not FFPROBE:
|
if not FFPROBE:
|
||||||
FFPROBE = None
|
FFPROBE = None
|
||||||
if CHECK_MEDIA:
|
if CHECK_MEDIA:
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
from __future__ import annotations
|
|
||||||
__author__ = 'Justin'
|
|
Loading…
Add table
Add a link
Reference in a new issue