Skip to content

CLI program that can download and mux audio and video data from youtube by url. With metadata entry!

Notifications You must be signed in to change notification settings

MajorMilk/YoutubeDownloaderCLI

Repository files navigation

YoutubeDownloaderCLI

A command-line tool for downloading YouTube videos and playlists. This tool serves as a CLI alternative to my other project, YouTube-To-MPX.

Installation

Prerequisites

  1. FFmpeg: Download and install FFmpeg, then add it to your system's PATH
  2. .NET SDK: Install the latest version of .NET SDK.

Steps

  1. Clone this repository.
  2. Build the source code using the latest .NET version.
  3. Add the directory containing the compiled executable files to your system's PATH.
  4. Done! You can now use the tool from the command line.

Adding things to your PATH variable

You can learn how to do this here on Windows and here on Linux.

How do I use the new Spotify Metadata features?

  1. Clone this repo and build the code
  2. Create an app on the spotify developers portal here
  3. Run the Spotify binary at least once, it will generate a json file in the same dir as other downloaded jsons with places for you to put your client id and client secret
  4. After placing your client id and secret into that json, simply run the exe, and the program will try and scrape metadata for all your m4a files

Usage

To download a single YouTube video:

YoutubeDownloader "<YouTube Video URL>"

To download a full playlist:

PlaylistDownloader "<Playlist URL>"

To download a complete MP4 version, add an extra argument:

YoutubeDownloader "<YouTube Video URL>" v

To find metadata for all of your m4a files:

SpotifyMetadataGenerator

To find metadata for only one of your m4a files:

SpotifyMetadataGenerator "<Path to File>"

Output Details

  • All downloaded files are saved in ~/Downloads/YoutubeDownloads.
  • Files are initially downloaded as WebM and converted to M4A. (YouTube does not directly serve other formats)
  • A JSON file containing metadata is also generated. (You should prob leave it in place)

Notes

  • On Linux, you may need to manually create the thumbnails directory under the json directory.
  • If using Linux, surround URLs with double quotes (") to avoid shell-related issues.
  • Spotify integration will not work unless you create an app on the spotify dev portal. Old functions will work fine though.
  • This program heavily relies on files being in the right places, please keep your original m4a files and jsons in their saved locations.

Building from Source

  1. Clone the repository (use the dev branch for the latest features, though it may contain bugs):
    git clone https://github.com/MajorMilk/YoutubeDownloaderCLI
  2. Navigate to the directory containing the solution file (.sln).
  3. Run the following command to build the project:
    dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -p:EnableTrim=true -o ./Release
    • For Linux, replace win-x64 with linux-x64.
  4. The compiled executables will be available in the ./Release folder.

Dependencies

This project uses the following libraries:

  • Newtonsoft.JSON (for JSON handling)
  • Cli.Wrap (for executing external processes)
  • YoutubeExplode (for downloading videos)

Feedback & Contributions

Your feedback is greatly appreciated! I am particularly interested in:

  • Preferred output formats
  • Whether WebM files should be deleted after conversion
  • Whether JSON metadata files should be deleted after processing
  • Whether converted files should be saved in the Music folder instead

Pull requests are welcome! If you know of an API that provides better metadata retrieval based on title and author, please share it.

About

CLI program that can download and mux audio and video data from youtube by url. With metadata entry!

Topics

Resources

Stars

Watchers

Forks

Languages