mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-27 21:54:17 +01:00
use which from stdlib instead our own version
This commit is contained in:
parent
6c41d00c4f
commit
d61e5793e6
@ -3,12 +3,13 @@ from random import sample
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
from shutil import which
|
||||
from requests import post, codes, Timeout
|
||||
from re import match
|
||||
|
||||
from svtplay_dl.log import log
|
||||
from svtplay_dl.utils.output import formatname
|
||||
from svtplay_dl.utils.proc import which, run_program
|
||||
from svtplay_dl.utils.proc import run_program
|
||||
|
||||
|
||||
class postprocess(object):
|
||||
|
@ -2,6 +2,7 @@ import os
|
||||
import sys
|
||||
import copy
|
||||
import logging
|
||||
from shutil import which
|
||||
|
||||
|
||||
from svtplay_dl.log import log
|
||||
@ -90,7 +91,6 @@ def get_one_media(stream):
|
||||
return
|
||||
|
||||
if stream.config.get("merge_subtitle"):
|
||||
from svtplay_dl.utils.proc import which
|
||||
if not which('ffmpeg'):
|
||||
log.error("--merge-subtitle needs ffmpeg. Please install ffmpeg.")
|
||||
log.info("https://ffmpeg.org/download.html")
|
||||
|
@ -1,34 +1,7 @@
|
||||
import platform
|
||||
import subprocess
|
||||
import logging
|
||||
|
||||
|
||||
def which(program):
|
||||
import os
|
||||
|
||||
if platform.system() == "Windows":
|
||||
program = "{0}.exe".format(program)
|
||||
|
||||
def is_exe(fpath):
|
||||
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
||||
|
||||
fpath, fname = os.path.split(program)
|
||||
if fpath:
|
||||
if is_exe(program):
|
||||
return program
|
||||
else:
|
||||
for path in os.environ["PATH"].split(os.pathsep):
|
||||
path = path.strip('"')
|
||||
exe_file = os.path.join(path, program)
|
||||
if is_exe(exe_file):
|
||||
return exe_file
|
||||
if os.path.isfile(program):
|
||||
exe_file = os.path.join(os.getcwd(), program)
|
||||
if is_exe(exe_file):
|
||||
return exe_file
|
||||
return None
|
||||
|
||||
|
||||
def run_program(cmd, show=True):
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
|
Loading…
Reference in New Issue
Block a user