Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdallas committed Nov 3, 2022
1 parent 49e97f7 commit d979873
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
13 changes: 3 additions & 10 deletions src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ impl<'a> Downloader<'a> {

/// Check if a particular URL contains supported media.
async fn get_media(&self, data: &PostData) -> Result<Vec<SupportedMedia>, GertError> {

let original = data.url.as_ref().unwrap();
let mut media: Vec<SupportedMedia> = Vec::new();

Expand Down Expand Up @@ -572,22 +571,16 @@ impl<'a> Downloader<'a> {
// collect all the URLs for the images in the album
let mut image_urls = Vec::new();
for item in gallery.items.iter() {


let mut ext = JPG_EXTENSION;
if let Some(metadata) = media_metadata {
if let Some(media) = metadata.get(&item.media_id) {
ext = media.m.split('/').last().unwrap();
ext = media.m.split('/').last().unwrap();
}
}



// extract the media ID from each gallery item and reconstruct the image URL
let image_url = format!(
"https://{}/{}.{}",
REDDIT_IMAGE_SUBDOMAIN, item.media_id, ext
);
let image_url =
format!("https://{}/{}.{}", REDDIT_IMAGE_SUBDOMAIN, item.media_id, ext);
image_urls.push(image_url);
}
let supported_media = SupportedMedia {
Expand Down
20 changes: 12 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,24 @@ async fn main() -> Result<(), GertError> {
let limit = match matches.value_of("limit").unwrap().parse::<u32>() {
Ok(limit) => limit,
Err(_) => {
let err = clap::Error::with_description("Limit must be a number", clap::ErrorKind::InvalidValue);
let err = clap::Error::with_description(
"Limit must be a number",
clap::ErrorKind::InvalidValue,
);
err.exit();
}
};
let period = matches.value_of("period");
let feed = matches.value_of("feed").unwrap();
let pattern = match matches.value_of("match") {
Some(pattern) => {
match regex::Regex::new(pattern) {
Ok(reg) => reg,
Err(_) => {
let err = clap::Error::with_description("Invalid regex pattern", clap::ErrorKind::InvalidValue);
err.exit();
}
Some(pattern) => match regex::Regex::new(pattern) {
Ok(reg) => reg,
Err(_) => {
let err = clap::Error::with_description(
"Invalid regex pattern",
clap::ErrorKind::InvalidValue,
);
err.exit();
}
},
None => regex::Regex::new(".*").unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion src/structures.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::{ops::Add, collections::HashMap};
use std::{collections::HashMap, ops::Add};

/// Data structure that represents a user's info
#[derive(Debug, Serialize, Deserialize)]
Expand Down

0 comments on commit d979873

Please sign in to comment.