infinitel8p / youtube-dl

Simple YouTube Downloader with GUI, work in progress
1 stars 0 forks source link

convert to mp3 #8

Closed infinitel8p closed 1 year ago

infinitel8p commented 1 year ago

use line 92 raise ValueError( f"[ Error ] : {subtype_menu.get()} subtype not available for this video.") to instead convert the audio file:


from pytube import YouTube
from pydub import AudioSegment
import os

yt = YouTube("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

# Download the video in MP4 format
video = yt.streams.filter(file_extension='mp4').first()
video.download("path/to/save/mp4/file/")

# Open the MP4 file and convert it to MP3 format
audio = AudioSegment.from_file("path/to/save/mp4/file/original_audio.mp4", format="mp4")
audio.export("path/to/save/mp3/file/converted_audio.mp3", format="mp3")

# Delete the original MP4 file
os.remove("path/to/save/mp4/file/original_audio.mp4")
infinitel8p commented 1 year ago

Build your application as a standalone executable using a package such as pyinstaller or cx_Freeze. These tools allow you to package your application along with all of its dependencies, including FFmpeg, into a single executable file. The user can then run the executable on their system without the need to install FFmpeg or other dependencies.

Use a package manager such as conda or pipenv to manage your application's dependencies. You can specify FFmpeg as a dependency in your environment.yml or Pipfile, and the package manager will take care of downloading and installing FFmpeg on the user's system.

You can also package your application as a Docker container. Docker allows you to include all of your application's dependencies, including FFmpeg, within the container. The user can then run the container on their system without the need to install FFmpeg or other dependencies.

infinitel8p commented 1 year ago

fixed