DEV Community

antonio vasconcellos
antonio vasconcellos

Posted on • Updated on

Downloading YouTube Videos with Elixir

We recently had to develop some features that involved downloading videos from YouTube.

After some research, we found YT-DLP([https://github.com/yt-dlp/yt-dlp])

yt-dlp is a fork of youtube-dl based on the now inactive youtube-dlc. The main focus of this project is to add new features and patches while staying up to date with the original project.

From this came the idea of writing a simple wrapper around Elixir to facilitate integration with our stack.

Exyt-dlp

[https://github.com/v0i4/exyt]

setup

[https://github.com/yt-dlp/yt-dlp/wiki/Installation]
[https://hex.pm/packages/exyt_dlp]

add to your mix.exs file:
{:exyt_dlp, "~> 0.1.2"}

run mix deps.get at project root folder

check installation

iex> Exyt.check_setup()
"Installed yt-dlp version: 2023.07.06\n"
Enter fullscreen mode Exit fullscreen mode

download

iex> url = "https://www.youtube.com/watch?v=BaW_jenozKc"
iex> Exyt.download(url, %{output: "/tmp/test/", format: "mp4", quality: :fhd})
Enter fullscreen mode Exit fullscreen mode

customize your params

iex> Exyt.ytdlp(["--get-filename"], "https://www.youtube.com/watch?v=BaW_jenozKc")
Enter fullscreen mode Exit fullscreen mode

check docs for more details

https://hexdocs.pm/exyt_dlp/Exyt.html#content

contribute

accepting PRs :)

Top comments (1)

Collapse
 
randellbrianknight profile image
Randell Brian Knight

Hello Antonio and welcome to the Dev community 👋