aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content.rs13
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;
8use cursive::Cursive; 8use cursive::Cursive;
9use cursive::views::Dialog; 9use cursive::views::Dialog;
10use serde_json::Value; 10use serde_json::Value;
11use reqwest::Response;
12use self::regex::Regex; 11use self::regex::Regex;
13 12
14pub fn query_url_gen(title: &str) -> String { 13pub 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
45pub fn get_extract(mut res: Response) -> Result<String, reqwest::Error> { 44pub 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
123pub fn get_links(mut res: Response) -> Result<Vec<String>, reqwest::Error> { 118pub 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,