-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiles_service.py
More file actions
26 lines (20 loc) · 794 Bytes
/
files_service.py
File metadata and controls
26 lines (20 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import requests
from os import listdir
from os.path import isfile, join, getmtime
import helper
def load_game_from_microsofts_server(game_id, profile_id):
url = 'https://aoe.ms/replay/?gameId=' + game_id + '&profileId=' + profile_id
r = requests.get(url)
if 'text/plain' in r.headers['content-type'] and r.content.decode() == 'Match not found.':
return {'error': 'Match not found.'}
return {'data': r.content}
def check_games_locally(path, filter):
files = [f for f in listdir(path) if isfile(join(path, f)) and ".aoe2record" in f]
return files
def sanity_check_path_and_improve_if_needed(path):
path = path.replace('\\', '/')
if path[-1] != '/':
path += '/'
return path
def guess_playing_time_from_file(path):
return getmtime(path)