Skip to content

Add YoutubeExplode.Cli command-line wrapper - #979

Open
Tyrrrz with Copilot wants to merge 17 commits into
primefrom
feature/cli
Open

Tyrrrz with Copilot wants to merge 17 commits into
primefrom
feature/cli

Conversation

Copilot AI commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Implements #977.

  • New YoutubeExplode.Cli project (CliFx + Spectre.Console, packaged as the yte .NET tool) with video, video stream, video cc, playlist, channel and search commands.
  • Data is written as JSON to stdout; commands that take objects read JSON from stdin; progress goes to stderr.
  • YoutubeExplode.Converter: FFmpeg path may now be a file or a directory; a clear error is thrown when FFmpeg can't be started, and the CLI prints installation instructions.
  • Removed YoutubeExplode.Demo.Cli; added a local readme and linked it from the main readme.

Note: the commands were not exercised against live YouTube (no network access in the dev environment); build, pack, --help and error paths were verified.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@Tyrrrz Tyrrrz left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot left some review comments


Also, what do you think about the CLI design? How do you like the command structure and the input/output handling?

Comment thread YoutubeExplode.Cli/Utils/Json.cs Resolved

Copilot AI commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot left some review comments

---...

I like the API-oriented hierarchy: videos streams and videos closed-captions keep related operations together, while playlists, channels, and search are easy to discover. The data contract is the strongest part to me—JSON results on stdout, diagnostics/progress on stderr, JSON input from stdin for commands that operate on returned objects, and raw bytes on stdout for stream retrieval make the commands composable in shell pipelines. The main tradeoff is some verbosity and naming inconsistency (get, get-manifest, get-results), but I think mirroring the library’s concepts is a reasonable priority for this low-level wrapper.

Copilot AI requested a review from Tyrrrz November 16, 2026 21:47
@Tyrrrz

Tyrrrz commented Nov 16, 2026

Copy link
Copy Markdown
Owner

@copilot please address the other review comments

…Kit, awaitable batches

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

@Tyrrrz Tyrrrz left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot some review comments below

…d group stub commands

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Copilot AI requested a review from Tyrrrz November 17, 2026 11:07

@Tyrrrz Tyrrrz left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot added some more comments as part of this review.

Additionally, what do you think about renaming the commands to make them more natural, even though it breaks 1:1 naming parity with the library?

Examples:

  • videos get -> video get
  • videos streams get -> video stream get
  • videos streams get-manifest -> video stream manifest
  • playlists get-videos -> playlist videos
  • search get-videos -> search videos

Comment thread YoutubeExplode.Converter/FFmpeg.cs Resolved
Comment thread YoutubeExplode.Converter/FFmpeg.cs Resolved
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot added some more comments as part of this review.

Additionally, what do you think about renaming the commands to make them more natural, even though it breaks 1:1 naming parity with the libra...

I'd go for it: singular nouns read naturally (yte video get), and the CLI isn't bound to the library's method names. A mapping for the rest that I'd propose:

  • videos get → video get
  • videos download → video download
  • videos streams get → video stream get
  • videos streams get-manifest → video stream manifest
  • videos streams download → video stream download
  • videos closed-captions get → video caption get
  • videos closed-captions get-manifest → video caption manifest
  • videos closed-captions download → video caption download
  • playlists get → playlist get
  • playlists get-videos → playlist videos
  • channels get → channel get
  • search get-results → search all
  • search get-videos/get-playlists/get-channels → search videos/playlists/channels

Two questions: should closed-captions become caption, and is search all right for mixed results? I haven't changed anything yet; say the word and I'll apply it, including the stubs and readme.

Copilot AI requested a review from Tyrrrz November 17, 2026 12:59
@Tyrrrz

Tyrrrz commented Nov 17, 2026

Copy link
Copy Markdown
Owner

@copilot

Two questions: should closed-captions become caption, and is search all right for mixed results? I haven't changed anything yet; say the word and I'll apply it, including the stubs and readme.

search all sounds good for mixed results. Actually, it might be more idiomatic for CLI to have a single search command with a --filter option to specify none/videos/playlists/channels. Do you think this is an acceptable divergence from the source API?

closed-captions should probably just become cc since this is what they're commonly referred to in the context of YouTube.

…h into one command with --filter

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Two questions: should closed-captions become caption, and is search all right for mixed results? I haven't changed anything yet; say the word and I'll apply it, including the stub...

Yes, I think the --filter divergence is acceptable: it's the more common CLI shape, and the four library methods all return the same kind of list. Done in bdcabe3. The commands are now video get|download, video stream get|manifest|download, video cc get|manifest|download, playlist get|videos, channel get, and search <query> [--filter None|Videos|Playlists|Channels]. The four search get-* commands and the search stub are gone, and the readme is updated. I checked the build and --help output; search against YouTube wasn't run, since the sandbox has no network access.

Copilot AI commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

  • Trimming: the csproj sets PublishTrimmed and PublishSingleFile only when SelfContained is true, so the NuGet tool stays framework-dependent. A trimmed linux-x64 build runs: ...

Done (ab99b8e).

  • Trimming flags: PublishTrimmed and PublishSingleFile are now passed from the workflow, and the conditional group is gone from the csproj. Passing them globally broke the build (NETSDK1124), because the multi-targeted libraries include netstandard2.0. To fix that, the CLI's project references use GlobalPropertiesToRemove="PublishTrimmed", and the workflow runs dotnet restore as a separate step before dotnet publish --no-restore. I checked this locally with a linux-x64 publish.
  • IL2117: I could not reproduce it. The same publish now produces no warnings, so I removed the suppression. The earlier warning probably came from the setup I had then. I didn't dig into which assembly raised it.
  • Not run: the workflow itself hasn't run on CI.

@Tyrrrz
Tyrrrz marked this pull request as ready for review November 17, 2026 18:03
Copilot AI balanced review requested due to automatic review settings November 17, 2026 18:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical JSON deserialization defects break CLI media input, while mismatched restore and publish settings leave clean CI runners without required linker/runtime assets.

2 open issues
What changed in this PR

Adds YoutubeExplode.Cli as the yte .NET tool, exposing the library through terminal commands for scripting, downloading, and debugging, as requested in #977.

Changes:

  • Adds video, stream, caption, playlist, channel, and search commands with JSON input/output and progress on stderr.
  • Supports FFmpeg executable or directory paths and provides CLI installation guidance.
  • Replaces the CLI demo, documents usage, and adds platform-specific binary packaging and release uploads.
File Description
YoutubeExplode.slnx Replaces the demo project with the CLI.
YoutubeExplode.Demo.Cli/​YoutubeExplode.Demo.Cli.csproj Removes the demo project definition.
YoutubeExplode.Demo.Cli/​Utils/​ConsoleProgress.cs Removes the demo progress renderer.
YoutubeExplode.Demo.Cli/​Program.cs Removes the interactive download demo.
YoutubeExplode.Converter/​FFmpeg.cs Resolves directory paths to FFmpeg executables.
YoutubeExplode.Cli/​YoutubeExplode.Cli.csproj Defines the yte tool and dependencies.
YoutubeExplode.Cli/​Utils/​VideoIdConverter.cs Adds video ID JSON conversion.
YoutubeExplode.Cli/​Utils/​UserNameConverter.cs Adds username JSON conversion.
YoutubeExplode.Cli/​Utils/​StreamInfoDto.cs Maps input metadata to concrete stream types.
YoutubeExplode.Cli/​Utils/​StreamInfoConverter.cs Enables concrete stream metadata serialization.
YoutubeExplode.Cli/​Utils/​SearchResultConverter.cs Enables concrete search-result serialization.
YoutubeExplode.Cli/​Utils/​RuntimeTypeConverter.cs Serializes interfaces using runtime types.
YoutubeExplode.Cli/​Utils/​PlaylistIdConverter.cs Adds playlist ID JSON conversion.
YoutubeExplode.Cli/​Utils/​JsonSerializerContext.cs Registers JSON models and converters.
YoutubeExplode.Cli/​Utils/​IdentifierConverter.cs Provides shared string-based identifier conversion.
YoutubeExplode.Cli/​Utils/​Extensions/​ConsoleExtensions.cs Adds Spectre.Console progress on stderr.
YoutubeExplode.Cli/​Utils/​ChannelSlugConverter.cs Adds channel slug JSON conversion.
YoutubeExplode.Cli/​Utils/​ChannelIdConverter.cs Adds channel ID JSON conversion.
YoutubeExplode.Cli/​Utils/​ChannelHandleConverter.cs Adds channel handle JSON conversion.
YoutubeExplode.Cli/​Readme.md Documents installation, commands, and pipelines.
YoutubeExplode.Cli/​Program.cs Builds and runs the CliFx application.
YoutubeExplode.Cli/​Commands/​Videos/​VideoGetCommand.cs Outputs video metadata as JSON.
YoutubeExplode.Cli/​Commands/​Videos/​VideoDownloadCommand.cs Downloads converted videos with FFmpeg guidance.
YoutubeExplode.Cli/​Commands/​Videos/​VideoCommand.cs Defines the video command group.
YoutubeExplode.Cli/​Commands/​Videos/​Streams/​StreamManifestCommand.cs Outputs available stream metadata.
YoutubeExplode.Cli/​Commands/​Videos/​Streams/​StreamGetCommand.cs Writes raw stream data to stdout.
YoutubeExplode.Cli/​Commands/​Videos/​Streams/​StreamDownloadCommand.cs Downloads selected streams to files.
YoutubeExplode.Cli/​Commands/​Videos/​Streams/​StreamCommand.cs Defines the stream command group.
YoutubeExplode.Cli/​Commands/​Videos/​ClosedCaptions/​ClosedCaptionManifestCommand.cs Outputs available caption tracks.
YoutubeExplode.Cli/​Commands/​Videos/​ClosedCaptions/​ClosedCaptionGetCommand.cs Outputs caption contents as JSON.
YoutubeExplode.Cli/​Commands/​Videos/​ClosedCaptions/​ClosedCaptionDownloadCommand.cs Downloads caption tracks as SRT files.
YoutubeExplode.Cli/​Commands/​Videos/​ClosedCaptions/​ClosedCaptionCommand.cs Defines the caption command group.
YoutubeExplode.Cli/​Commands/​Search/​SearchCommand.cs Searches with optional result-type filtering.
YoutubeExplode.Cli/​Commands/​Playlists/​PlaylistVideosCommand.cs Outputs playlist videos as a JSON array.
YoutubeExplode.Cli/​Commands/​Playlists/​PlaylistGetCommand.cs Outputs playlist metadata.
YoutubeExplode.Cli/​Commands/​Playlists/​PlaylistCommand.cs Defines the playlist command group.
YoutubeExplode.Cli/​Commands/​Channels/​ChannelKind.cs Defines supported channel identifier kinds.
YoutubeExplode.Cli/​Commands/​Channels/​ChannelGetCommand.cs Retrieves channels by identifier kind.
YoutubeExplode.Cli/​Commands/​Channels/​ChannelCommand.cs Defines the channel command group.
YoutubeExplode.Cli/​Commands/​Base/​StreamCommandBase.cs Reads stream metadata from stdin.
YoutubeExplode.Cli/​Commands/​Base/​CommandBase.cs Shares JSON handling, cancellation, and error translation.
YoutubeExplode.Cli/​Commands/​Base/​ClosedCaptionTrackCommandBase.cs Reads caption track metadata from stdin.
Readme.md Links to the new CLI project.
Directory.Packages.props Adds CliFx and Spectre.Console versions.
.github/​workflows/​main.yml Publishes platform binaries and uploads release archives.

Review effort: Balanced

Comment thread .github/workflows/main.yml Resolved
Tyrrrz and others added 2 commits November 17, 2026 18:16
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Copilot AI requested a review from Tyrrrz December 1, 2026 16:04
@Tyrrrz

Tyrrrz commented Dec 1, 2026

Copy link
Copy Markdown
Owner

@copilot please fix merge conflicts, prioritizing upstream where it's newer

# Conflicts:
#	Directory.Packages.props
#	YoutubeExplode.Demo.Cli/YoutubeExplode.Demo.Cli.csproj

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@Tyrrrz

Tyrrrz commented Dec 1, 2026

Copy link
Copy Markdown
Owner

@copilot build errors on CI

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please fix merge conflicts, prioritizing upstream where it's newer

Merged prime in 78029aa, resolving conflicts in favor of the newer upstream dependency versions and preserving the CLI replacement for the old demo CLI. The merged solution builds successfully and all 11 targeted channel-ID tests pass.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot build errors on CI

Fixed in 2b9dc51: the CLI workflow restores once with the RID and self-contained setting, then publishes with --no-restore. I reproduced and eliminated the NETSDK1124 failure; trimmed linux-x64 publish and the Release solution build both pass locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants