Working on comments and minor bug fixes in tools
This commit is contained in:
parent
09d7d2c537
commit
4e335a3650
@ -5,12 +5,20 @@
|
|||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import colorama
|
import colorama
|
||||||
colorama.init()
|
colorama.init()
|
||||||
|
|
||||||
|
|
||||||
def load_arguments():
|
def load_arguments():
|
||||||
|
'''Get/load command parameters
|
||||||
|
|
||||||
|
Args:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
arguments: A dictionary of lists of the options passed by the user
|
||||||
|
'''
|
||||||
arguments = {
|
arguments = {
|
||||||
"directories":list(),
|
"directories":list(),
|
||||||
"files":list(),
|
"files":list(),
|
||||||
@ -44,7 +52,14 @@ def load_arguments():
|
|||||||
|
|
||||||
|
|
||||||
def detect_ffmpeg():
|
def detect_ffmpeg():
|
||||||
'''Returns the version of ffmpeg that is installed or false'''
|
'''Returns the version of ffmpeg that is installed or false
|
||||||
|
|
||||||
|
Args:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
String : The version number of the installed FFMPEG
|
||||||
|
False : The failure of retreiving the version number
|
||||||
|
'''
|
||||||
try:
|
try:
|
||||||
txt = subprocess.check_output(['ffmpeg', '-version'], stderr=subprocess.STDOUT).decode()
|
txt = subprocess.check_output(['ffmpeg', '-version'], stderr=subprocess.STDOUT).decode()
|
||||||
if "ffmpeg version" in txt:
|
if "ffmpeg version" in txt:
|
||||||
@ -55,7 +70,14 @@ def detect_ffmpeg():
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def user_confirm(question, color=False):
|
def user_confirm(question, color=False):
|
||||||
'''Returns the user answer to a yes or no question'''
|
'''Returns the user answer to a yes or no question
|
||||||
|
|
||||||
|
Args:
|
||||||
|
question : A String containing the user question
|
||||||
|
color : A String containing the prefered color for a question (reg/yellow)
|
||||||
|
Returns:
|
||||||
|
Bool : Positive or negative return to the user question
|
||||||
|
'''
|
||||||
if color == "yellow":
|
if color == "yellow":
|
||||||
print(f"{colorama.Fore.YELLOW}{question} {colorama.Fore.RESET}", end = '')
|
print(f"{colorama.Fore.YELLOW}{question} {colorama.Fore.RESET}", end = '')
|
||||||
answer = input()
|
answer = input()
|
||||||
@ -71,19 +93,33 @@ def user_confirm(question, color=False):
|
|||||||
print("Please answer with yes (Y) or no (N)...")
|
print("Please answer with yes (Y) or no (N)...")
|
||||||
return user_confirm(question)
|
return user_confirm(question)
|
||||||
|
|
||||||
def deletefile(filename):
|
def deletefile(filepath):
|
||||||
'''Delete a file, Returns a boolean'''
|
'''Delete a file, Returns a boolean
|
||||||
|
|
||||||
|
Args:
|
||||||
|
filepath : A string containing the full filepath
|
||||||
|
Returns:
|
||||||
|
Bool : The success of the operation
|
||||||
|
'''
|
||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filepath)
|
||||||
except OSError:
|
except OSError:
|
||||||
print(f"{colorama.Fore.RED}Error deleting {filename}{colorama.Fore.RESET}")
|
print(f"{colorama.Fore.RED}Error deleting {filepath}{colorama.Fore.RESET}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
print(f"{colorama.Fore.GREEN}Successfully deleted {filename}{colorama.Fore.RESET}")
|
print(f"{colorama.Fore.GREEN}Successfully deleted {filepath}{colorama.Fore.RESET}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def findfreename(filepath, attempt = 0):
|
def findfreename(filepath, attempt = 0):
|
||||||
'''Delete a file, Returns a boolean'''
|
''' Given a filepath it will try to find a free filename by appending to the name.
|
||||||
|
First trying as passed in argument, then adding [HEVC] to the end and if all fail [HEVC](#).
|
||||||
|
|
||||||
|
Args:
|
||||||
|
filepath : A string containing the full filepath
|
||||||
|
attempt : The number of times we have already tryed
|
||||||
|
Returns:
|
||||||
|
filepath : The first free filepath we found
|
||||||
|
'''
|
||||||
|
|
||||||
attempt += 1
|
attempt += 1
|
||||||
|
|
||||||
@ -93,9 +129,9 @@ def findfreename(filepath, attempt = 0):
|
|||||||
hevcpath = filename + "[HEVC]" + extension
|
hevcpath = filename + "[HEVC]" + extension
|
||||||
copynumpath = filename + f"[HEVC]({attempt})" + extension
|
copynumpath = filename + f"[HEVC]({attempt})" + extension
|
||||||
|
|
||||||
if not os.path.exists(filepath):
|
if not os.path.exists(filepath) and attempt <= 2:
|
||||||
return filepath
|
return filepath
|
||||||
elif not os.path.exists(hevcpath):
|
elif not os.path.exists(hevcpath) and attempt <= 2:
|
||||||
return hevcpath
|
return hevcpath
|
||||||
elif not os.path.exists(copynumpath):
|
elif not os.path.exists(copynumpath):
|
||||||
return copynumpath
|
return copynumpath
|
||||||
|
|||||||
@ -29,6 +29,10 @@ colorama.init()
|
|||||||
def main():
|
def main():
|
||||||
'''
|
'''
|
||||||
MediaCurator's main function
|
MediaCurator's main function
|
||||||
|
|
||||||
|
Args:
|
||||||
|
|
||||||
|
Returns:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
print(f"{colorama.Style.BRIGHT}")
|
print(f"{colorama.Style.BRIGHT}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user