ability to skip game or movie content

This commit is contained in:
Sebastian Hugentobler 2017-03-22 14:40:54 +01:00
parent bcb95f3c28
commit c1779265af
3 changed files with 43 additions and 4 deletions

View File

@ -124,7 +124,9 @@ impl<'a> Gog<'a> {
storage_path: &str,
storage_path_movies: &str,
os_filters: &Vec<String>,
language_filters: &Vec<String>)
language_filters: &Vec<String>,
skip_movies: bool,
skip_games: bool)
-> Result<(), GogError> {
let configfiles = ConfigFiles::new();
let mut config: Config = match configfiles.load("config.json") {
@ -140,6 +142,8 @@ impl<'a> Gog<'a> {
extras: HashMap::new(),
os_filters: os_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);
if game_hash_saved == game_hash {

View File

@ -15,7 +15,7 @@
//! -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 clap;
@ -73,6 +73,16 @@ fn main() {
.value_name("FILTER")
.help("Only sync files for this comma seperated list of languages.")
.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();
let configfiles = ConfigFiles::new();
@ -88,7 +98,7 @@ fn main() {
let download_folder_movies: &str = match matches.value_of("movieStorage") {
Some(value) => value,
None => config.movie_storage.as_str(),
None => download_folder,
};
let os_filters: Vec<String> = match matches.value_of("os") {
@ -101,12 +111,26 @@ fn main() {
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 gog = Gog::new(&mut http_client);
gog.login().unwrap();
gog.sync(download_folder,
download_folder_movies,
&os_filters,
&language_filters)
&language_filters,
skip_movies,
skip_games)
.unwrap();
}

View File

@ -46,6 +46,10 @@ pub struct Config {
pub os_filters: Vec<String>,
#[serde(default = "default_list")]
pub language_filters: Vec<String>,
#[serde(default)]
pub skip_movies: bool,
#[serde(default)]
pub skip_games: bool,
}
fn default_map() -> HashMap<String, u64> {
@ -66,6 +70,8 @@ impl Config {
extras: HashMap::new(),
os_filters: Vec::new(),
language_filters: Vec::new(),
skip_movies: false,
skip_games: false,
}
}
}