Reference/API

GUI

class nxbrew_dl.gui.MainWindow[source]

NXBrew-dl Main Window

This is the main GUI for NXBrew-dl. It’s where the magic happens!

closeEvent(event)[source]

Close the application

enable_disable_ui(mode='disable')[source]

Selective enable/disable parts of the UI

Parameters:

mode – Whether to ‘enable’ or ‘disable’. Defaults to disable

get_game_dict()[source]

Get game dictionary from NXBrew A-Z page

load_config()[source]

Apply read in config to the GUI

load_table()[source]

Load the game table, disable things until we’re done

run_nxbrew_dl()[source]

Run NXBrew-dl

save_config()[source]

Save config to file

set_directory_name(line_edit)[source]

Make a button set a directory name

Parameters:

line_edit (QLineEdit) – The QLineEdit widget to set the text for

setup_update_notification(new_version_available, url)[source]

Create a message box to open up to the latest GitHub release

staticMetaObject = PySide6.QtCore.QMetaObject("MainWindow" inherits "QMainWindow": Methods:   #39 type=Slot, signature=run_nxbrew_dl() )
update_display(text)[source]

When using the search bar, show/hide rows

Parameters:

text (str) – Text to filter out rows

update_progressbar_value(value)[source]
class nxbrew_dl.gui.RegionLanguageWindow(user_config=None, general_config=None, parent=None)[source]

NXBrew-dl region/language window

This part controls the advanced region/language options, where order is important and there are quite a few options!

Parameters:
  • user_config (dict) – user config. If None, will load in from expected path

  • general_config (dict) – general config. If None, will load in from expected path

load_config()[source]

Load the region/language configuration

populate_list(default_config_key, list_widget, item_dict=None, check_state=None)[source]

Load items from a dict, potentially checked/unchecked

set_languages()[source]

Set languages from the user config

set_regions()[source]

Set regions from the user config

staticMetaObject = PySide6.QtCore.QMetaObject("RegionLanguageWindow" inherits "QWidget": )
class nxbrew_dl.gui.AboutWindow(parent=None)[source]

NXBrew-dl About window

staticMetaObject = PySide6.QtCore.QMetaObject("AboutWindow" inherits "QDialog": )

NXBrew Downloader

class nxbrew_dl.nxbrew_dl.NXBrew(to_download, progress_bar=None, progress_bar_label=None, update_progressBar=None, general_config=None, regex_config=None, user_config=None, user_cache=None, logger=None)[source]

Handles downloading files

Will search through download sites in priority, pulling out links and sending them to JDownloader. If they’re all online, will bulk download/extract, and then remove the links

Parameters:
  • to_download (dict) – Dictionary of files to download

  • progress_bar (QProgressBar, optional) – Progress bar widget. Defaults to None, which will do nothing fancy with the progress bar

  • progress_bar_label (QLabel, optional) – If set, will put the game title in a progress bar label. Defaults to None

  • general_config (dict) – Dictionary for default configuration

  • regex_config (dict) – Dictionary for regex configuration

  • user_config (dict) – Dictionary for user configuration

  • user_cache (dict) – Cache dictionary

  • logger (logging.logger) – Logger instance. If None, will set up a new one

clean_up_cache()[source]

Remove items from the cache and on disk, if needed, and do a final save

download_game(name, url)[source]

Download game given URL

Will grab the HTML page, parse out files, then remove based on region/language preferences. If we don’t want DLC/Updates it’ll also remove them before sending off to JDownloader

Parameters:
  • name (str) – Name of game to download

  • url (str) – URL to download

get_dl_dict_score(dl_dict)[source]

Get the best ROM(s) from a list, using a scoring system

We only score by language and region, preferring a particular region over a particular language

Parameters:

dl_dict – Dictionary of potential downloads

post_to_discord(name, url, added_type='Base Game', description=None, thumb_url=None)[source]

Post summary as a discord message

Parameters:
  • name (str) – Game name

  • url (str) – URL for the ROM

  • added_type (str) – Type of added link. Defaults to “Base Game”

  • description (str) – Description of the link. Defaults to None

  • thumb_url (str) – Thumbnail URL. Defaults to None

run()[source]

Run NXBrew-dl

run_jdownloader(dl_dict, out_dir, package_name)[source]

Grab links and download through JDownloader

Will look through download sites in priority order, bypassing shortened links if required and checking everything’s online. Then, will download, extract, and clean up at the end

Parameters:
  • dl_dict (dict) – Dictionary of download files

  • out_dir – Directory to save downloaded files

  • package_name (str) – Name of package to define subdirectories and keep track of links

Utilities

class nxbrew_dl.util.NXBrewLogger(name='NXBrew', log_level='INFO', log_dir='log', max_logs=9)[source]

Intialise a custom logging class

This one will do a nice colorlog out to the terminal, and also save a log to file with sensitive info redacted

Parameters:
  • name (str) – The name of the logger. Defaults to “NXBrew”.

  • log_level (str) – Logging level. Defaults to “INFO”

  • log_dir (str) – The directory to save logs to. Defaults to “log”

  • max_logs (int) – The maximum number of logs to save. Defaults to 9

get_file_logger()[source]

Initialise logging to a file, moving files if necessary

get_gui_logger()[source]

Get the GUI logger

get_logger()[source]

Initialise the logging to file, and the GUI logger

update_redact_filter(redact_pattern)[source]

Update the redact patterns, update the redact filter

Parameters:

redact_pattern (str) – The regex pattern to redact. Any special regex characters are automatically escaped so this should be input as a literal string

Bypass 1link url

Parameters:
  • url (str) – URL to bypass

  • logger (logging.Logger) – Logger to use. Defaults to None, which will not log anything

  • impersonate (str) – Type of browser to impersonate. Defaults to None, which will choose randomly from a selection

  • n_retry (int) – Current retry. Defaults to 0

  • max_retries (int) – Maximum number of retries. Defaults to 5

nxbrew_dl.util.bypass_ouo(url, logger=None, impersonate=None, n_retry=0, max_retries=5)[source]

Bypass OUO url

Parameters:
  • url (str) – URL to bypass

  • logger (logging.Logger) – Logger to use. Defaults to None, which will not log anything

  • impersonate (str) – Type of browser to impersonate. Defaults to None, which will choose randomly from a selection

  • n_retry (int) – Current retry. Defaults to 0

  • max_retries (int) – Maximum number of retries. Defaults to 5

nxbrew_dl.util.check_github_version()[source]

Check NXBrew-dl version on GitHub. Returns version and associated URL

nxbrew_dl.util.check_has_filetype(f, search_str)[source]

Check whether the game has an associated filetype

Parameters:
  • f (str) – Name of the file

  • search_str (list) – List of potential values to check for

nxbrew_dl.util.discord_push(url, embeds)[source]

Post a message to Discord

Parameters:
  • url (str) – Discord URL

  • embeds (list) – List of dictionaries of embeds

nxbrew_dl.util.get_dl_dict(soup, dl_sites, dl_mappings, regions=None, languages=None, regionless_titles=None, implied_languages=None)[source]

For a particular page, parse out download links

Will look through the page to find various links (base game, DLC, updates) per download site and add them to a dictionary

Parameters:
  • soup (bs4.BeautifulSoup) – soup object to parse

  • dl_sites (list) – List of download sites in preference order

  • dl_mappings (dict) – Dictionary of mappings for download types

  • regions (list) – list of regions potentially parse. Defaults to None, which will use an empty list

  • languages (dict) – list of languages potentially parse. Defaults to None, which will use an empty dict

  • regionless_titles (list) – list of titles that have no region info. Defaults to None, which will use an empty list

  • implied_languages (dict) – Dictionary of mappings from regions to implied languages. Defaults to None, which will use an empty dict

nxbrew_dl.util.get_game_dict(general_config, regex_config, nxbrew_url)[source]

Download the game index, and parse relevant info out of it

Parameters:
  • general_config (dict) – General configuration

  • regex_config (dict) – Regex configuration

  • nxbrew_url (string) – NXBrew URL

nxbrew_dl.util.get_game_name(f, nsp_xci_variations)[source]

Get game name, which is normally up to “Switch NSP”, but there are some edge cases

Parameters:
  • f (str) – Name

  • nsp_xci_variations (list) – List of potential NSP/XCI name variations

nxbrew_dl.util.get_html_page(url, cache=False, cache_filename='index.html')[source]

Get an HTML page as a soup

Parameters:
  • url (string) – URL

  • cache (bool) – If True, will save the game index as a cache. Defaults to False

  • cache_filename (string) – Filename to cache file to. Defaults to “index.html”

nxbrew_dl.util.get_languages(soup, lang_dict)[source]

Parse languages from a soup

Parameters:
  • soup (bs4.BeautifulSoup) – soup object to find languages in

  • lang_dict (dict) – Dictionary of languages

nxbrew_dl.util.get_thumb_url(soup)[source]

Parse thumbnail URL from a soup

Parameters:

soup (bs4.BeautifulSoup) – soup object to find languages in

nxbrew_dl.util.load_json(file)[source]

Load json file

Parameters:

file (str) – Path to JSON file

nxbrew_dl.util.load_yml(f)[source]

Load YAML file

Parameters:

f (str) – Path to YAML file

nxbrew_dl.util.save_json(data, out_file, sort_key=None)[source]

Save json in a pretty way

Parameters:
  • data (dict) – Data to be saved

  • out_file (str) – Path to JSON file

  • sort_key (str) – Key within each dictionary entry to sort by. Default is None, which will not sort.

nxbrew_dl.util.save_yml(f, data)[source]

Save YAML file

Parameters:
  • f (str) – Path to YAML file

  • data (dict) – Data to be saved