Skip to content

Commit 5718113

Browse files
committed
Update readme
1 parent 89b2be5 commit 5718113

File tree

2 files changed

+51
-22
lines changed

2 files changed

+51
-22
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 6.0
1+
// swift-tools-version: 5.6
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

README.md

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# YoutubeTranscript
22

3-
A Swift library for fetching YouTube video transcripts (captions) programmatically. Supports both standard YouTube videos and Shorts, with robust error handling and async/await support.
3+
I tried to find a library that fetches YouTube video transcripts for Swift but couldn’t find one, so I made one myself.
4+
5+
This package uses an unofficial YouTube API, so it may break over time if no updates are made.
6+
The library uses an HTML scraper and the Innertube API to fetch transcripts.
7+
8+
Heavily inspired by [youtube-transcript](https://github.com/Kakulukian/youtube-transcript)
49

510
## Features
611

@@ -10,25 +15,6 @@ A Swift library for fetching YouTube video transcripts (captions) programmatical
1015
- Async/await API for modern Swift concurrency
1116
- Comprehensive unit tests using Swift Testing
1217

13-
## Installation
14-
15-
Add this package to your `Package.swift` dependencies:
16-
17-
```swift
18-
.package(url: "https://github.com/yourusername/swift-youtube-transcript.git", from: "1.0.0")
19-
```
20-
21-
And add `YoutubeTranscript` as a dependency for your target:
22-
23-
```swift
24-
.target(
25-
name: "YourTarget",
26-
dependencies: [
27-
.product(name: "YoutubeTranscript", package: "swift-youtube-transcript")
28-
]
29-
)
30-
```
31-
3218
## Usage
3319

3420
```swift
@@ -53,7 +39,15 @@ let config = TranscriptConfig(lang: "en")
5339
let transcript = try await YoutubeTranscript.fetchTranscript(for: "YOUR_VIDEO_ID", config: config)
5440
```
5541

56-
## Error Handling
42+
### Supported URL Formats
43+
44+
- Standard videos: `https://www.youtube.com/watch?v=VIDEO_ID`
45+
- Short URLs: `https://youtu.be/VIDEO_ID`
46+
- YouTube Shorts: `https://www.youtube.com/shorts/VIDEO_ID`
47+
- Embedded videos: `https://www.youtube.com/embed/VIDEO_ID`
48+
- Direct video IDs: `VIDEO_ID`
49+
50+
### Error Handling
5751

5852
The library throws `YoutubeTranscriptError` for all error cases:
5953

@@ -67,6 +61,41 @@ The library throws `YoutubeTranscriptError` for all error cases:
6761
- `.networkError`: Network error occurred
6862
- `.parsingError`: Failed to parse YouTube response
6963

64+
## Minimum requirements
65+
66+
- macOS 12.0+
67+
- iOS 15.0+
68+
- tvOS 15.0+
69+
- watchOS 8.0+
70+
71+
## Installation
72+
73+
### Adding YoutubeTranscript to a Swift package
74+
75+
Add this package to your `Package.swift` dependencies:
76+
77+
```swift
78+
.package(url: "https://github.com/spaceman1412/swift-youtube-transcript.git", from: "1.0.0")
79+
```
80+
81+
And add `YoutubeTranscript` as a dependency for your target:
82+
83+
```swift
84+
.target(
85+
name: "YourTarget",
86+
dependencies: [
87+
.product(name: "YoutubeTranscript", package: "swift-youtube-transcript")
88+
]
89+
)
90+
```
91+
92+
### Adding YoutubeTranscript to an Xcode project
93+
94+
1. From the **File** menu, select **Add Packages…**
95+
1. Enter `https://github.com/spaceman1412/swift-youtube-transcript` into the
96+
_Search or Enter Package URL_ search field
97+
1. Link **YoutubeTranscript** to your application target
98+
7099
## Testing
71100

72101
This project uses [Swift Testing](https://github.com/apple/swift-testing) for its test suite.

0 commit comments

Comments
 (0)