diff options
author | fxqnlr <[email protected]> | 2022-11-05 21:53:24 +0100 |
---|---|---|
committer | fxqnlr <[email protected]> | 2022-11-05 21:53:24 +0100 |
commit | 0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd (patch) | |
tree | 6262c397c500834cf6a06059394ac51328de3aed /src/apis | |
parent | 5d50f446a1a4612c0c931bdbc61f945760392f29 (diff) | |
download | modlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.tar modlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.tar.gz modlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.zip |
added setup & download; direct input
Diffstat (limited to 'src/apis')
-rw-r--r-- | src/apis/modrinth.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/apis/modrinth.rs b/src/apis/modrinth.rs index c71b47f..abb8eec 100644 --- a/src/apis/modrinth.rs +++ b/src/apis/modrinth.rs | |||
@@ -156,6 +156,16 @@ pub async fn versions(api: String, id: String, list: List) -> Vec<Version> { | |||
156 | serde_json::from_slice(&data.await.unwrap()).unwrap() | 156 | serde_json::from_slice(&data.await.unwrap()).unwrap() |
157 | } | 157 | } |
158 | 158 | ||
159 | pub async fn get_raw_versions(api: String, versions: Vec<String>) -> Vec<Version> { | ||
160 | println!("Getting versions"); | ||
161 | |||
162 | let url = format!(r#"versions?ids=["{}"]"#, versions.join(r#"",""#)); | ||
163 | |||
164 | let data = get(api, url).await; | ||
165 | |||
166 | serde_json::from_slice(&data.unwrap()).unwrap() | ||
167 | } | ||
168 | |||
159 | pub fn extract_current_version(versions: Vec<Version>) -> Result<String, Box<dyn std::error::Error>> { | 169 | pub fn extract_current_version(versions: Vec<Version>) -> Result<String, Box<dyn std::error::Error>> { |
160 | match versions.len() { | 170 | match versions.len() { |
161 | 0 => Err(Box::new(Error::new(ErrorKind::NotFound, "NO_VERSIONS_AVAILABLE"))), | 171 | 0 => Err(Box::new(Error::new(ErrorKind::NotFound, "NO_VERSIONS_AVAILABLE"))), |