Skip to content

Downloader

codemicro edited this page Jan 19, 2020 · 5 revisions

Purpose

The purpose of the Downloader is to download mods from Nexusmods, upload them and modify the state of the database accordingly.

Setup

  1. Install Python packages from requirements.txt

  2. Ensure Rclone is in your PATH

  3. Setup a remote for Nexusmods in Rclone

  4. Obtain one or more Nexusmods API keys from https://www.nexusmods.com/users/myaccount?tab=api. Use the field named Personal API Key. If you wish to use more than one API key to avoid ratelimiting delays, you must register multiple Nexus accounts. Each account requires a unique email address.

  5. Duplicate the file settings.example.json from the repository root and rename it settings.json. This is where all your credentials will be stored (the filename settings.json has been added to .gitignore). Fill in the fields as follows (if you are only using one Nexus API key, leave it in the array anyway):

    {
      "endpoint": "https://www.tdpain.net/nexusapi/",
      "auth_key": "put your internal auth key here",
      "game": "skyrim",
      "download_folder": "downloads",
      "nexus_keys": [
        "put your nexus api keys in this list here"
      ],
      "rclone": {
        "enable": true,
        "remote_name": "target rclone remote",
        "directory": "downloads",
        "show_progress": false
      }
    }

    endpoint and rclone>directory should remain unchanged. Even if rclone>enable is set to false, all fields in the rclone section must exist.

  6. Run the downloader. For the first mod the script tries to download, it will ask you what download server to use. After each run, you should check the error.log file the script creates to check if the script stopped prematurely, and if so, why.

Script rundown

download.py is the script you want to run for this. If begins by defining some functions, initialising Loguru, loading settings and initialising the key switcher.

It then begins the download sequence. It will make a request to the internal API, and depending on the response, wait for 30 seconds, or move on to downloading the file. If it moves on, the download link is requested from Nexus, and downloaded. While downloading, it is compressed and when the download is completed, uploaded to the specified remote using Rclone. Once this has been done, the internal API is informed the download has succeeded, and the sequence restarts.

common.py is just used for some fancy coloured printing.

Clone this wiki locally