Skip to main content

SegScript

License: MIT Python 3.11+ PyPI version

A command-line tool for managing, enhancing, and interacting with YouTube transcripts.

Overview

SegScript allows you to download, view, and query YouTube video transcripts directly from your terminal. It provides a clean interface for working with transcripts, including the ability to extract specific time ranges and view enhanced transcript content. I've used the langchain-google-genai package in conjunction with Google's Gemini Flash 2.0 model, which has delivered exceptional results in transcript enhancement.

Features

  • Download transcripts from any YouTube video using its ID
  • List all downloaded transcripts stored in your local collection
  • View full transcripts or segments based on time ranges
  • Interactive mode for browsing and working with your transcript collection
  • Rich text formatting for improved readability in the terminal

Installation

pip install segscript

For testing purposes,

# Clone the repository
git clone https://github.com/keshavsharma25/segscript.git
cd segscript

# Install dependencies
pip install -r pyproject.toml

# Install the package (optional)
pip install -e .

Dependencies

  • youtube-transcript-api: Fetch youtube transcripts with ease
  • click: Command-line interface creation kit
  • rich: Terminal formatting and styling
  • python-dotenv: Load GOOGLE_API_KEY from the command line environment
  • pathlib: Object-oriented filesystem paths
  • langchain-google-genai: For synthesizing transcript into a well structured format

Usage

Basic Commands

# List all downloaded transcripts
segscript list

# Download a transcript for a YouTube video
segscript download VIDEO_ID

# Get a transcript (downloads if not already available)
segscript get VIDEO_ID

# Get a transcript for a specific time range
segscript get VIDEO_ID --time-range "10:00;20:00"

# Start interactive mode
segscript prompt

Interactive Mode

Interactive mode provides a user-friendly interface for:

  1. Browsing your transcript collection
  2. Selecting a transcript to work with
  3. Viewing full transcripts or specific segments
  4. Querying transcripts by time range

File Structure

Transcripts are stored in the ~/.segscript/ directory with the following structure:

~/.segscript/
├── .env                    # Environment variables file
├── VIDEO_ID_1/
│   ├── VIDEO_ID_1.json     # Raw transcript data
│   └── metadata.json       # Video metadata
├── VIDEO_ID_2/
│   ├── VIDEO_ID_2.json
│   └── metadata.json
└── ...

Examples

Download a transcript

segscript download dQw4w9WgXcQ

View a transcript for a specific section of a video

segscript get dQw4w9WgXcQ --time-range "1:30;2:45"

Interactive browsing

segscript prompt

Next TODOs

  • Add transcript summary support.
  • Add a prompt to make the each sentence be have its own line for better readibility.
  • In prompt, improve the UX by clearing the screen before running the command (like after download in prompt).
  • Improve the copy of the segscript prompt for better understanding.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

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

Acknowledgments

  • A huge thanks to Youtube Transcript API for making transcript retrieval so easy and accessible.
  • Also kudos to Langchain Google for the langchain-google-genai.
  • Built with Rich for beautiful terminal output.
  • Uses Click for command-line interface.

Note: SegScript is not affiliated with YouTube or Google.

Metadata

Release files for segscript 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for segscript 0.1.7
File Size Uploaded
segscript-0.1.7.tar.gz 15.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for segscript 0.1.7
File Interpreter ABI Platform
segscript-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 30.8 kB

Release files / segscript-0.1.7.tar.gz

Download URL segscript-0.1.7.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a36d35c225f53e3dfc6e4eb518178cf170cc40c8838e33d2f73514ad53634195
BLAKE2b-256 checksum
How to use checksums
48d45c435c0a72fd53d50abc6f06648facc2a6cc5caac0bb27c7b3e20284755f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / segscript-0.1.7-py3-none-any.whl

Download URL segscript-0.1.7-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
459cf89671a54c0b6dd9e059b7f8b4b6e0e5c7ff1a56d8779dd8cbb6e23a03ec
BLAKE2b-256 checksum
How to use checksums
b1ca1401d35458354d69768a5bce9f4f2967278ba3b6d0c87719f7371ca43887
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

1 release file

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page