|
|
@ -45,10 +45,12 @@ impl TsPart { |
|
|
|
|
|
|
|
|
async fn download(&mut self, client: &ClientActorHandle) -> &Self {
|
|
|
async fn download(&mut self, client: &ClientActorHandle) -> &Self {
|
|
|
let state = client.download(self.filename.clone(), &self.uri).await;
|
|
|
let state = client.download(self.filename.clone(), &self.uri).await;
|
|
|
|
|
|
debug!("TsPart::download got: {:?}", state);
|
|
|
match state {
|
|
|
match state {
|
|
|
Ok(DownloadState::Done { content_type, .. }) => {
|
|
|
Ok(DownloadState::Done { content_type, .. }) => {
|
|
|
self.state = TsState::Ready;
|
|
|
self.state = TsState::Ready;
|
|
|
self.content_type = content_type;
|
|
|
self.content_type = content_type;
|
|
|
|
|
|
debug!("DONE TsPart: {:?}", self);
|
|
|
},
|
|
|
},
|
|
|
_ => self.state = TsState::Failed,
|
|
|
_ => self.state = TsState::Failed,
|
|
|
};
|
|
|
};
|
|
|
@ -98,14 +100,14 @@ impl M3u8Download { |
|
|
pub(super) async fn download(&mut self, client: &ClientActorHandle) {
|
|
|
pub(super) async fn download(&mut self, client: &ClientActorHandle) {
|
|
|
loop {
|
|
|
loop {
|
|
|
let unfinished: Vec<_> = self.ts_parts.iter_mut()
|
|
|
let unfinished: Vec<_> = self.ts_parts.iter_mut()
|
|
|
. filter_map(|p| match p.state {
|
|
|
|
|
|
TsState::Ready => if p.content_type != Some("video/MP2T".to_string()) {
|
|
|
|
|
|
Some(p.download(client))
|
|
|
|
|
|
|
|
|
. filter_map(|ts_part| match ts_part.state {
|
|
|
|
|
|
TsState::Ready => if ts_part.content_type != Some("video/MP2T".to_string()) {
|
|
|
|
|
|
Some(ts_part.download(client))
|
|
|
} else {
|
|
|
} else {
|
|
|
None
|
|
|
None
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
_ => Some(p.download(client))
|
|
|
|
|
|
|
|
|
_ => Some(ts_part.download(client))
|
|
|
}).collect();
|
|
|
}).collect();
|
|
|
|
|
|
|
|
|
debug!("UNFINISHED NOW: {}", unfinished.len());
|
|
|
debug!("UNFINISHED NOW: {}", unfinished.len());
|
|
|
|