Python scripts for interacting with planets.nu
Requires python to be installed on the computer: https://www.python.org/downloads/
usage: pull_messages.py [-h] [--format {csv,mbox}] [--username USERNAME] [--password PASSWORD] GAMEID
GAMEID
is the 6-digit numeric game number that can be found in game history or in the URL of the game.
CSV format is the default. For finished games, you only need to give the GAMEID
value to the script. For games still in progress, your planets.nu USERNAME and PASSWORD are also required.
python pull_messages.py --username USERNAME --password PASSWORD GAMEID
When using the CSV format, the script will:
a) check that the game exists. If the game is still in progress, it will login
b) create a game_data/tmp local folder and download the game_data into the folder as a zip file
c) unzip the file into game_data/tmp
d) extract all of the messages and export them into messages_[GAMEID].csv
file. The csv file can be opened using any text editor or Excel/Excel-like program
e) remove the files from game_data/tmp to save disk space
i) the zip file will remain in game_data folder. It can be deleted
When pulling messages for a game in mbox format, it's then possible to import the mbox file into an e-mail reader to read the in-game messages. When using mbox format, you need to give the following parameters to the script:
python pull_messages.py --format mbox --username USERNAME --password PASSWORD GAMEID
The script will:
a) log in to planets.nu with the given username and password
b) fetch all messages for all races in the game
c) extract all the messages in mbox format to messages_[GAMEID].mbox
file. The file can be imported to an e-mail program such as Thunderbird or Outlook. (Thunderbird requires a plugin, such as "ImportExportTools NG" to import mbox files).
NOTE: It's possible that not all messages are fetched when using the mbox format. For example, for Capricorn war, only about the most recent 150 turns worth of messages was received when testing this script.
- Install Python 3 from https://www.python.org/downloads/windows/
NOTE: During installation, you need to check
Add Python to PATH
. Otherwise, you may have to specify the full path to python.exe when running it from the command line. It is also recommended to check the option to install thepip
utility, which will help you install missing python modules. - Download the nu_python_scripts code as ZIP and unzip in a local folder (C:\Users\XXX\nu_python_scripts-main for this example)
- Launch Windows Command Prompt
- Change directory to where you unzipped the code
cd C:\Users\XXX\nu_python_scripts-main
- Try running
python pull_messages.py
- If there is an Error message
No module named ...
you can install that module using thepip
utility. In this example, the modulerequests
was missing and it was installed with
pip install requests
- Run the script with the GAME# of the Libra War
python pull_messages.py 267580
Note: A few of the turns failed to parse for an unknown reason
- Upload
C:\Users\XXX\nu_python_scripts-main\messages_267580.csv
into Google Docs and change the column width to something more reasonable - Enjoy all of the in-game communications from the Libra War in a more accessible format
- Run the script with the
GAMEID
of the Libra War with additional arguments, including your planets.nu USERNAME and PASSWORD:
python pull_messages.py 267580 --format mbox --username USERNAME --password PASSWORD
- Install Thunderbird Email client and launch it
- Unfortunately, there is no way to import messages into Thunderbird without setting up an account. You can either set it up with a real account or a bogus account. To use a bogus account, fill out
Your name
andEmail address
fields, clickConfigure Manually
,Advanced Config
and then disableCheck for new messages at startup
andCheck for new messages every...
tickboxes - In Thunderbird
Add-ons
menu search forImportExportTools NG
and clickAdd to Thunderbird
- On the left-hand side, right click on
Local Folders
and selectImportExportTools NG
->Import mbox file
->Import directly one or more mbox files
->OK
- Choose the file generated by the script:
C:\Users\XXX\nu_python_scripts-main\messages_267580.mbox
- You should now have a folder with thousands of messages from the game. They can be grouped by conversations, sorted and searched