cleaned up
This commit is contained in:
parent
67d3189bfe
commit
2c9e4f5986
@ -17,8 +17,14 @@ def playerArchives(username):
|
||||
url = f"https://api.chess.com/pub/player/{username}/games/archives"
|
||||
archive = requests.get(url, headers=headers).json()['archives']
|
||||
|
||||
file_path = os.getcwd()
|
||||
file_name = os.path.join(file_path, username+'_archive.txt')
|
||||
try:
|
||||
cwd = os.getcwd()
|
||||
path = os.path.join(cwd, 'archives')
|
||||
os.makedirs(path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
file_name = os.path.join(path, username+'_archive.txt')
|
||||
with open(file_name, 'w') as f:
|
||||
json.dump(archive, f)
|
||||
|
||||
@ -48,12 +54,6 @@ def playerMonthly(url=None):
|
||||
# Multithreaded games download
|
||||
def threddGames(username=None, archive=None):
|
||||
|
||||
try:
|
||||
path = os.getcwd()+'/archives'
|
||||
os.makedirs(path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if archive:
|
||||
with open(archive) as f:
|
||||
archive = json.load(f)
|
||||
|
Loading…
Reference in New Issue
Block a user