Scripts used to grab or read stats in RoK
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ashton Charbonneau 99c74903b7 Add bounding box debug image 2 years ago
.gitignore Add top 300 power mode 2 years ago
README.md Initial commit 3 years ago
rok-reader.py Add bounding box debug image 2 years ago
rok-stat-grabber.py Add top 300 power mode 2 years ago

README.md

rok-stat-grabber

The grabber iterates through entries in the individual power rankings and takes screenshots of each profile page (main profile page, the more info page, and the more info page with kills expanded). It will also copy the username into usernames.txt.

Some profiles cannot be clicked. These are skipped, and a screenshot is saved along with the skipped rank.

Each profile is given a timestamp that is common to the three screenshot files and the line in usernames.txt. The timestamp can be used to associate individual accounts.

Setup

Connect to an Android device via ADB. If connecting to a physical device, I would recommend using scrcpy with the --turn-screen-off flag to help prevent the device from heating up. If using an emulator, follow instructions for that emulator to connect via ADB. Get the device serial with adb devices.

This script uses AdbClipboard and the accompanying app to pull the clipboard containing the username. This only works until android 9. If running scrcpy, the clipboard grabs on the device are pushed to your computer, which could be annoying.

If running the script script on multiple accounts in parallel, I would recommend using different project names to avoid collisions in in the timestamp. It’s also likely prudent to overlap the rankings a bit if running in parallel.

The script terminates if it is unable to access a profile three times in a row. Could cause issues if there is a large amount of migration; I would recommend occasionally checking progress.

Usage

Open the individual rankings to either the top of the list (if starting with rank 1), or to the profile page of whatever rank you are starting with. Run with the needed command line options:

  • --project (required): what folder should the scraped files be saved in?
  • --serial (required): serial number of the device from adb devices.
  • --count (required): what rank should you stop at?
  • --start: what rank are you starting with? The script taps in a different spot for the first 4 ranks compared to others, and this defaults to rank 1.
  • --verbose: show progress output.

Examples

Grab ranks 1-990 (start at top of list, or with profile of rank 1 open): python rok-stat-grabber.py -p "KVK4_Pass5" -s "SERIAL123456" -c 990 -v

Grab ranks 801-990 (start with profile of rank 801 open): python rok-stat-grabber.py -p "KVK1_MGE" -v -s "SERIAL123456" -c 990 -n 801

Troubleshooting

  • Check
    • ADB issues
    • Device resolution
    • Screen rotation
    • Android version (for clipboard)
  • ??? (TODO)

Todo

  • Currently only works on devices with 1440x2560 resolution. Change coordinates from absolute values to percentages to support other sizes. Grab screen size via adb or command line.
  • Correct for screen rotation on devices. Currently uses the ROTATE variable (have used 0 and 90 on different devices).
  • Skip your own rank if the scraping account is included in top 1000.
  • Draw a box around skipped profiles in screenshot to make it easier to see them.
  • Support scraping the last ~990-1000 rankings.
  • Remove serial requirement if only a single device is connected, or choose from a list.
  • More checks to ensure you are on the correct page.
  • Better tesseract config.
  • Better logging and debug notes.
  • Check/catch errors.
  • Add screenshots to README.
  • Don’t force the folder structure.
  • Make sleep time random or adjustable or something.
  • Replace AdbClipboard with something that works with newer versions of Android.
  • Better handling when quitting.
  • Compress the images (optipng run in parallel or something?).
  • Probably some usernames are problematic and should be escaped.
  • I think when it skips more than one profile in a row, the rank number in the screenshot of the skipped profile doesn’t increment properly, but I might have already fixed that. Will check next time.
  • Support for iOS has tricky requirements (maybe requires jailbreak) but structure would be similar.