From 0f3f4cb1dd7670b84b85a5bb03a58e5d55b6794c Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Sun, 17 Mar 2024 20:18:40 -0600 Subject: Using ffmpeg instead of moviepy --- buildozer.spec | 4 ++-- requirements.txt | 2 +- src/model/youload_playlist.py | 10 ++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/buildozer.spec b/buildozer.spec index 8d85df8..47bcd34 100644 --- a/buildozer.spec +++ b/buildozer.spec @@ -13,7 +13,7 @@ package.domain = nate.youload source.dir = src # (list) Source files to include (let empty to include all the files) -source.include_exts = py,png,jpg,kv,atlas,pymovie +source.include_exts = py,png,jpg,kv,atlas # (list) List of inclusions using pattern matching #source.include_patterns = assets/*,images/*.png @@ -37,7 +37,7 @@ version = 1.2 # (list) Application requirements # comma separated e.g. requirements = sqlite3,kivy -requirements = python3,kivy,pytube +requirements = python3,kivy,ffmpeg-python # (str) Custom source folders for requirements # Sets custom source for any requirements with recipes diff --git a/requirements.txt b/requirements.txt index c286d2f..8769e6d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ kivy pytube -moviepy +ffmpeg-python diff --git a/src/model/youload_playlist.py b/src/model/youload_playlist.py index 51f8758..1856c64 100644 --- a/src/model/youload_playlist.py +++ b/src/model/youload_playlist.py @@ -1,5 +1,5 @@ from pytube import Playlist -from moviepy.editor import VideoFileClip +import ffmpeg import os def make_alpha_numeric(string: str) -> str: @@ -52,13 +52,11 @@ class YouLoadPlayList: elif self.download_type == "mp3": file_path = video.streams.first().download(output_path=self.folder_name, filename_prefix=filename_prefix) - # Get video from mp4. - video_audio = VideoFileClip(file_path) - - # Get mp3. + # To mp3. file_path_mp3 = file_path[:-4] + ".mp3" - video_audio.audio.write_audiofile(file_path_mp3) + ffmpeg.input(file_path).output(file_path_mp3).run() + # Remove mp4 file. os.remove(file_path) else: video.streams.get_by_resolution(self.download_type).download(output_path=self.folder_name, filename_prefix=filename_prefix) -- cgit v1.2.3