diff options
-rw-r--r-- | src/content.rs | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/content.rs b/src/content.rs index f352f9f..13582f1 100644 --- a/src/content.rs +++ b/src/content.rs | |||
@@ -8,7 +8,6 @@ use cursive::utils::markup::StyledString; | |||
8 | use cursive::Cursive; | 8 | use cursive::Cursive; |
9 | use cursive::views::Dialog; | 9 | use cursive::views::Dialog; |
10 | use serde_json::Value; | 10 | use serde_json::Value; |
11 | use reqwest::Response; | ||
12 | use self::regex::Regex; | 11 | use self::regex::Regex; |
13 | 12 | ||
14 | pub fn query_url_gen(title: &str) -> String { | 13 | pub fn query_url_gen(title: &str) -> String { |
@@ -42,11 +41,7 @@ pub fn search_url_gen(search: &str) -> String { | |||
42 | url | 41 | url |
43 | } | 42 | } |
44 | 43 | ||
45 | pub fn get_extract(mut res: Response) -> Result<String, reqwest::Error> { | 44 | pub fn get_extract(v: &Value) -> Result<String, reqwest::Error> { |
46 | let v: Value = match serde_json::from_str(&res.text()?) { | ||
47 | Ok(x) => x, | ||
48 | Err(x) => panic!("Failed to parse json\nReceived error {}", x), | ||
49 | }; | ||
50 | let pageid = &v["query"]["pageids"][0]; | 45 | let pageid = &v["query"]["pageids"][0]; |
51 | let pageid_str = match pageid { | 46 | let pageid_str = match pageid { |
52 | Value::String(id) => id, | 47 | Value::String(id) => id, |
@@ -120,11 +115,7 @@ pub fn get_search_results(search: &str) -> Result<Vec<String>, reqwest::Error> { | |||
120 | Ok(results) | 115 | Ok(results) |
121 | } | 116 | } |
122 | 117 | ||
123 | pub fn get_links(mut res: Response) -> Result<Vec<String>, reqwest::Error> { | 118 | pub fn get_links(v: &Value) -> Result<Vec<String>, reqwest::Error> { |
124 | let v: Value = match serde_json::from_str(&res.text()?) { | ||
125 | Ok(x) => x, | ||
126 | Err(x) => panic!("Failed to parse json\nReceived error {}", x), | ||
127 | }; | ||
128 | let pageid = &v["query"]["pageids"][0]; | 119 | let pageid = &v["query"]["pageids"][0]; |
129 | let pageid_str = match pageid { | 120 | let pageid_str = match pageid { |
130 | Value::String(id) => id, | 121 | Value::String(id) => id, |