Easily download mp3 / mp4 with python and youtube-dl!

Purpose

Easily download mp3 / mp4 with python and youtube-dl!

environment


$python3 --version
Python 3.7.3

Install ffmpeg for mp3 conversion

$brew install ffmpeg

DL folder creation

$mkdir mp4-download

Virtual environment for Python

$cd mp4-download
$python3 -m venv venv
$source venv/bin/activate

Install youtube-dl with pip

$pip install youtube-dl

Download video (mp4)

$youtube-dl https://youtu.be/UVapiyZr2Mk
```bash
## Execution result
```bash
[youtube] UVapiyZr2Mk: Downloading webpage
[download] Destination:It's tofu-UVapiyZr2Mk.mp4
[download] 100% of 20.11MiB in 00:07

Download video (mp4)

$youtube-dl https://youtu.be/RFuKNaHE63M
[youtube] RFuKNaHE63M: Downloading webpage
[download] Destination:Asteria SKT Tofu Shop-RFuKNaHE63M.mp4
[download] 100% of 16.55MiB in 00:05

Check download results


$ls -a
.
..
venv
It's tofu-UVapiyZr2Mk.mp4
Asteria SKT Tofu Shop-RFuKNaHE63M.mp4

Video playback

$open It's tofu-UVapiyZr2Mk.mp4 
$open Asteria SKT Tofu Shop-RFuKNaHE63M.mp4

mp3 download

$youtube-dl --extract-audio --audio-format mp3 https://youtu.be/OfbBWmO45rs

Execution result

[youtube] OfbBWmO45rs: Downloading webpage
[youtube] OfbBWmO45rs: Downloading MPD manifest
[download][Jenkins Life Counseling Room] To Mr. Pilomi-OfbBWmO45rs.webm has already been downloaded
[download] 100% of 17.78MiB
[ffmpeg] Destination:[Jenkins Life Counseling Room] To Mr. Pilomi-OfbBWmO45rs.mp3
Deleting original file [Jenkins Life Counseling Room] To Mr. Pilomi-OfbBWmO45rs.webm (pass -k to keep)

mp3 playback

$open [Jenkins Life Counseling Room] To Mr. Pilomi-OfbBWmO45rs.mp3

that's all!

Thank you very much!

Recommended Posts

Easily download mp3 / mp4 with python and youtube-dl!
Easy partial download of mp4 with python and youtube-dl!
Easily beep with python
Automatically search and download YouTube videos with Python
Programming with Python and Tkinter
Easily serverless with Python with chalice
Python and hardware-Using RS232C with Python-
python with pyenv and venv
Download csv file with python
Works with Python and R
Try hitting the Twitter API quickly and easily with Python
Easily write JSON and Python dataclass conversions with quicktype and dacite
How to convert Youtube to mp3 and download it super-safely [Python]
Easily build network infrastructure and EC2 with AWS CDK Python
Communicate with FX-5204PS with Python and PyUSB
Shining life with Python and OpenCV
Robot running with Arduino and python
Install Python 2.7.9 and Python 3.4.x with pip.
Neural network with OpenCV 3 and Python 3
Scraping with Node, Ruby and Python
Implemented file download with Python + Bottle
Scraping with Python, Selenium and Chromedriver
Easily handle lists with python + sqlite3
Scraping with Python and Beautiful Soup
MP3 to WAV conversion with Python
JSON encoding and decoding with python
Hadoop introduction and MapReduce with Python
[GUI with Python] PyQt5-Drag and drop-
Easily handle databases with Python (SQLite3)
I played with PyQt5 and Python3
[Python] Collect images easily with icrawler!
Reading and writing CSV with Python
Multiple integrals with Python and Sympy
Easily post to twitter with Python 3
Coexistence of Python2 and 3 with CircleCI (1.0)
Easy modeling with Blender and Python
Sugoroku game and addition game with python
Upload and download images with falcon
FM modulation and demodulation with Python
Download python
I tried to easily detect facial landmarks with python and dlib
[python3] Implement debug log output function easily with logging and Click
Communicate between Elixir and Python with gRPC
Data pipeline construction with Python and Luigi
Calculate and display standard weight with python
Monitor Mojo outages with Python and Skype
FM modulation and demodulation with Python Part 3
Read CSV file with python (Download & parse CSV file)
Python installation and package management with pip
Using Python and MeCab with Azure Databricks
POST variously with Python and receive with Flask
Capturing images with Pupil, python and OpenCV
Fractal to make and play with Python
A memo with Python2.7 and Python3 on CentOS
Download Japanese stock price data with python
Use PIL and Pillow with Cygwin Python
Create and decrypt Caesar cipher with python
CentOS 6.4 with Python 2.7.3 with Apache with mod_wsgi and Django
Reading and writing JSON files with Python
Dealing with "years and months" in Python
Download files on the web with Python