Reformat; Handle AuthorizationTimeout for p2g presentations

This commit is contained in:
2017-06-17 03:32:46 +02:00
parent 07d77ab0f6
commit 4e71132674
3 changed files with 95 additions and 108 deletions

View File

@@ -57,11 +57,18 @@ impl Presentation {
match *self {
Presentation::PublishToGo { ref download_url, .. } => {
let mut response = try_to_get_valid_response(
let response_res = try_to_get_valid_response(
|client| client.get(download_url).header(construct_cookie()),
|resp| resp.headers().get::<ContentDisposition>().is_some(),
);
if response_res.is_err() {
// Appears to be the reason...
return Err(DownloadError::AuthorizationTimeout);
}
let mut response = response_res.unwrap();
let filename = {
let content_disposition =
response.headers().get::<ContentDisposition>().unwrap();
@@ -130,7 +137,7 @@ impl Presentation {
let mut response = try_to_get_valid_response(
|client| client.get(download_url).header(construct_cookie()),
|resp| resp.status() == &StatusCode::Ok,
);
).unwrap();
// TODO: Support formats besides mp4
// extract extension from url or somewehre else...
let filename = format!("{} - {}.mp4", fix_filename(self.name()), i + 1);