Skip to content

Commit

Permalink
Made option for verbose ffmpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
jo1gi committed Dec 30, 2021
1 parent 6f6861c commit 2ea824b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion audiobookdl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def run():
logging.set_loglevel(options.loglevel)
if options.print_output:
logging.set_loglevel("error")
output.ffmpeg_output = options.ffmpeg_output
logging.log("Checking for missing dependencies", "debug")
missing = dependencies.check_dependencies(options)
if missing is not True:
Expand Down Expand Up @@ -60,7 +61,6 @@ def run():
def print_output(source: Source, template: str):
"""Prints output location"""
source.before()
title = source.get_title()
meta = source.get_metadata()
location = output.gen_output_location(template, meta)
print(location)
Expand Down
6 changes: 6 additions & 0 deletions audiobookdl/utils/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,10 @@ def parse_arguments():
help="Download only cover",
action='store_true',
)
parser.add_argument(
'--verbose-ffmpeg',
dest="ffmpeg_output",
help="Show ffmpeg output in terminal",
action="store_true",
)
return parser.parse_args()
6 changes: 4 additions & 2 deletions audiobookdl/utils/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
'artist': 'NA',
}

ffmpeg_output = False


def gen_output_filename(booktitle: str, file: Dict[str, str], template: str) -> str:
"""Generates an output filename based on different attributes of the
Expand All @@ -30,7 +32,7 @@ def combine_audiofiles(filenames: List[str], tmp_dir: str, output_path: str):
subprocess.run(
["ffmpeg", "-f", "concat", "-safe", "0", "-i",
combine_file, "-c", "copy", output_path],
capture_output=True)
capture_output=not ffmpeg_output)


def convert_output(filenames: List[str], output_dir: str, output_format: str):
Expand All @@ -44,7 +46,7 @@ def convert_output(filenames: List[str], output_dir: str, output_format: str):
if not output_format == split_path[1][1:]:
subprocess.run(
["ffmpeg", "-i", full_path, new_path],
capture_output=True)
capture_output=not ffmpeg_output)
os.remove(full_path)
new_paths.append(f"{os.path.splitext(name)[0]}.{output_format}")
return new_paths
Expand Down

0 comments on commit 2ea824b

Please sign in to comment.