A Swift package providing both a command line tool and library for interacting with YouTube content:
- Download transcripts from any YouTube video
- Get video metadata and information
- Parse YouTube activity history from Google Takeout
swift build -c release
cp .build/release/ytt /usr/local/bin/
Download a transcript from a YouTube video:
ytt transcribe https://www.youtube.com/watch?v=VIDEO_ID
# or just the ID
ytt transcribe VIDEO_ID
Get detailed information about a video:
ytt info https://www.youtube.com/watch?v=VIDEO_ID
# Include transcript in the output
ytt info --include-transcript VIDEO_ID
Parse your YouTube activity history from Google Takeout:
ytt activity "Takeout/My Activity/YouTube/MyActivity.html"
# Supports path expansion
ytt activity "~/Downloads/Takeout/My Activity/YouTube/MyActivity.html"
ytt activity "../Takeout/My Activity/YouTube/MyActivity.html"
Supports various activity types:
- Watched videos
- Viewed posts/stories
- Liked content
- Subscribed to channels
- Answered polls
- Voted on content
- Saved videos/playlists
- Search history
A Swift library that can be integrated into any project to access YouTube content.
Add to your Package.swift:
dependencies: [
.package(url: "PATH_TO_REPO", branch: "main")
]
// Get transcript by URL
let transcript = try await YouTubeTranscriptKit.getTranscript(url: videoURL)
// Get transcript by ID
let transcript = try await YouTubeTranscriptKit.getTranscript(videoID: "VIDEO_ID")
// Get video info with optional transcript
let info = try await YouTubeTranscriptKit.getVideoInfo(videoID: "VIDEO_ID", includeTranscript: true)
Parse your YouTube activity history from Google Takeout:
let activities = try await YouTubeTranscriptKit.getActivity(fileURL: takeoutFile)
VideoInfo
: Complete video metadata including title, channel, views, etc.TranscriptMoment
: Individual transcript entries with timingActivity
: YouTube activity entries including:- Various action types (watched, liked, subscribed, etc.)
- Links to videos, channels, playlists, etc.
- Timestamps and additional metadata