Direct link to making a move in the first active game?

Hi,

I may have missed something, but I can’t find a link that takes me directly to the first active (correspondence) game. I often want to spawn a new Chromium window to make a move, rather than going first to the game list and selecting a game.

There’s a button in the top-right of the window showing me the number of games in which it’s my turn to move, but it’s not a standard link.

Is there a way to do this? What I’m really looking for is something that I can use at the command line to spawn the browser directly to a game window.

Unfortunately we don’t have a direct link I could give you to take you straight to your next game. This could be one of those things that would make a useful api tool, the following link will give you all of your games that haven’t ended:

https://online-go.com/api/v1/me/games/?ended__isnull=True

Fair enough. It should be easy enough to write a quick python wrapper that will extract the first game link from that page and spawn that.

It would be a good addition to the API, though!

Just for reference, here’s a python snippet that I’m using to open an active game. (This is pulled from an updated version of my py3status ogs notifier, so any oddities like the redirect to /dev/null are an artefact of that.)


from json import loads
from urllib.request import urlopen
from subprocess import call

PLAYER_ID=1504

# Redirect stdin/stdout to /dev/null
dn = open("/dev/null")

player_id = PLAYER_ID

# Get the active games list where it's my turn to move
ogs_games = urlopen('http://online-go.com/api/v1/players/' + str( player_id ) + '/full/')

# Parse to a dictionary
ogs_data = loads( ogs_games.read().decode('utf-8') )

# Get the list of active games
active_game_list = ogs_data['active_games']

# Step through the active games until one is found that has the PLAYER_ID to play
for game in active_game_list:
    if game['json']['clock']['current_player'] == player_id: 
        # Spawn Chromium at this game, then break
        url_arg = "--app=http://online-go.com/game/" + str(game['json']['clock']['game_id'])
        call(["chromium", url_arg ], stdin=dn, stdout=dn, stderr=dn )
        break

dn.close()
1 Like

Using the code format block of the forums :slight_smile:

from json import loadsfrom urllib.request import urlopenfrom subprocess import call

PLAYER_ID=1504

# Redirect stdin/stdout to /dev/nulldn = open("/dev/null")

player_id = PLAYER_ID

# Get the active games list where it's my turn to moveogs_games = urlopen('http://online-go.com/api/v1/players/' + str( player_id ) + '/full/')

# Parse to a dictionaryogs_data = loads( ogs_games.read().decode('utf-8') )

# Get the list of active gamesactive_game_list = ogs_data['active_games']

# Step through the active games until one is found that has the PLAYER_ID to playfor game in active_game_list:    if game['json']['clock']['current_player'] == player_id:         # Spawn Chromium at this game, then break        url_arg = "--app=http://online-go.com/game/" + str(game['json']['clock']['game_id'])        call(["chromium", url_arg ], stdin=dn, stdout=dn, stderr=dn )        break

dn.close()

Ah, I used the code block, but didn’t put the preformatted text block around it. Original post edited now, which is nice because it preserves Python’s irritating fixed indentation requirements.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.