feat(phase-3): add yt-dlp downloader implementation#5
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a concrete Phase 3 “Download Engine” implementation by introducing a yt-dlp–backed downloader and accompanying unit/integration tests, while extending downloader types to include metadata.
Changes:
- Added
YTDLPDownloaderthat shells out toyt-dlp, supports context cancellation, and maps yt-dlp JSON into internal result/metadata types. - Added unit tests using a fake command runner plus integration tests that run when
yt-dlpis available. - Updated Phase 3 roadmap status and added a
Metadatatype to the downloader package.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/downloader/ytdlp.go | New yt-dlp based downloader implementation (command runner abstraction, download + metadata fetch, result parsing). |
| internal/downloader/ytdlp_test.go | Unit tests for download flow, parsing, error paths, and cancellation using a fake runner. |
| internal/downloader/ytdlp_integration_test.go | Integration tests that exercise yt-dlp against a real URL when available. |
| internal/downloader/types.go | Adds Metadata type alongside existing Item/Result/Downloader. |
| docs/ROADMAP.md | Marks yt-dlp adapter as completed and updates Phase 3 checklist. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+116
to
+118
| if expectedID != "" && info.ID != expectedID { | ||
| continue | ||
| } |
Comment on lines
+91
to
+97
| func (d *YTDLPDownloader) parseResult(expectedID string) (Result, error) { | ||
| // TODO: This method scans the output directory which is not safe for concurrent downloads. | ||
| // Consider using a unique temp directory per download or returning the file path directly from yt-dlp. | ||
| entries, err := os.ReadDir(d.outputDir) | ||
| if err != nil { | ||
| return Result{}, err | ||
| } |
Comment on lines
+168
to
+174
| output, err := d.cmdRunner.Run(ctx, "yt-dlp", args...) | ||
| if err != nil { | ||
| if ctx.Err() == context.Canceled || ctx.Err() == context.DeadlineExceeded { | ||
| return nil, fmt.Errorf("metadata fetch cancelled: %w", ctx.Err()) | ||
| } | ||
| return nil, fmt.Errorf("yt-dlp metadata failed: %w", err) | ||
| } |
| @@ -0,0 +1,118 @@ | |||
| package downloader | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements the first feature of Phase 3 (Download Engine) by adding a production-ready yt-dlp based downloader implementation.
The existing Downloader abstraction is now backed by a real downloader implementation while keeping the interface unchanged.
Changes
Downloader Implementation
YTDLPDownloaderTesting
Added isolated unit tests covering:
Added separate integration tests for environments with yt-dlp installed.
Documentation
Updated
docs/ROADMAP.md:Out of Scope
This PR does not include:
These will be handled in following Phase 3 features.
Verification
Passed:
go test ./... golangci-lint run ./... go build ./...