From 78648b66c63b111f0a3288d0dd9ce33a34662409 Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Tue, 5 Dec 2023 21:19:14 +0300 Subject: [PATCH] Use get_audio_properties instead of mutagen --- .gitignore | 3 +++ cyberdrop_dl/utils/sorting.py | 13 ++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 2c4681f05..1866efcbe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ /Test-AppData-Dir/ /AppData/ /Downloads/ + +# Python cache +__pycache__ diff --git a/cyberdrop_dl/utils/sorting.py b/cyberdrop_dl/utils/sorting.py index 804c0c059..2169d5c19 100644 --- a/cyberdrop_dl/utils/sorting.py +++ b/cyberdrop_dl/utils/sorting.py @@ -3,11 +3,10 @@ from pathlib import Path from typing import TYPE_CHECKING -import mutagen -from videoprops import get_video_properties from PIL import Image +from videoprops import get_audio_properties, get_video_properties -from cyberdrop_dl.utils.utilities import FILE_FORMATS, purge_dir, log_with_color +from cyberdrop_dl.utils.utilities import FILE_FORMATS, log_with_color, purge_dir if TYPE_CHECKING: from cyberdrop_dl.managers.manager import Manager @@ -88,10 +87,10 @@ async def sort_audio(self, file: Path, base_name: str) -> None: """Sorts an audio file into the sorted audio folder""" self.audio_count += 1 - file_info = mutagen.FileType(file).info - length = file_info.length - bitrate = file_info.bitrate - sample_rate = file_info.sample_rate + props = get_audio_properties(str(file)) + length = str(props['duration']) + bitrate = str(props['bit_rate']) + sample_rate = str(props['sample_rate']) parent_name = file.parent.name filename, ext = file.stem, file.suffix