Reference/API
ROMSearch
- class romsearch.ROMSearch(config_file=None, config=None, default_config=None, regex_config=None, logger=None)[source]
General search tool to get ROMs downloaded and organized into files
- Parameters:
config_file (str, optional) – path to config file. Defaults to None.
config (dict, optional) – configuration dictionary. Defaults to None.
default_config (dict, optional) – default configuration dictionary. Defaults to None.
regex_config (dict, optional) – regex configuration dictionary. Defaults to None.
ROMDownloader
- class romsearch.ROMDownloader(platform=None, config_file=None, config=None, platform_config=None, rclone_method='sync', copy_files=None, logger=None, include_filter_wildcard=True)[source]
Downloader tool via rclone
This works per-platform, so must be specified here.
For this, we can either sync an entire directory (rclone_method=’sync’), or copy individual files (rclone_method=’copy’). If the method is copy, then copy_files must be set as a list
- Parameters:
platform (str, optional) – Platform name. Defaults to None, which will throw a ValueError
config_file (str, optional) – Configuration file. Defaults to None
config (dict, optional) – Configuration dictionary. Defaults to None
platform_config (dict, optional) – Platform configuration dictionary. Defaults to None
rclone_method (str, optional) – Should be one of ‘sync’ or ‘copy’. Defaults to ‘sync’
copy_files (list, optional) – Must be set if rclone_method is ‘copy’. Determines the filenames to copy over. Defaults to None
logger (logging.Logger, optional) – Logger instance. Defaults to None
include_filter_wildcard (bool, optional) – If set, will include wildcards in rclone filters. Defaults to True.
- post_to_discord(start_files, end_files, name, max_per_message=10)[source]
Create a discord post summarising files added and removed
- Parameters:
start_files (list) – list of files at the start of the rclone
end_files (list) – list of files at the end of the rclone
name (string) – Name of the post title
max_per_message (int, optional) – Maximum number of items per post. Defaults to 10.
- rclone_copy(remote_dir, out_dir=None, max_retries=5)[source]
Use rclone to sync files one-by-one
- Parameters:
remote_dir – rclone remote path
out_dir – directory to download to
max_retries – maximum number of retries
- rclone_download(remote_dir, out_dir=None, max_retries=5)[source]
Download from rclone, either via sync or copy
- Parameters:
remote_dir – rclone remote path
out_dir – directory to download to
max_retries – maximum number of retries
Utilities
- romsearch.util.get_bracketed_file_pattern(str_to_match)[source]
Get file pattern to match bracketed things
This is a little tricky since sometimes things can be matched a little unusually. What we do here is allow for matches of letters, commas or spaces before and after, but ensure there’s no text immediately after the match. So “De” will match for a language but not “Demo”
- romsearch.util.get_file_time(f, datetime_format)[source]
Get created file time from the file itself
- romsearch.util.get_game_name(f)[source]
Get game name, which is just everything up to the first bracket
- romsearch.util.get_parent_name(game_name, dupe_dict)[source]
Get the parent name recursively searching through a dupe dict
- romsearch.util.get_short_name(f, regex_config=None, default_config=None)[source]
Get short game name from the ROM file naming convention
- romsearch.util.setup_logger(log_level, script_name, log_dir, additional_dir='', max_logs=9)[source]
Set up the logger.
- Parameters:
log_level (str) – The log level to use
script_name (str) – The name of the script
log_dir (str) – The directory to save logs to
additional_dir (str) – Any additional directories to keep log files tidy
max_logs (int) – Maximum number of log files to keep
- Returns:
A logger object for logging messages.