Skip to content

avj2352/youtube-mp3-converter

Repository files navigation

Youtube MP3 Toolsuite

Simple CLI application to download, convert to MP3 format, and add metadata information. Metadata information include

  • Title
  • Artist
  • Album Artist
  • Genre
  • Album Artwork

You need ffmpeg encoder installed in your machine in order for the following scripts to work

  • youtube_converter.py
  • youtube_metadata.py

Important Links

Instructions - using uv

  • Create a folder to save mp3 files - download
  • From the root folder, run uv run main.py

Instructions - using pip

  • Clone / Download the ZIP version into your local machine
  • Create folder to save mp3 files - download
  • Setup a Local environment using python -m venv venv --prompt="utump3(3.11)"
  • Activate the virtual environment
  # For Macbook
  source ./venv/Scripts/activate

  # For windows
  ./venv/Scripts/activate.bat
  • Run the following to install dependant libraries
pip install -r requirements.txt

TLDR;

Read more about the error in the link below -NoneType object has no attribute span

I just patched this error by simply modifying venv/.local/lib/python3.7/site-packages/pytube/cipher.py Line 411

transform_plan_raw = find_object_from_startpoint(raw_code, match.span()[1] - 1)

to

transform_plan_raw = js

And everything works fine. Hope this can solve your problem. Thank you very much! It worked perfectly here. I have no idea how this change fixed the bug (if you want to explain that would be great), but it worked perfectly anyway.

Youtube Converter

You need to convert the downloaded file to an Actual MP3 audio file. Run the following script from terminal

# s - source path (source location of the media file)
# d - destination path (where you want the converted file to reside)
python3 ./youtube_converter.py -s ./download/harry_potter.mp3 -d ./download/harry_potter_convert.mp3

Youtube Metadata

In order to add metadata information (including artwork file) run the following script from terminal

# m - path to the mp3 file
# a - path to the artwork file (optional)
python3 ./youtube_metadata.py -m ./download/harry_potter_ea_games_soundtrack_convert.mp3 -a ./download/harry_potter.jpeg

About

Python script to download youtube videos as mp3 files. uses pytubefix

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published