Comments (9)
This could also be implemented as an async stream of information about the download.
from rustube.
@fabi321 sounds reasonable.
The best place for such a hook would probably be in src/stream/mod.rs:261
async fn write_stream_to_file(mut stream: impl tokio_stream::Stream<Item=reqwest::Result<bytes::Bytes>> + Unpin, file: &mut File) -> Result<()> {
while let Some(chunk) = stream.next().await {
file
.write_all(&chunk?)
.await?;
}
Ok(())
}
This function handles the response stream and writes incoming byte-chunks to the target file.
Implementing it similar to pytube
, by having a dedicated struct
for download arguments is probably the best idea. This would allow adding arguments in the future without making a breaking change.
I won't have time to implement this within the next few days, so you're welcome to make PR. Otherwise, I will implement it within the next few weeks.
from rustube.
This could also be implemented as an async stream of information about the download.
That also sounds like an interesting option, especially, since it allows the other side to stop listening when it's done with its task.
tokio
s channel could be used for that. It returns a Receiver that can be turned into a Stream
using ReceiverStream.
The main question here would be if the download should stop when the Receiver
is dropped - kind of like a kill switch - or if such errors should be ignored.
from rustube.
I tried to hide this behind a feature since it needs tokio/sync, but the resulting code either has a lot of duplication or looks ugly. Would you mind if my solution does not require a feature to be activated?
from rustube.
Nvm, I just added yet more fields to the Stream struct.
from rustube.
@fabi321 thank you for the effort.
It's no problem if it's activated without a feature. The feature system is far from perfect/finished and I will eventually redo it from scratch.
from rustube.
I now opened #9 as a first go to. It's using a feature now
from rustube.
It's completely lacking an actual executor, but provides my first thoughts on the topic
from rustube.
Fixed as #9 is merged
from rustube.
Related Issues (20)
- Is download speed throttled by YouTube? HOT 21
- Could not acquire the player response (age-restricted videos) HOT 7
- Tracking issue: YouTube API v1 HOT 5
- VideoDetails.average_rating does no longer exist
- Files downloaded with best_audio or worst_audio are using the wrong extension HOT 2
- Problem downloading best quality? HOT 6
- Consider moving away from nightly-only features HOT 2
- callback cannot use in `tokio::spawn` HOT 1
- Can't download a specific video (id=whoI4EuC0yg) HOT 2
- How do you specify the download path for the video? HOT 4
- blocking_download_to_with_callback is not found HOT 2
- Security issue around CVE-2020-26235 (RUSTSEC-2020-0071)
- add option for stdout HOT 2
- Default example from docs not working correctly. HOT 5
- Can you make url property in stream visible?
- UnexpectedResponse("watch html did not contain a PlayabilityStatus") HOT 4
- add dashManifestUrl && hlsManifestUrl in to stream HOT 1
- Possible API change
- 403: Forbidden when trying to download any video HOT 1
- YouTube returned an unexpected response: `The transform-plan function call contains more than one dot`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rustube.