Code Monkey home page Code Monkey logo

ogsdownloader's Introduction

OGSDownloader

This is a simple command-line tool I developed to download the SGF files of games from an OGS profile. It will download the records of every available public game on the given profiles.

Basic Instructions

To use this tool, you will need Python 3.9 or higher. You can see here for how to download and install this for your respective OS. This is a command-line tool, to install it, type the following into the command-line:

python3 -m pip install ogsdownloader

This will install of the requirements and the tool itself. To use it to download all of your own games, enter the following command:

python3 -m ogsdownloader sgf_files -u <YOUR_USERNAME> -i --authorised

This will prompt for your username again, and then your password. Once you've provided your password, you shouldn't have to do so again since the tokens received will be saved in a configuration file and reused.

To download someone else's games, do the following command:

python3 -m ogsdownloader sgf_files -u <USERNAME>

Arguments and Options

The following is an explanation of the available arguments and options for the tool.

  • destination
    • The destination to which the files will be downloaded, this is required
    • Folder will be created if it doesn't already exist
  • --authorised
    • Use user authentication when making requests to OGS
    • This will enable downloading private games from the authenticated person's profile
  • --username
    • The username to authenticate with i.e. your username
  • -c, --config
    • The config file to use
    • If not supplied, the tool will default to the applications directory
  • -f, --format
    • The naming scheme for the files
    • By default, it is '{ID}'
    • See Name Formatting below for details
  • -i, --interactive
    • Whether to use interactive mode, prompting for username and password
    • Only useful when using an authorised instance
  • -s, --sleep
    • The time to sleep in seconds between making consecutive requests to OGS
    • Defaults to 5 seconds
    • See Rate Limiting below
  • -u, --user-id
    • The user ID or username of the profile to download from
    • Can be specified multiple times e.g. -u 1234 -u 5678
  • -v, --verbose
    • Increases the output of the program

Rate Limiting

OGS will cut off the downloads if too many requests are performed in too short a time. To prevent this, a sleep time is used to spread out the web requests. This is scraping etiquette. Be polite. Downloading games is not as important as playing them. OGS prioritises players, as they should. This tool takes traffic from the same servers; you can afford to wait a little longer, so keep the sleep time reasonable.

Name Formatting

The downloaded files can be titled according to several variables. These are:

  • NAME
  • ID
  • START
  • END
  • BLACK
  • WHITE

To be replaced, these keywords must be surrounded in brackets e.g. '{ID} {NAME} will include both the name and the ID in the filename.

Black and white in this case refer to the usernames of the players on the respective sides on the game. Similarly, the 'start' and 'end' variables will produce ISO formatted strings for the start and end of the game. If the game is still in progress at the time of download, then the 'end' variable will be replaced with 'Unknown' instead.

ogsdownloader's People

Contributors

serene-arc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jpyllman

ogsdownloader's Issues

'Namespace' object has no attribute 'unauthorised'

Installed the module via instructions, and ran the following:

python3 -m ogsdownloader ./ -u $my_username -i --authorised -v

Spat out:

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/dakota-marshall/.local/lib/python3.10/site-packages/ogsdownloader/__main__.py", line 124, in <module>
    entry()
  File "/home/dakota-marshall/.local/lib/python3.10/site-packages/ogsdownloader/__main__.py", line 120, in entry
    main(args)
  File "/home/dakota-marshall/.local/lib/python3.10/site-packages/ogsdownloader/__main__.py", line 72, in main
    if not config.has_option('DEFAULT', 'username') and not args.username and not args.unauthorised:
AttributeError: 'Namespace' object has no attribute 'unauthorised'. Did you mean: 'authorised'?

I removed and not args.unauthorised from the if statement, and it worked as expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.