ability to skip game or movie content
This commit is contained in:
parent
bcb95f3c28
commit
c1779265af
11
src/gog.rs
11
src/gog.rs
@ -124,7 +124,9 @@ impl<'a> Gog<'a> {
|
|||||||
storage_path: &str,
|
storage_path: &str,
|
||||||
storage_path_movies: &str,
|
storage_path_movies: &str,
|
||||||
os_filters: &Vec<String>,
|
os_filters: &Vec<String>,
|
||||||
language_filters: &Vec<String>)
|
language_filters: &Vec<String>,
|
||||||
|
skip_movies: bool,
|
||||||
|
skip_games: bool)
|
||||||
-> Result<(), GogError> {
|
-> Result<(), GogError> {
|
||||||
let configfiles = ConfigFiles::new();
|
let configfiles = ConfigFiles::new();
|
||||||
let mut config: Config = match configfiles.load("config.json") {
|
let mut config: Config = match configfiles.load("config.json") {
|
||||||
@ -140,6 +142,8 @@ impl<'a> Gog<'a> {
|
|||||||
extras: HashMap::new(),
|
extras: HashMap::new(),
|
||||||
os_filters: os_filters.clone(),
|
os_filters: os_filters.clone(),
|
||||||
language_filters: language_filters.clone(),
|
language_filters: language_filters.clone(),
|
||||||
|
skip_movies: skip_movies,
|
||||||
|
skip_games: skip_games,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -160,6 +164,11 @@ impl<'a> Gog<'a> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (game.is_movie && skip_movies) || (!game.is_movie && skip_games) {
|
||||||
|
info!("filtering {}", game.title);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let game_hash = models::get_hash(&game);
|
let game_hash = models::get_hash(&game);
|
||||||
|
|
||||||
if game_hash_saved == game_hash {
|
if game_hash_saved == game_hash {
|
||||||
|
30
src/main.rs
30
src/main.rs
@ -15,7 +15,7 @@
|
|||||||
//! -s, --storage <FOLDER> Sets the download folder (defaults to the working directory).
|
//! -s, --storage <FOLDER> Sets the download folder (defaults to the working directory).
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! An incomplete list of languages on gog: `english, český, deutsch, español, français, magyar, polski, русский, 中文`
|
//! An incomplete list of languages on gog: `english, český, deutsch, español, français, italiano, magyar, polski, русский, 中文`
|
||||||
|
|
||||||
extern crate chrono;
|
extern crate chrono;
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
@ -73,6 +73,16 @@ fn main() {
|
|||||||
.value_name("FILTER")
|
.value_name("FILTER")
|
||||||
.help("Only sync files for this comma seperated list of languages.")
|
.help("Only sync files for this comma seperated list of languages.")
|
||||||
.takes_value(true))
|
.takes_value(true))
|
||||||
|
.arg(Arg::with_name("skip-movies")
|
||||||
|
.short("f")
|
||||||
|
.long("skip-movies")
|
||||||
|
.help("Skip movie content.")
|
||||||
|
.takes_value(false))
|
||||||
|
.arg(Arg::with_name("skip-games")
|
||||||
|
.short("g")
|
||||||
|
.long("skip-games")
|
||||||
|
.help("Skip game content.")
|
||||||
|
.takes_value(false))
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
let configfiles = ConfigFiles::new();
|
let configfiles = ConfigFiles::new();
|
||||||
@ -88,7 +98,7 @@ fn main() {
|
|||||||
|
|
||||||
let download_folder_movies: &str = match matches.value_of("movieStorage") {
|
let download_folder_movies: &str = match matches.value_of("movieStorage") {
|
||||||
Some(value) => value,
|
Some(value) => value,
|
||||||
None => config.movie_storage.as_str(),
|
None => download_folder,
|
||||||
};
|
};
|
||||||
|
|
||||||
let os_filters: Vec<String> = match matches.value_of("os") {
|
let os_filters: Vec<String> = match matches.value_of("os") {
|
||||||
@ -101,12 +111,26 @@ fn main() {
|
|||||||
None => config.language_filters,
|
None => config.language_filters,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let skip_movies = if matches.is_present("skip-movies") {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
config.skip_movies
|
||||||
|
};
|
||||||
|
|
||||||
|
let skip_games = if matches.is_present("skip-games") {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
config.skip_games
|
||||||
|
};
|
||||||
|
|
||||||
let mut http_client = Http::new();
|
let mut http_client = Http::new();
|
||||||
let mut gog = Gog::new(&mut http_client);
|
let mut gog = Gog::new(&mut http_client);
|
||||||
gog.login().unwrap();
|
gog.login().unwrap();
|
||||||
gog.sync(download_folder,
|
gog.sync(download_folder,
|
||||||
download_folder_movies,
|
download_folder_movies,
|
||||||
&os_filters,
|
&os_filters,
|
||||||
&language_filters)
|
&language_filters,
|
||||||
|
skip_movies,
|
||||||
|
skip_games)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,10 @@ pub struct Config {
|
|||||||
pub os_filters: Vec<String>,
|
pub os_filters: Vec<String>,
|
||||||
#[serde(default = "default_list")]
|
#[serde(default = "default_list")]
|
||||||
pub language_filters: Vec<String>,
|
pub language_filters: Vec<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub skip_movies: bool,
|
||||||
|
#[serde(default)]
|
||||||
|
pub skip_games: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_map() -> HashMap<String, u64> {
|
fn default_map() -> HashMap<String, u64> {
|
||||||
@ -66,6 +70,8 @@ impl Config {
|
|||||||
extras: HashMap::new(),
|
extras: HashMap::new(),
|
||||||
os_filters: Vec::new(),
|
os_filters: Vec::new(),
|
||||||
language_filters: Vec::new(),
|
language_filters: Vec::new(),
|
||||||
|
skip_movies: false,
|
||||||
|
skip_games: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user