How to download and get the list of all video URLs from YouTube using Pytube in Python?

  Pytube is a very serious, lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.

Prerequisite

Pytube can also help to get the author’s name, views of videos, captions of YouTube videos, etc. You can use pytube to interact with channels.
There is a various APIs python module that can help to fetch metadata.

Table of Contents

Required Module

In this tutorial, we are using the Pytube Module of Python. You can download it using PIP in python.

pip install pytube

Approach To Use Pytube

  1. Import the pytube module.
  2. Create and initialize an object of channel and pass the URL of the YouTube channel as arguments e.g, channel_obj = Channel(‘https://youtu.be/mBJMkFNRVek’).
  3. Print the URL using For loop as shown in program.

Pytube program implementation is given below.

Program: Get YouTube Videos URLs from Channel Using Pytube

from pytube import Channel
 
channel_url = 'https://www.youtube.com/channel/UCccqNO0SRLSwJkuTYheyl4A'
channel_obj  = Channel(channel_url)


print('List Of Videos URL:')
for url in channel_obj.video_urls:
    print(url)

Output

List Of Videos URL:
https://www.youtube.com/watch?v=mBJMkFNRVek

Leave a Reply

Your email address will not be published. Required fields are marked *