How to Use ydl

Index

  1. Introduction
  2. Environment Setup
  3. How to Use ydl
  4. Outroduction

Introduction

What is ydl in a nutshell?

ydl is a exhaustive video downloader written by me. Just using ydl once, you can download all the videos which belong to the specified channel or playlist. Since it memorizes what it downloaded, you can trace your favorite channel by regularly executing ydl. Furthermore, since it has (only) command-line interface, you can automatically and regularly execute ydl as a cron job.

Supported Environments

The program is cross-platform. Windows, macOS and Linux are fully-supported.

How can I trust ydl?

ydl is a open-source program, which means you are given a chance to read the source codes. Internally, ydl uses the official YouTube Data API to create a list of target videos, and then makes youtube-dl download the videos. And youtube-dl is also a open-source software, which is used world-wide by so many users that Wikipedia has an article about that. If you'd like to read or is just interested in the source codes of ydl, visit project page on GitHub.

Is it okay to download YouTube videos in the first place?

It depends. As of February 29, 2020, Terms of Service says
Permissions and Restrictions You may access and use the Service as made available to you, as long as you comply with this Agreement and applicable law. You may view or listen to Content for your personal, non-commercial use. You may also show YouTube videos through the embeddable YouTube player. The following restrictions apply to your use of the Service. You are not allowed to:
  1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as expressly authorized by the Service; or (b) with prior written permission from YouTube and, if applicable, the respective rights holders;
  2. ...
, so you are allowed to download YouTube videos under limited conditions. You have responsibility for what you choose to download. We and ydl never encourage you to violate Terms of Service nor the law.

How to use ydl?

The full documentation is here. However, it's long and requires higher-level background knowledge to understand. In other words, it's not beginner-friendly. In this page, for beginners, we explain in detail how to enjoy the essential functionality of ydl. Hereafter, we assume you are a Windows user and not familiar with terminal.

Environment Setup

Setup WSL

First you have to install Ubuntu 18.04 LTS on Windows. It's very easy. This subsection is based on the official instructions.
  1. Press Win + r keys, type "powershell" and press Ctrl + Shift + Enter to open PowerShell as Administrator.
  2. Execute the following command. In other words, copy the following text, paste it to the PowerShell window and press Enter. Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  3. Press Enter to restart the computer.
  4. Press Win + r keys, type "ms-windows-store:" (don't forget the last colon ":") and press Enter to open Microsoft Store.
  5. Search for "Ubuntu" and install Ubuntu 18.04 LTS.
  6. Press Win + r keys, type "ubuntu1804.exe" and press Enter to open Ubuntu.
  7. Wait for a few minutes to complete the installation of Ubuntu.
  8. Next you are required to set up a user account for Ubuntu. Enter arbitrary username and its arbitrary password. These are completely independent of your Windows' account. Note, when you type the password, what you are typing is not displayed even as black dots or asterisks. You may feel as if you were typing nothing, but you are actually entering what you type.
  9. Execute the following command. You can think this is Ubuntu version of Windows Update. It takes some time and you will once be prompted for the password you've just set. sudo apt update && sudo apt upgrade

Install youtube-dl

  1. Press Win + r keys, type "ubuntu1804.exe" and press Enter to open Ubuntu.
  2. Execute the following command. sudo apt install python3-pip
  3. Execute the following command to install youtube-dl. sudo pip3 install youtube-dl

Install ydl

  1. Execute the following command to download ydl git clone "https://github.com/your-diary/ydl"
  2. Execute the following command to install ydl cd ydl && sudo make install

Acquire an API Key to Access YouTube

  1. Visit Google API Console and login with your Google account.
  2. Click "Select a project".
  3. Click "NEW PROJECT".
  4. Click "CREATE" to create a project.
  5. Click "Select a project".
  6. Select the project you just created and click "OPEN".
  7. Click "ENABLE APIS AND SERVICES".
  8. Select "YouTube Data API v3".
  9. Click "ENABLE".
  10. Click "CREATE CREDENTIALS".
  11. Select "YouTube Data API v3", "Other UI (e.g. Windows, CLI tool)" and "Public data", and then click "What credentials do I need?".
  12. Copy the created API key.
  13. Replace YOUR_KEY in the following code with the key you have got and execute the result. This lets ydl access the API key. echo YOUR_KEY > ~/.ydl_api_key

How to Use ydl

Caveat

As explained in Is it okay to download YouTube videos in the first place?, you are allowed to download YouTube videos only under limited conditions. Again, we and ydl never encourage you to violate Terms of Service nor the law.

In this section, we provide a pseudo example.

Trace a channel with the channel ID

When the URL of a channel includes "youtube.com/channel/CHANNEL_ID", it indicates the channel is identified by "CHANNEL_ID".

Here is how to download all the videos in the channel specified by "CHANNEL_ID".

  1. Press Win + r keys, type "ubuntu1804.exe" and press Enter to open Ubuntu.
  2. Execute the following command to create a folder to which the downloaded videos will be saved, and to enter into it. The part "test_channel" is arbitrary. mkdir test_channel && cd test_channel
  3. Execute the following command where "CHANNEL_ID" is the channel id you'd like to specify. ydl creates a list of videos and makes youtube-dl download each video in turn. Everything is automatic. The only thing you have to do is to just wait for the operation to be completed, having coffee. easy_ydl --channel-id CHANNEL_ID
  4. After that, you may want to execute the following command to open the folder in Explorer. explorer.exe .
  5. Finally assume a week or so has past since the previous execution and you come to think you'd like to download only newly uploaded videos since then. The simple command below executed in the same folder is enough. This means there is no need to specify the channel id except for the very first execution. easy_ydl

Trace a channel with the username

When the URL of a channel includes "youtube.com/user/USERNAME", it indicates the channel is identified by "USERNAME". In this case, instead of easy_ydl --channel-id CHANNEL_ID , execute the following command. easy_ydl --username USERNAME

Outroduction

Currently, this document is only available in English. Translations are all welcome.

When you would like to suggest a new feature or have found a bug, if you have a GitHub account, please send a pull request or open an issue. If you don't, please send a mail to us.

If you have any questions, please do not hesitate to contact us.