mirror of
https://github.com/narrrl/ytd-rs.git
synced 2026-11-04 00:47:02 +01:00
feat: add streaming output for progress monitoring and update README
This commit is contained in:
1 parent
46f51fa98d
commit
f5d2083248
3 files changed
+89
-7
No files matched your search
@@ -65,5 +65,27 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
```
|
||||
|
||||
### Streaming Output (Progress Bars)
|
||||
If you want to track the progress of a long-running download, you can stream the standard output line-by-line:
|
||||
```rust
|
||||
use ytd_rs::YtDlp;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut process = YtDlp::new("https://www.youtube.com/watch?v=uTO0KnDsVH0")
|
||||
.download_process()
|
||||
.await?;
|
||||
|
||||
while let Some(line) = process.next_line().await? {
|
||||
// e.g. "[download] 10.0% of 50.00MiB at 1.00MiB/s ETA 00:50"
|
||||
println!("yt-dlp output: {}", line);
|
||||
}
|
||||
|
||||
process.wait().await?;
|
||||
println!("Download finished successfully!");
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
MIT
|
||||
Reference in new issue
Block a user