CLI: Pass --years as argument

pull/105/head
desimaniac 5 years ago
parent 430bba33b0
commit 65da06f3eb

@ -3,6 +3,7 @@ import os.path
import signal import signal
import sys import sys
import time import time
import re
import click import click
import schedule import schedule
@ -292,6 +293,10 @@ def show(
type=click.Choice(['rating', 'release', 'votes']), type=click.Choice(['rating', 'release', 'votes']),
help='Sort list to process.', help='Sort list to process.',
show_default=True) show_default=True)
@click.option(
'--years', '-y',
default=None,
help='Range of years to search. For example, \'2000-2010\'.')
@click.option( @click.option(
'--genres', '-g', '--genres', '-g',
default=None, default=None,
@ -338,6 +343,7 @@ def shows(
add_limit=0, add_limit=0,
add_delay=2.5, add_delay=2.5,
sort='votes', sort='votes',
years=None,
genres=None, genres=None,
folder=None, folder=None,
actor=None, actor=None,
@ -371,7 +377,12 @@ def shows(
log.debug("Filter Trakt results with genre(s): %s", ', '.join(map(lambda x: x.title(), genres.split(',')))) log.debug("Filter Trakt results with genre(s): %s", ', '.join(map(lambda x: x.title(), genres.split(','))))
# set years range # set years range
if cfg.filters.shows.blacklisted_min_year and cfg.filters.shows.blacklisted_max_year: r = re.compile('[0-9]{4}-[0-9]{4}')
if years and r.match(years):
cfg['filters']['shows']['blacklisted_min_year'] = int(years.split('-')[0])
cfg['filters']['shows']['blacklisted_max_year'] = int(years.split('-')[1])
elif cfg.filters.shows.blacklisted_min_year and cfg.filters.shows.blacklisted_max_year:
years = str(cfg.filters.shows.blacklisted_min_year) + '-' + str(cfg.filters.shows.blacklisted_max_year) years = str(cfg.filters.shows.blacklisted_min_year) + '-' + str(cfg.filters.shows.blacklisted_max_year)
else: else:
years = None years = None
@ -750,6 +761,10 @@ def movie(
default=None, default=None,
type=int, type=int,
help='Set a minimum Rotten Tomatoes score.') help='Set a minimum Rotten Tomatoes score.')
@click.option(
'--years', '-y',
default=None,
help='Range of years to search. For example, \'2000-2010\'.')
@click.option( @click.option(
'--genres', '-g', '--genres', '-g',
default=None, default=None,
@ -801,6 +816,7 @@ def movies(
add_delay=2.5, add_delay=2.5,
sort='votes', sort='votes',
rotten_tomatoes=None, rotten_tomatoes=None,
years=None,
genres=None, genres=None,
folder=None, folder=None,
minimum_availability=None, minimum_availability=None,
@ -840,7 +856,12 @@ def movies(
log.debug("Filter Trakt results with genre(s): %s", ', '.join(map(lambda x: x.title(), genres))) log.debug("Filter Trakt results with genre(s): %s", ', '.join(map(lambda x: x.title(), genres)))
# set years range # set years range
if cfg.filters.movies.blacklisted_min_year and cfg.filters.movies.blacklisted_max_year: r = re.compile('[0-9]{4}-[0-9]{4}')
if years and r.match(years):
cfg['filters']['movies']['blacklisted_min_year'] = int(years.split('-')[0])
cfg['filters']['movies']['blacklisted_max_year'] = int(years.split('-')[1])
elif cfg.filters.movies.blacklisted_min_year and cfg.filters.movies.blacklisted_max_year:
years = str(cfg.filters.movies.blacklisted_min_year) + '-' + str(cfg.filters.movies.blacklisted_max_year) years = str(cfg.filters.movies.blacklisted_min_year) + '-' + str(cfg.filters.movies.blacklisted_max_year)
else: else:
years = None years = None

Loading…
Cancel
Save