Git Product home page Git Product logo

yt_downloader's Introduction

YouTube Segment Downloader

This script, main.py, automates the process of downloading specific segments from YouTube videos as MP3 files, using yt-dlp. It reads a CSV file containing YouTube video IDs and the corresponding start and end times for each segment you wish to download. This is particularly useful for creating samples, clips, or extracting specific parts of audio from longer videos.

Features

  • Download specific segments of YouTube videos as MP3.
  • Parallel downloads to improve efficiency.
  • Customizable download directory and parallel download count.

Prerequisites

Before you run this script, you need to have the following installed on your system:

  • Python 3.9.10 or higher
  • yt-dlp Python package
  • pandas Python package

You can install the required Python packages using pip:

pip install -r requirements.txt

Usage

Prepare Your CSV File: Ensure you have a CSV file with the columns ytid, start_s, and end_s, representing the YouTube video ID, the start time of the segment in seconds, and the end time of the segment in seconds, respectively.

Run the Script: Navigate to the directory containing main.py and run the following command:

python main.py --data path/to/yourfile.csv --directory path/to/download/directory --delimiter "," --max-workers N

Replace path/to/yourfile.csv with the path to your CSV file, path/to/download/directory with the path where you want the MP3 files to be saved, "," with the delimiter used in your CSV file (if different from a comma), and N with the number of parallel downloads you wish to run.

Arguments

  • data: Path to the CSV file containing the download information. Default is data.csv.
  • directory: Path to the directory where the MP3 files will be saved. Default is music.
  • delimiter: Delimiter used in the CSV file. Default is ,.
  • max-workers: Number of parallel downloads. Default is 5.

Example CSV Format

Your CSV file should follow this format:

ytid,start_s,end_s
dQw4w9WgXcQ,10,20

This example would download the audio from 10 to 20 seconds of the video with ID dQw4w9WgXcQ.

Disclaimer

This script is provided for educational purposes only. Be mindful of YouTube's Terms of Service before downloading content.

yt_downloader's People

Contributors

tino3141 avatar tino3141-littlehelp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.