A Ruby application to download videos and audio using RabbitMQ message queues. This project demonstrates how to use the Bunny gem to interact with RabbitMQ while applying Object-Oriented Programming concepts and composition over inheritance.
This project was created to provide a fun and practical way to learn RabbitMQ using the Bunny gem in Ruby. It also serves as a playground for applying Object-Oriented Programming concepts, emphasizing composition over inheritance.
By building a useful application that downloads media from video sites, it combines learning with practical utility.
- Ruby 3.x
- Docker (for RabbitMQ if you don't have an instance)
- ffmpeg -> on the computer that will run the receiver.rb file
- yt-dlp -> on the computer that will run the receiver.rb file
Before configuring the application, you need to set up RabbitMQ:
- Make sure the rabbitmq.conf file is in the conf/ directory
- Build the RabbitMQ Docker image:
bash bin/rabbitmq_start.sh
- Get the admin password from secrets/admin_password file, you will need it to fill the config.yml
git clone https://github.com/dklima/media_downloader
cd media_downloader
bundle install
Create the configuration file based on the provided sample: config.yml.sample
cp config.yml.sample config.yml
Edit the config.yml file to match your environment:
- Update RabbitMQ connection details with the hostname, port, and credentials (using the password you retrieved from the secrets/admin_password file)
- Make sure the virtual host is correct (usually )
/
- Specify download paths as required
Your config.yml should look something like this:
# RabbitMQ Configuration
- rabbitmq:
hostname: localhost
port: 5672
vhost: /
username: admin
password: something
queue: download_queue
# Downloader Configuration
- downloader:
path: ./medias
Use the send.rb script to submit a URL with media for downloading:
# Basic usage
ruby send.rb -u https://youtube.com/watch?v=example
# Download audio only
ruby send.rb -u https://youtube.com/watch?v=example -a
# Specify output filename
ruby send.rb -u https://youtube.com/watch?v=example -n "my_video"
# Keep original files
ruby send.rb -u https://youtube.com/watch?v=example -k
You can also run the send.rb script without arguments and you'll be prompted for the URL:
ruby send.rb
To start processing the download queue, run the receiverrb script:
ruby receive.rb
The consumer will listen for messages in the download queue and process them as they arrive.
_bin/
Binary executableslib/
Core application codeconf/
Configuration files for RabbitMQmedias/
Default directory for downloaded filessend.rb
Script to publish download requestsreceive.rb
Script to consume and process download requests
The MIT License (MIT)
Copyright © 2025
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.