Reformat code
This commit is contained in:
31
src/main.rs
31
src/main.rs
@@ -58,8 +58,8 @@ fn main() {
|
||||
Arg::with_name("CATALOG_NAME")
|
||||
.help(
|
||||
"name of the catalog e.g. from the URL:\n\
|
||||
https://streams.tum.de/Mediasite/Catalog/catalogs/era-2016 -> era-2016\n\
|
||||
special cases (WS16/17; login included): DS, EIDI, ERA, ...",
|
||||
https://streams.tum.de/Mediasite/Catalog/catalogs/era-2016 -> era-2016\n\
|
||||
special cases (WS16/17; login included): DS, EIDI, ERA, ...",
|
||||
)
|
||||
.required(true)
|
||||
.index(1),
|
||||
@@ -144,10 +144,12 @@ fn get_auth() {
|
||||
|
||||
let res = try_to_get_valid_response(
|
||||
|client| {
|
||||
let mut request_builder = client.post("https://streams.tum.de/Mediasite/Login").unwrap();
|
||||
request_builder.form(
|
||||
&form_data,
|
||||
).expect("Failed to serialize form_data!");
|
||||
let mut request_builder = client
|
||||
.post("https://streams.tum.de/Mediasite/Login")
|
||||
.unwrap();
|
||||
request_builder
|
||||
.form(&form_data)
|
||||
.expect("Failed to serialize form_data!");
|
||||
request_builder
|
||||
},
|
||||
|res| res.headers().get::<SetCookie>().is_some(),
|
||||
@@ -218,7 +220,7 @@ fn get_catalog_id(name: &str) -> String {
|
||||
let prefix = "CatalogId: '";
|
||||
let idx = body.find(prefix).expect(
|
||||
"Failed to find CatalogId on the catalog page! Perhaps you got the wrong catalog \
|
||||
name or an invalid login? Maybe you need to open the page in a browser once...",
|
||||
name or an invalid login? Maybe you need to open the page in a browser once...",
|
||||
);
|
||||
let pre_len = prefix.len();
|
||||
// Assuming all catalog ids follow this pattern!
|
||||
@@ -251,9 +253,12 @@ fn get_json(catalog_id: &str) -> String {
|
||||
let mut request_builder = client
|
||||
.post(
|
||||
"https://streams.tum.de/Mediasite/Catalog/Data/GetPresentationsForFolder",
|
||||
).unwrap();
|
||||
request_builder.header(construct_cookie())
|
||||
.json(&data).expect("Failed to serialize json!");
|
||||
)
|
||||
.unwrap();
|
||||
request_builder
|
||||
.header(construct_cookie())
|
||||
.json(&data)
|
||||
.expect("Failed to serialize json!");
|
||||
request_builder
|
||||
});
|
||||
read_response_body(&mut res)
|
||||
@@ -302,8 +307,8 @@ where
|
||||
|
||||
fn read_response_body(response: &mut Response) -> String {
|
||||
let mut string = String::new();
|
||||
response.read_to_string(&mut string).expect(
|
||||
"Failed to read body",
|
||||
);
|
||||
response
|
||||
.read_to_string(&mut string)
|
||||
.expect("Failed to read body");
|
||||
string
|
||||
}
|
||||
|
Reference in New Issue
Block a user