YoutubeDLSharp
A simple.NET wrapper library for youtube-dl and yt-dlp
模組介紹 作者原文
YoutubeDLSharp
A simple.NET wrapper library for youtube-dl and yt-dlp.
| For yt-dlp | For youtube-dl |
| --- | --- |
| Versions >= v.1.0 | Versions v.0.x
| |
What is it?
YoutubeDLSharp is a wrapper for the popular command-line video downloaders youtube-dl and yt-dlp.
It allows you to use the extensive features of youtube-dl/ yt-dlp in a.NET project.
For more about the features of youtube-dl/ yt-dlp, supported websites and anything else, visit their project pages at and
How do I install it?
First, add the package from NuGet:
PM> Install-Package YoutubeDLSharp
Next, you would want to have the binaries for yt-dlp and FFmpeg available.
If you don't have them set up already, you can either...
-...download them from their respective download pages manually: [[yt-dlp Download]]( [[FFmpeg Download]](
-...use the built-in download methods:
await YoutubeDLSharp.Utils.DownloadYtDlp();
await YoutubeDLSharp.Utils.DownloadFFmpeg();
await YoutubeDLSharp.Utils.DownloadDeno(); // optional, for YouTube downloads
How do I use it?
There are two ways to use YoutubeDLSharp: the class YoutubeDL provides high level methods for downloading and converting videos
while the class YoutubeDLProcess allows directer and flexibler access to the youtube-dl process.
Using the YoutubeDL class
In the simplest case, initializing the downloader and downloading a video can be achieved like this:
var ytdl = new YoutubeDL();
// set the path of yt-dlp and FFmpeg if they're not in PATH or current directory
ytdl.YoutubeDLPath = "path\\to\\yt-dlp.exe";
ytdl.FFmpegPath = "path\\to\\ffmpeg.exe";
// optional: set a different download folder
ytdl.OutputFolder = "some\\directory\\for\\video\\downloads";
// download a video
var res = await ytdl.RunVideoDownload("
// the path of the downloaded file
string path = res.Data;
Instead of only downloading a video, you can also directly extract the audio track...
var res = await ytdl.RunAudioDownload(
"
AudioConversionFormat.Mp3
);... or selectively download videos from a playlist:
var res = await ytdl.RunVideoPlaylistDownload(
"
start: 52, end: 76
);
All of the above methods also allow you to track the download progress or cancel an ongoing download:
// a progress handler with a callback that updates a progress bar
var progress = new Progress(p => progressBar.Value = p.Progress);
// a cancellation token source used for cancelling the download
// use cts.Cancel(); to perform cancellation
var cts = new CancellationTokenSource();
//...
await ytdl.RunVideoDownload("
progress: progress, ct: cts.Token);
As youtube-dl also allows you to extract extensive metadata for videos, you can also fetch these (without downloading the video):
var res = await ytdl.RunVideoDataFetch("
// get some video information
VideoData video = res.Data;
string title = video.Title;
string uploader = video.Uploader;
long? views = video.ViewCount;
// all available download formats
FormatData formats = video.Formats;
//...
This intro does not show all available options. Refer to the method documentations for more.
The project includes a demo WPF desktop app under WpfDemoApp that uses the YoutubeDL class.
Working with options
YoutubeDLSharp uses the OptionSet class to model youtube-dl/ yt-dlp options.
The names of the option properties correspond to the names of youtube-dl, so defining a set of options can look like this:
var options = new OptionSet()
{
NoContinue = true,
RestrictFilenames = true,
Format = "best",
RecodeVideo = VideoRecodeFormat.Mp4,
Exec = "echo {}"
}
Some options of yt-dlp can be set multiple times.
Th
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。