diff --git a/YouTubeMDBot/audio/__init__.py b/YouTubeMDBot/audio/__init__.py index 7970b6b..49eab31 100755 --- a/YouTubeMDBot/audio/__init__.py +++ b/YouTubeMDBot/audio/__init__.py @@ -17,5 +17,4 @@ from ..audio.ffmpeg import FFmpegOGG from ..audio.ffmpeg import FFmpegMP3 from ..audio.ffmpeg import ffmpeg_available -from ..audio.ffmpeg import FFmpegProcessor from ..audio.fpcalc import FPCalc diff --git a/YouTubeMDBot/audio/ffmpeg.py b/YouTubeMDBot/audio/ffmpeg.py index bda56ef..53d199f 100755 --- a/YouTubeMDBot/audio/ffmpeg.py +++ b/YouTubeMDBot/audio/ffmpeg.py @@ -15,14 +15,12 @@ # along with this program. If not, see . from abc import ABC from abc import abstractmethod -from io import BytesIO from typing import List from subprocess import PIPE from subprocess import Popen from ..constants import FFMPEG_OPENER from ..constants import FFMPEG_CONVERTER -from ..constants import FFMPEG_PROCESSOR def ffmpeg_available() -> bool: @@ -62,11 +60,6 @@ def get_extra(self) -> bytes: return self.__err -class FFmpegProcessor(FFmpeg): - def __init__(self, data: bytes): - super().__init__(data=data, command=FFMPEG_PROCESSOR.copy()) - - class FFmpegOpener(FFmpeg): def __init__(self, data: bytes): super().__init__(data=data, command=FFMPEG_OPENER.copy()) diff --git a/YouTubeMDBot/constants/__init__.py b/YouTubeMDBot/constants/__init__.py index 01e666d..60906a2 100755 --- a/YouTubeMDBot/constants/__init__.py +++ b/YouTubeMDBot/constants/__init__.py @@ -18,5 +18,4 @@ from ..constants.app_constants import YDL_CLI_OPTIONS from ..constants.app_constants import YOUTUBE from ..constants.app_constants import FFMPEG_OPENER -from ..constants.app_constants import FFMPEG_PROCESSOR from ..constants.app_constants import FFMPEG_CONVERTER diff --git a/YouTubeMDBot/constants/app_constants.py b/YouTubeMDBot/constants/app_constants.py index 5f1a98d..5564c27 100755 --- a/YouTubeMDBot/constants/app_constants.py +++ b/YouTubeMDBot/constants/app_constants.py @@ -37,6 +37,5 @@ # FFmpeg commands FFMPEG_OPENER = "ffmpeg -i - -f s16le -".split(" ") -FFMPEG_PROCESSOR = "ffmpeg -i - -filter:a loudnorm -vn -b:a 128k -f m4a -".split(" ") FFMPEG_CONVERTER = ["ffmpeg", "-i", "-", "-vn", "-map_metadata", "0", "-movflags", "use_metadata_tags"] diff --git a/YouTubeMDBot/downloader/youtube_downloader.py b/YouTubeMDBot/downloader/youtube_downloader.py index 27552af..6139205 100755 --- a/YouTubeMDBot/downloader/youtube_downloader.py +++ b/YouTubeMDBot/downloader/youtube_downloader.py @@ -16,8 +16,6 @@ from io import BytesIO from typing import Tuple -from ..errors import ProcessorError -from ..audio import FFmpegProcessor from ..constants.app_constants import YDL_CLI_OPTIONS @@ -36,13 +34,7 @@ def download(self) -> Tuple[BytesIO, bytes]: stdout, stderr = proc.communicate() retcode = proc.returncode if retcode == 0: - processor = FFmpegProcessor(data=stdout) - if processor.process() == 0: - return BytesIO(processor.get_output()), processor.get_output() - else: - raise ProcessorError( - "ffmpeg failed: " + str(processor.get_extra().decode("utf-8")) - ) + return BytesIO(stdout), stdout else: raise RuntimeError("youtube-dl downloader exception - more info: " + str(stderr.decode("utf-8"))) diff --git a/cover.jpg b/cover.jpg old mode 100644 new mode 100755 index 169117d..1567926 Binary files a/cover.jpg and b/cover.jpg differ diff --git a/hello.m4a b/hello.m4a old mode 100644 new mode 100755 index 1126d7e..9d42f4a Binary files a/hello.m4a and b/hello.m4a differ diff --git a/o.ipod b/o.ipod new file mode 100644 index 0000000..f3c44d9 Binary files /dev/null and b/o.ipod differ diff --git a/o.m4a b/o.m4a new file mode 100644 index 0000000..f3c44d9 Binary files /dev/null and b/o.m4a differ diff --git a/o.mp4 b/o.mp4 new file mode 100644 index 0000000..a5d59d6 Binary files /dev/null and b/o.mp4 differ diff --git a/out.m4a b/out.m4a new file mode 100644 index 0000000..ea242e6 Binary files /dev/null and b/out.m4a differ diff --git a/temp_f.py b/temp_f.py new file mode 100644 index 0000000..bcb91fa --- /dev/null +++ b/temp_f.py @@ -0,0 +1,30 @@ +import mutagen +import subprocess + +from pydub import effects, AudioSegment +from io import BytesIO +from tempfile import TemporaryFile + +ctr = BytesIO() +# command = "ffmpeg -i Inm-N5rLUSI.m4a -filter:a loudnorm -vn -b:a 128k -c:a aac -f ipod {}".format(tf.name).split(" ") +# print(tf.name) +# proc = subprocess.Popen(command, stderr=subprocess.PIPE) +# out, err = proc.communicate() +# print(err.decode("utf-8")) +with open("Inm-N5rLUSI.m4a", "rb") as audio: + sound = audio.read() +bf = BytesIO(sound) +s = AudioSegment(bf, format="m4a") +s2 = effects.normalize(s) +s2.export(bf, format="m4a") +c = input("Continue? [yes/no] - ") +if c == "yes": + print(tf.closed) + tf.seek(0) + data = BytesIO(tf.read()) + data.seek(0) + print(mutagen.File(data).pprint()) + with open("out.m4a", "wb") as file: + data.seek(0) + file.write(data.read()) +