Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
imcgeoch committed Dec 5, 2013
1 parent e467f85 commit 6abe910
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@ twic_update
===========

A bash script for updating a Scid database with the newest games from The Week in Chess


This script downloads the newest group of games from www.theweekinchess.com and enters them into a scid database. It can be used with cron to automatically keep your database current.
It also keeps a copy of each week's games in a seperate folder. These aren't needed for the database to function but may be of interest. They also provide evidence of which weeks have been downloaded.


By default, twic-update uses a the directory ~/Chess, a database called Database, and drops pgns into the directory ~/Chess/TWIC. These must exist for the script to function. They can be changed by editing lines 3-6 in twic_update.sh

twic_update requires curl and (obviously) scid.
30 changes: 30 additions & 0 deletions twic_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

DIRECTORY=~/Chess
DATABASE=Database
SAVEDIRECTORY=TWIC

# The temporary name of downloaded file

TEMP=/tmp/twic.zip

# The latest week number for which a pgn file has been published
WEEK_NUM=`curl -s http://www.theweekinchess.com/twic | grep -m 1 g.zip | sed 's/^.*twic//' | sed 's/g.zip.*//'`


clear
echo "Getting TWIC #"$WEEK_NUM" from www.theweekinchess.com/twic"
echo

#Gets file from online
curl -o $TEMP "http://www.theweekinchess.com/zips/twic"$WEEK_NUM"g.zip"

#Unzips file
unzip $TEMP -d /tmp

#adds to SCID
sc_import $DIRECTORY"/"$DATABASE "/tmp/twic"$WEEK_NUM".pgn"

#cleanup
rm $TEMP
mv "/tmp/twic"$WEEK_NUM".pgn" $DIRECTORY"/"$SAVEDIRECTORY

0 comments on commit 6abe910

Please sign in to comment.