{"id":26415714,"url":"https://github.com/bluegrams/youtubedlsharp","last_synced_at":"2025-04-09T05:08:33.575Z","repository":{"id":36949573,"uuid":"233416949","full_name":"Bluegrams/YoutubeDLSharp","owner":"Bluegrams","description":"A simple .NET wrapper library for youtube-dl and yt-dlp","archived":false,"fork":false,"pushed_at":"2024-07-28T10:30:27.000Z","size":136,"stargazers_count":186,"open_issues_count":15,"forks_count":31,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-30T09:19:44.012Z","etag":null,"topics":["csharp","dotnet","hacktoberfest","video","youtube","youtube-dl","youtube-dl-wrapper","yt-dlp","yt-dlp-wrapper"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bluegrams.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-12T15:50:20.000Z","updated_at":"2024-12-28T20:11:06.000Z","dependencies_parsed_at":"2024-04-28T13:41:36.332Z","dependency_job_id":"9e3b62a2-d2eb-44cb-a15c-34cf0840dc0e","html_url":"https://github.com/Bluegrams/YoutubeDLSharp","commit_stats":{"total_commits":37,"total_committers":6,"mean_commits":6.166666666666667,"dds":"0.21621621621621623","last_synced_commit":"aa2233b957b09776e1b33d146d2655408f78706f"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bluegrams%2FYoutubeDLSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bluegrams%2FYoutubeDLSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bluegrams%2FYoutubeDLSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bluegrams%2FYoutubeDLSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bluegrams","download_url":"https://codeload.github.com/Bluegrams/YoutubeDLSharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247980837,"owners_count":21027808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","hacktoberfest","video","youtube","youtube-dl","youtube-dl-wrapper","yt-dlp","yt-dlp-wrapper"],"created_at":"2025-03-18T00:54:35.663Z","updated_at":"2025-04-09T05:08:33.553Z","avatar_url":"https://github.com/Bluegrams.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YoutubeDLSharp\n\n[![Build status](https://bluegrams.visualstudio.com/vividl/_apis/build/status/youtubedlsharp-ci)](https://bluegrams.visualstudio.com/vividl/_build/latest?definitionId=3)\n\nA simple .NET wrapper library for [youtube-dl](https://github.com/ytdl-org/youtube-dl) and [yt-dlp](https://github.com/yt-dlp/yt-dlp).\n\n| For **yt-dlp** | For **youtube-dl** |\n| --- | --- |\n| **Versions \u003e= v.1.0**  | [Versions v.0.x](https://github.com/Bluegrams/YoutubeDLSharp/tree/v.0.x)\n| [![Nuget](https://img.shields.io/nuget/vpre/YoutubeDLSharp?color=blue)](https://www.nuget.org/packages/YoutubeDLSharp) | [![NuGet](https://img.shields.io/badge/nuget-v.0.4.3-blue)](https://www.nuget.org/packages/YoutubeDLSharp/0.4.3)\n\n## What is it?\n\nYoutubeDLSharp is a wrapper for the popular command-line video downloaders youtube-dl and yt-dlp.\nIt allows you to use the extensive features of youtube-dl/ yt-dlp in a .NET project.\nFor more about the features of youtube-dl/ yt-dlp, supported websites and anything else, visit their project pages at http://ytdl-org.github.io/youtube-dl/ and https://github.com/yt-dlp/yt-dlp.\n\n## How do I install it?\n\nFirst, add the package from NuGet:\n\n```\nPM\u003e Install-Package YoutubeDLSharp\n```\n\nNext, you would want to have the binaries for yt-dlp and FFmpeg available.\nIf you don't have them set up already, you can either...\n\n- ...download them from their respective download pages manually: [[yt-dlp Download]](https://github.com/yt-dlp/yt-dlp/releases/latest) [[FFmpeg Download]](https://ffmpeg.org/download.html)\n- ...use the built-in download methods:\n    ```csharp\n    await YoutubeDLSharp.Utils.DownloadYtDlp();\n    await YoutubeDLSharp.Utils.DownloadFFmpeg();\n    ```\n\n## How do I use it?\n\nThere are two ways to use YoutubeDLSharp: the class `YoutubeDL` provides high level methods for downloading and converting videos\nwhile the class `YoutubeDLProcess` allows directer and flexibler access to the youtube-dl process.\n\n### Using the `YoutubeDL` class\n\nIn the simplest case, initializing the downloader and downloading a video can be achieved like this:\n\n```csharp\nvar ytdl = new YoutubeDL();\n// set the path of yt-dlp and FFmpeg if they're not in PATH or current directory\nytdl.YoutubeDLPath = \"path\\\\to\\\\yt-dlp.exe\";\nytdl.FFmpegPath = \"path\\\\to\\\\ffmpeg.exe\";\n// optional: set a different download folder\nytdl.OutputFolder = \"some\\\\directory\\\\for\\\\video\\\\downloads\";\n// download a video\nvar res = await ytdl.RunVideoDownload(\"https://www.youtube.com/watch?v=bq9ghmgqoyc\");\n// the path of the downloaded file\nstring path = res.Data;\n```\n\nInstead of only downloading a video, you can also directly extract the audio track ...\n\n```csharp\nvar res = await ytdl.RunAudioDownload(\n    \"https://www.youtube.com/watch?v=QUQsqBqxoR4\",\n    AudioConversionFormat.Mp3\n);\n```\n\n... or selectively download videos from a playlist:\n\n```csharp\nvar res = await ytdl.RunVideoPlaylistDownload(\n    \"https://www.youtube.com/playlist?list=PLPfak9ofGSn9sWgKrHrXrxQXXxwhCblaT\",\n    start: 52, end: 76\n);\n```\n\nAll of the above methods also allow you to track the download progress or cancel an ongoing download:\n\n```csharp\n// a progress handler with a callback that updates a progress bar\nvar progress = new Progress\u003cDownloadProgress\u003e(p =\u003e progressBar.Value = p.Progress);\n// a cancellation token source used for cancelling the download\n// use `cts.Cancel();` to perform cancellation\nvar cts = new CancellationTokenSource();\n// ...\nawait ytdl.RunVideoDownload(\"https://www.youtube.com/watch?v=_QdPW8JrYzQ\",\n                            progress: progress, ct: cts.Token);\n```\n\nAs youtube-dl also allows you to extract extensive metadata for videos, you can also fetch these (without downloading the video):\n\n```csharp\nvar res = await ytdl.RunVideoDataFetch(\"https://www.youtube.com/watch?v=_QdPW8JrYzQ\");\n// get some video information\nVideoData video = res.Data;\nstring title = video.Title;\nstring uploader = video.Uploader;\nlong? views = video.ViewCount;\n// all available download formats\nFormatData[] formats = video.Formats;\n// ...\n```\n\nThis intro does not show all available options. Refer to the method documentations for more.\n\nThe project includes a demo WPF desktop app under [WpfDemoApp](WpfDemoApp/MainWindow.xaml.cs) that uses the `YoutubeDL` class.\n\n### Working with options\n\nYoutubeDLSharp uses the `OptionSet` class to model youtube-dl/ yt-dlp options.\nThe names of the option properties correspond to the names of youtube-dl, so defining a set of options can look like this:\n\n```csharp\nvar options = new OptionSet()\n{\n    NoContinue = true,\n    RestrictFilenames = true,\n    Format = \"best\",\n    RecodeVideo = VideoRecodeFormat.Mp4,\n    Exec = \"echo {}\"\n}\n```\n\nSome options of yt-dlp can be set multiple times.\nThis is reflected in `YoutubeDLSharp` by passing an array of values to the corresponding option properties:\n\n```csharp\nvar options = new OptionSet()\n{\n    PostprocessorArgs = new[]\n    {\n        \"ffmpeg:-vcodec h264_nvenc\",\n        \"ffmpeg_i1:-hwaccel cuda -hwaccel_output_format cuda\"\n    }\n};\n```\n\n`OptionSet` instances can be passed to many `YoutubeDL` methods to override the default behaviour:\n\n```csharp\nvar options = new OptionSet()\n{\n    NoContinue = true,\n    RestrictFilenames = true\n}\nvar ytdl = new YoutubeDL();\nvar res = await ytdl.RunVideoDownload(\n    \"https://www.youtube.com/watch?v=bq9ghmgqoyc\",\n    overrideOptions: options\n);\n```\n\nAlternatively, `RunWithOptions()` can be used to directly run youtube-dl/ yt-dlp with a given `OptionSet`:\n\n```csharp\nvar ytdl = new YoutubeDL();\nvar res = await ytdl.WithOptions(\"\u003cYOUR_URL\u003e\", options);\n```\n\nFor documentation of all options supported by yt-dlp and their effects, visit https://github.com/yt-dlp/yt-dlp#usage-and-options.\n\nAdditionally, YoutubeDLSharp allows you to pass **custom options** to the downloader program.\nThis is especially useful when a forked/ modified version of youtube-dl is used.\nCustom can be specified like this:\n\n```csharp\n// add\noptions.AddCustomOption\u003cstring\u003e(\"--my-custom-option\", \"value\");\n// set\noptions.SetCustomOption\u003cstring\u003e(\"--my-custom-option\", \"new value\");\n```\n\n### `YoutubeDLProcess`\n\nTo start a youtube-dl/ yt-dlp process directly with the defined options, you can also use the low-level `YoutubeDLProcess` class, giving you more control over the process:\n\n```csharp\nvar ytdlProc = new YoutubeDLProcess();\n// capture the standard output and error output\nytdlProc.OutputReceived += (o, e) =\u003e Console.WriteLine(e.Data);\nytdlProc.ErrorReceived += (o, e) =\u003e Console.WriteLine(\"ERROR: \" + e.Data);\n// start running\nstring[] urls = new[] { \"https://github.com/ytdl-org/youtube-dl#options\" };\nawait ytdlProc.RunAsync(urls, options);\n```\n\n### Loading/ Saving configuration\n\nYou can persist a youtube-dl/ yt-dlp configuration to a file and reload it:\n\n```csharp\n// Save to file\nvar saveOptions = new OptionSet();\nsaveOptions.WriteConfigFile(\"path\\\\to\\\\file\");\n\n// Reload configuration\nOptionSet loadOptions = OptionSet.LoadConfigFile(\"path\\\\to\\\\file\");\n```\n\nThe file format is compatible with the format used by youtube-dl/ yt-dlp itself.\nFor more, read https://github.com/yt-dlp/yt-dlp#configuration.\n\n## Issues \u0026 Contributing\n\nYou are very welcome to contribute by reporting issues, fixing bugs or resolving inconsistencies to youtube-dl/ yt-dlp.\nIf you want to contribute a new feature to the library, please open an issue with your suggestion before starting to implement it.\n\nAll issues related to downloading specific videos, support for websites or downloading/ conversion features should better be reported to https://github.com/yt-dlp/yt-dlp/issues.\n\n## Version History\n\nSee [Changelog](https://github.com/Bluegrams/YoutubeDLSharp/blob/master/Changelog.md).\n\n## License\n\nThis project is licensed under [BSD-3-Clause license](https://github.com/Bluegrams/YoutubeDLSharp/blob/master/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluegrams%2Fyoutubedlsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluegrams%2Fyoutubedlsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluegrams%2Fyoutubedlsharp/lists"}