17个不稳定版本 (4个重大更改)
0.6.0 | 2022年10月16日 |
---|---|
0.4.0 | 2022年6月28日 |
0.3.8 | 2022年1月2日 |
0.3.7 | 2021年12月25日 |
0.2.4 | 2021年3月14日 |
在 视频 中排名406
每月下载67次
190KB
3.5K SLoC
rustube
一个完整(WIP)且易于使用的YouTube下载器。
注意:0.3.5是一个临时修复,以适应YouTube API的变化(#38)。遗憾的是,此修复对受年龄限制的视频不起作用。我们正在#39中修复此问题。
概览
路线图
- 下载普通视频
- 下载受年龄限制的视频 (由于YouTube API的变化,0.3.5之后不再工作)
- 异步API
- 阻塞API
- 完整视频信息反序列化
- 基于功能的视频信息反序列化
- CLI
- 测试套件
- 基准测试
- Python绑定
- C/C++绑定
用法
rustube
提供了一个极其易于使用的API。如果您只想下载视频,而不关心任何中间步骤和任何视频信息,这就可以了
#[tokio::main]
async fn main() {
let url = "https://www.youtube.com/watch?v=Edx9D2yaOGs&ab_channel=CollegeHumor";
println!("downloaded video to {:?}", rustube::download_best_quality(&url).await.unwrap());
}
当然,rustube
的功能远不止下载视频。它还旨在反序列化YouTube提供的完整视频信息(这仍然是WIP)。因此,查找视频的观看次数就像这样简单
use rustube::{Id, VideoFetcher};
let id = Id::from_raw("https://www.youtube.com/watch?v=Edx9D2yaOGs&ab_channel=CollegeHumor").unwrap();
let descrambler = VideoFetcher::from_id(id.into_owned())
.unwrap()
.fetch()
.await
.unwrap();
let view_count = descrambler.video_details().view_count;
let title = descrambler.video_title();
println!("The video `{}` was viewed {} times.", title, view_count);
有关更多示例,请查看API文档。
CLI
rustube
附带了一个CLI,rustube-cli
,因此您可以在不写任何代码的情况下下载您喜欢的YouTube视频。
要安装它,只需运行
cargo install rustube-cli
在成功安装rustube-cli
后,您就可以使用rustube
命令了
A simple CLI for the rustube YouTube-downloader library.
For documentation and more information about rustube or the rustube-cli checkout
`https://github.com/DzenanJupic/rustube`.
For help with certain subcommands run `rustube <SUBCOMMAND> --help`.
USAGE:
rustube <SUBCOMMAND>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
SUBCOMMANDS:
check Checks if a video can be downloaded and fetches information about it
This command is similar to fetch, in the way that it also fetches information
about a video, but, other then fetch, will also decrypt all stream URLs.
Therefore you can use the returned URLs for downloading the video. This of
course means that the video has to be downloadable.
By default this command will check for any streams that contain a video and an
audio track. To specify other behavior, like checking for a stream with a
particular quality, have a look at the subcommand help.
download Downloads a YouTube video
By default, the Stream with the best quality and both a video, and an audio
track will be downloaded. To specify other download behavior, have a look the
the subcommand help.
fetch Fetches information about a YouTube video
Fetching information does not require the video to actually be downloadable. So
this also works when a video is, i.e., an offline stream. The downside is that
you often don't have access to the stream URLs. Some videos come with pre-
decrypted urls, in which case you can also use these to download the video, but
if the video url is encrypted there's no way for you to download the video using
only the returned information. To get decrypted URLs, have a look at `check`.
For most use cases it's recommended to use `check` instead, since it gives you
both more control and more information.
help Prints this message or the help of the given subcommand(s)
贡献
rustube
仍然处于早期阶段,欢迎您为其做出贡献!目标是利用Rust的速度、类型系统和安全性来制作最快的、最可靠的、功能最齐全的YouTube下载器。
本项目的代码100%开源。您提交给 rustube
的任何贡献,都必须具备 MIT 许可证和 Apache-2.0 许可证,并且以 MIT 或 Apache-2.0 许可证形式发布,不得附加任何额外的条款或条件。
许可证
该项目根据 MIT 许可证或 Apache-2.0 许可证的条款进行许可,您可自行选择。
依赖项
~11–25MB
~346K SLoC