def schedule(broker, args): usage = "%prog schedule [options]" description = "Description: process configured sources and schedule nzb's for download" epilog = """ Examples: Process configured sources and schedule nzb's for download: > python mediarover.py schedule Same as above, but use non-default config directory: > python mediarover.py schedule --config /path/to/config/dir Process configured sources but don't schedule anything for download: > python mediarover.py schedule --dry-run """ parser = OptionParser(usage=usage, description=description, epilog=epilog, add_help_option=False) parser.add_option("-c", "--config", metavar="/PATH/TO/CONFIG/DIR", help="path to application configuration directory") parser.add_option("-d", "--dry-run", action="store_true", default=False, help="simulate downloading nzb's from configured sources") parser.add_option("-h", "--help", action="callback", callback=print_epilog, help="show this help message and exit") (options, args) = parser.parse_args(args) if options.config: broker.register(CONFIG_DIR, options.config) # create config object using user config values try: config = get_processed_app_config(broker[RESOURCES_DIR], broker[CONFIG_DIR]) except (ConfigurationError), e: print e exit(1)
def set_quality(broker, args): usage = "%prog set-quality [options] [series [season [episode]]]" description = "Description: populate metadata database with local episode quality specifics" epilog = """ Examples: Interactive Prompt: ================== Process series directories: > python mediarover.py set-quality Same as above, but use non-default config directory > python mediarover.py set-quality --config /path/to/config/dir Process series directories (without series prompt): > python mediarover.py set-quality --no-series-prompt Process episodes of a given series: > python mediarover.py set-quality some.show Process episodes of a given series and season: > python mediarover.py set-quality some.show 3 Process specific episode of a given series: > python mediarover.py set-quality some.show 3 15 Partially Automated: =================== Process series directories setting files with extension .avi to medium quality: > python mediarover.py set-quality --medium avi Same as above, but also set .mp4 to medium and .mkv to high quality: > python mediarover.py set-quality --medium avi --medium mp4 --high mkv Automate as much as possible, only prompting the user for input when absolutely needed: > python mediarover.py set-quality --low mp4 --medium avi --high mkv --no-series-prompt """ parser = OptionParser(usage=usage, description=description, epilog=epilog, add_help_option=False) parser.add_option("-c", "--config", metavar="/PATH/TO/CONFIG/DIR", help="path to application configuration directory") parser.add_option("-l", "--low", action="append", type="string", default=list(), help="mark extension as LOW quality") parser.add_option("-m", "--medium", action="append", type="string", default=list(), help="mark extension as MEDIUM quality") parser.add_option("-H", "--high", action="append", type="string", default=list(), help="mark extension as HIGH quality") parser.add_option("--no-series-prompt", action="store_false", dest="series_prompt", default=True, help="Don't ask for confirmation before processing each series") parser.add_option("-h", "--help", action="callback", callback=print_epilog, help="show this help message and exit") (options, args) = parser.parse_args(args) if options.config: broker.register(CONFIG_DIR, options.config) # create config object using user config values try: config = get_processed_app_config(broker[RESOURCES_DIR], broker[CONFIG_DIR]) except (ConfigurationError), e: print e exit(1)
def configuration(broker, args): usage = "%prog configuration [options]" description = "Description: generate default configuration and logging files" epilog = """ Examples: Generate default application config files: > python mediarover.py configuration --write Generate default application config files, in a specific directory: > python mediarover.py configuration --write --config /path/to/config/dir Process tv_root and generate series filters > python mediarover.py configuration --generate-filters Advanced Example: Generate default application config files, set tv_root to given value(s), and generate series filters Note: multiple tv_root values must be separated by commas, no spaces > python mediarover.py configuration --write /path/to/tv,/path/to/more/tv --generate-filters """ parser = OptionParser(usage=usage, description=description, epilog=epilog, add_help_option=False) parser.add_option("-c", "--config", metavar="/PATH/TO/CONFIG/DIR", help="path to application configuration directory") parser.add_option("--generate-filters", action="store_true", default=False, help="Generate default series filters") parser.add_option("--write", action="store_true", default=False, help="Generate default configuration and logging files") parser.add_option("-h", "--help", action="callback", callback=print_epilog, help="show this help message and exit") (options, args) = parser.parse_args(args) if options.config: broker.register(CONFIG_DIR, options.config) if options.write: if len(args) > 0: tv_root = args[0] generate_filters = options.generate_filters else: tv_root = None generate_filters = False generate_config_files(broker[RESOURCES_DIR], broker[CONFIG_DIR], tv_root, generate_filters) elif options.generate_filters: try: config = get_processed_app_config(broker[RESOURCES_DIR], broker[CONFIG_DIR]) except (ConfigurationError), e: print e exit(1) else: generate_series_filters(broker[RESOURCES_DIR], broker[CONFIG_DIR], config)
def episode_sort(broker, args): usage = "%%prog episode-sort [options] result_dir [%s|%s|%s] | [nzb_name nice_name newzbin_id category newsgroup status]" % (LOW, MEDIUM, HIGH) description = "Description: process a recent download and sort episode file in appropriate series folder" epilog = """ Examples: Manual use: ========== Manually sort a downloaded file: > python mediarover.py episode-sort /path/to/some.download Same as above, but use a non-default config directory: > python mediarover.py episode-sort --config /path/to/config/dir /path/to/some.download Manually sort a downloaded file, but specify an overriding quality level: (%s/%s/%s) > python mediarover.py episode-sort /path/to/some.download high Simulate sorting a downloaded file: > python mediarover.py episode-sort --dry-run /path/to/some.download From shell script : (called by SABnzbd) ================== Sort a downloaded file: > python mediarover.py episode-sort /path/to/some.download some.download.nzb some.download 12345 tv alt.public.access.tv 0 """ % (LOW, MEDIUM, HIGH) parser = OptionParser(usage=usage, description=description, epilog=epilog, add_help_option=False) parser.add_option("-c", "--config", metavar="/PATH/TO/CONFIG/DIR", help="path to application configuration directory") parser.add_option("-d", "--dry-run", action="store_true", default=False, help="simulate downloading nzb's from configured sources") parser.add_option("-h", "--help", action="callback", callback=print_epilog, help="show this help message and exit") (options, args) = parser.parse_args(args) if options.config: broker.register(CONFIG_DIR, options.config) # create config object using user config values try: config = get_processed_app_config(broker[RESOURCES_DIR], broker[CONFIG_DIR]) except (ConfigurationError), e: print e exit(1)