Skip to main content

Python package to extract YouTube video titles and URLs

Project description

Automate a YouTube Channel Videos List Creation

Overview

This repo is intended to provide a quick, simple way to create a list of all videos posted to any YouTube channel by providing just the URL to that user's channel videos. The general format for this is https://www.youtube.com/user/TheChannelYouWantToScrape/videos OR
https://www.youtube.com/channel/TheChannelYouWantToScrape/videos,
with TheChannelYouWantToScrape replaced with the username of the channel.

Quick Start

RECOMMENDED:

pip install yt-videos-list

Running as a module

python3
from yt_videos_list import ListGenerator
LG = ListGenerator()
LG.generate_list('channelName', 'channelType', 'optional_file_name_you_can_provide')

There are two types of YouTube channels: one type is a user channel and the other is a channel channel.

To scrape the video titles along with the link to the video, you need to run the generate_list(channelName, channelType) method on the ListGenerator object you just created, substituting the type of channel for channelType argument and the name of the channel for the channelName argument. By default, the name of the file produced will be channelNameVideosList.ext where the .ext will be .csv or .txt depending on the type of file(s) that you specified.

Basic Use Case

user channelType (example uses sentdex):

LG.generate_list('sentdex', 'user')

channel channelType (example uses Billie Eilish):

LG.generate_list('UCiGm_E4ZwYSHV3bcW1pnSeQ', 'channel')

Naming the output file

In order to get a more descriptive file name, add how you would like to describe the file for the (optional) third argument (fileName):

LG.generate_list('UCiGm_E4ZwYSHV3bcW1pnSeQ', 'channel', fileName='BillieEilish')

For more control:

ListGenerator(csv=True, csvWriteFormat='x', txt=True, txtWriteFormat='x', docx=False,
              docxWriteFormat='x', chronological=True,
              headless=False, scrollPauseTime=0.7,)

There are a number of optional arguments you can specify during the instantiation of the ListGenerator object. The preceding arguments are run by default, but in case you want more flexibility, you can specify:

  • The type of file you want: csv and txt currently available
  • If you want to override an already existing file with the same name: the default setting of 'x' shows you a warning and asks you if you want to overwrite the file or skip it. If you know you want to overwrite it, set the WriteFormat of the file type to 'w'
  • If you want the list of videos to be sorted by oldest to most recent (default setting set to True), otherwise set chronological=False to sort the videos by most recent to oldest
  • If you want to see the automated instance of the browser while it runs. Headless is set to False by default to give you an idea of what is going on and make it easier to debug in case something happens that you weren't expecting, but if you don't want to see it, set headless=True
  • How long you want to wait before scrolling down. The default setting of scrollPauseTime=0.7 works well with an average internet connection, but if your internet connection is much slower you may want to increase scrollPauseTime to a value larger than 0.7, and if your internet connection is very fast you can decrease the scrollPauseTime to a value that is smaller than 0.7

Running as a script (coming soon!)

Enter the directory in which the pyYT_videos_list.py and execute.py exist (they should both be in the same directory to avoid refernce issues), and run the following command from your command line

python3 yt_videos_list

You should see the following:

What is the name of the YouTube channel you want to generate the list for?
If you're unsure, click on the channel and look at the URL.
It should be in the format:
https://www.youtube.com/user/YourChannelName
OR
https://www.youtube.com/channel/YourChannelName
Substitute what you see for YourChannelName and type it in below:

Enter the name of the channel or user that you wish to scrape, and the program will do the rest for you!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yt_videos_list-0.1.3.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file yt_videos_list-0.1.3.tar.gz.

File metadata

  • Download URL: yt_videos_list-0.1.3.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for yt_videos_list-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6b294a9080f3f562af527f9a4103e6e51a9ff3191689e3acb9733991bef93050
MD5 0eb35a91866485bf88a947488292c405
BLAKE2b-256 124c440b719d57caa650b9686481d02d3e72e1327f2e7c93ff02f8bbf503d2ac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page