Skip to content

Junman140/YouTube-Thumbnails-Scraper

Repository files navigation


YouTube Video Metadata Fetcher

This Python script fetches detailed metadata for all videos in a YouTube channel, including video titles, thumbnails, view counts, like counts, and other stats. The metadata is saved into a metadata.json file for further use.


Features

  • Fetch video titles, descriptions, view count, like count, and more.
  • Fetch high-quality thumbnails for each video.
  • Fetch video duration and other useful metadata.
  • Save all data into a structured metadata.json file.
  • Handle large channels with pagination for video listings.

Prerequisites

Before running the script, you will need the following:

  1. Python 3.x installed on your machine.
  2. YouTube Data API v3 keyGet an API key here.
  3. Python packages: requests to make HTTP requests to the YouTube API.

Installation

1. Clone the repository or download the script file:

git clone https://github.com/your-repo-name/YouTube-Video-Metadata.git

2. Install the required dependencies:

pip install requests

Configuration

  1. Open the fetch_metadata.py script.
  2. Replace the following placeholders:
    • YOUR_API_KEY: Replace this with your YouTube Data API v3 key.
    • CHANNEL_ID: Replace this with the YouTube channel's unique ID. (You can find the channel ID in the URL, e.g., https://www.youtube.com/channel/CHANNEL_ID).

Usage

  1. Run the script: After configuring the script with your API key and channel ID, run it in your terminal:

    python fetch_metadata.py
  2. What happens next:

    • The script will fetch the Uploads playlist of the given channel.
    • It will retrieve all video IDs in that playlist.
    • The script will then fetch detailed metadata for each video, including:
      • Video title
      • Video description
      • Published date
      • View count
      • Like count
      • Dislike count
      • Comment count
      • Video duration
      • Video thumbnail URL
    • All data will be saved in the metadata.json file.

Output

The script saves the fetched metadata in a metadata.json file, structured like this:

[
    {
        "videoId": "abcd1234",
        "title": "Sample Video Title",
        "description": "This is the description of the video.",
        "publishedAt": "2023-05-01T12:34:56Z",
        "viewCount": 1500,
        "likeCount": 500,
        "dislikeCount": 10,
        "commentCount": 150,
        "duration": "PT15M30S",
        "thumbnail": "https://example.com/thumbnail.jpg"
    },
    ...
]

Handling Pagination

If the channel has more than 50 videos, the script automatically handles pagination. It will continue fetching videos until all are retrieved.


Contributing

Feel free to fork this project and submit pull requests. If you have any feature requests or bug fixes, please open an issue or create a pull request.


License

This project is licensed under the MIT License – see the LICENSE file for details.


Acknowledgments

  • The script uses the YouTube Data API v3 to interact with YouTube and fetch video details.
  • Thanks to the requests library for simplifying HTTP requests in Python.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published