Reformat...
This commit is contained in:
@@ -71,10 +71,9 @@ impl Presentation {
|
||||
match *param {
|
||||
DispositionParam::Filename(ref charset, _, ref vec) => {
|
||||
assert_eq!(&Charset::Ext("UTF-8".to_string()), charset);
|
||||
name = Some(
|
||||
String::from_utf8(vec.to_vec())
|
||||
.expect("Suggested filename isn't valid UTF-8!")
|
||||
);
|
||||
name = Some(String::from_utf8(vec.to_vec()).expect(
|
||||
"Suggested filename isn't valid UTF-8!",
|
||||
));
|
||||
}
|
||||
_ => continue,
|
||||
}
|
||||
@@ -105,15 +104,13 @@ impl Presentation {
|
||||
|
||||
let url = "https://streams.tum.de/Mediasite/PlayerService/\
|
||||
PlayerService.svc/json/GetPlayerOptions";
|
||||
let mut res = try_to_get_response(
|
||||
|client| {
|
||||
client
|
||||
.post(url)
|
||||
.header(construct_cookie())
|
||||
.header(ContentType::json())
|
||||
.body(&*payload)
|
||||
}
|
||||
);
|
||||
let mut res = try_to_get_response(|client| {
|
||||
client
|
||||
.post(url)
|
||||
.header(construct_cookie())
|
||||
.header(ContentType::json())
|
||||
.body(&*payload)
|
||||
});
|
||||
|
||||
let json_text = read_response_body(&mut res);
|
||||
if json_text.contains("You are not authorized to view the requested content") {
|
||||
@@ -130,11 +127,10 @@ impl Presentation {
|
||||
vec
|
||||
};
|
||||
for (i, download_url) in videos.iter().enumerate() {
|
||||
let mut response =
|
||||
try_to_get_valid_response(
|
||||
|client| client.get(download_url).header(construct_cookie()),
|
||||
|resp| resp.status() == &StatusCode::Ok,
|
||||
);
|
||||
let mut response = try_to_get_valid_response(
|
||||
|client| client.get(download_url).header(construct_cookie()),
|
||||
|resp| resp.status() == &StatusCode::Ok,
|
||||
);
|
||||
// TODO: Support formats besides mp4
|
||||
// extract extension from url or somewehre else...
|
||||
let filename = format!("{} - {}.mp4", fix_filename(self.name()), i + 1);
|
||||
@@ -159,10 +155,9 @@ impl<'a> From<&'a JsonValue> for Presentation {
|
||||
if json["DownloadUrls"].len() >= 1 {
|
||||
assert_eq!(json["DownloadUrls"].len(), 1);
|
||||
Presentation::PublishToGo {
|
||||
name: json["Name"]
|
||||
.clone()
|
||||
.take_string()
|
||||
.expect("json: Presentation didn't contain a \"Name\"!"),
|
||||
name: json["Name"].clone().take_string().expect(
|
||||
"json: Presentation didn't contain a \"Name\"!",
|
||||
),
|
||||
download_url: json["DownloadUrls"][0]["Url"]
|
||||
.clone()
|
||||
.take_string()
|
||||
@@ -177,10 +172,9 @@ impl<'a> From<&'a JsonValue> for Presentation {
|
||||
let index_start_resource = index - "cdf23465581b45aa92d588ebd59619d91d".len();
|
||||
|
||||
Presentation::VideoOnDemand {
|
||||
name: json["Name"]
|
||||
.clone()
|
||||
.take_string()
|
||||
.expect("json: Presentation didn't contain a \"Name\"!"),
|
||||
name: json["Name"].clone().take_string().expect(
|
||||
"json: Presentation didn't contain a \"Name\"!",
|
||||
),
|
||||
query_string: player_url[index..index_end_query].to_string(),
|
||||
resource_id: player_url[index_start_resource..index].to_string(),
|
||||
}
|
||||
@@ -206,8 +200,9 @@ fn download_to_file(response: &mut Response, path: &Path) -> Result<(), io::Erro
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
|
||||
file.write_all(&buf[0..len])
|
||||
.expect("Failed writing into the file!");
|
||||
file.write_all(&buf[0..len]).expect(
|
||||
"Failed writing into the file!",
|
||||
);
|
||||
done += len;
|
||||
|
||||
let now = Instant::now();
|
||||
@@ -217,9 +212,9 @@ fn download_to_file(response: &mut Response, path: &Path) -> Result<(), io::Erro
|
||||
2,
|
||||
done as f64 * 1000.0 / update_duration_millis as f64 / 1024.0
|
||||
);
|
||||
::std::io::stdout()
|
||||
.flush()
|
||||
.expect("Failed flushing the terminal!");
|
||||
::std::io::stdout().flush().expect(
|
||||
"Failed flushing the terminal!",
|
||||
);
|
||||
last = now;
|
||||
done = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user