This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcsgo-maps-overview.py
90 lines (80 loc) · 2.48 KB
/
csgo-maps-overview.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
import os
import sys
import time
import urllib
import requests
# https://www.online-convert.com
API_KEY = sys.argv[1]
API_URL = "http://api2.online-convert.com/jobs"
TYPE_IN = "dds"
TYPE_OUT = sys.argv[2]
HEADER = {
'x-oc-api-key': API_KEY,
'content-type': "application/json",
'cache-control': "no-cache"
}
API_REQUEST_WAIT = 15
FILE_URLS = sys.argv[3] # file with urls containing updated game files
LOCAL_DIR = "overviews"
FILES = [
'de_cache_radar',
'de_cache_radar_spectate',
'de_cbble_radar',
'de_dust2_radar',
'de_dust2_higher_radar',
'de_inferno_radar',
'de_mirage_radar',
'de_mirage_radar_spectate',
'de_nuke_radar',
'de_nuke_lower_radar',
'de_overpass_radar',
'de_train_radar',
'de_biome_radar',
'de_biome_radar_spectate',
'de_austria_radar',
'de_austria_radar_spectate',
'de_castle_radar',
'de_castle_radar_spectate',
'de_subzero_radar',
'de_vertigo_radar',
'de_vertigo_lower_radar',
'de_zoo_radar',
'de_zoo_radar_spectate',
'dz_blacksite_radar',
'dz_sirocco',
'dz_sirocco_radar',
'de_season_radar',
'de_season_radar_spectate'
]
print("Starting...")
remote_url = None
with open(FILE_URLS, "r") as f:
for line in f:
url = line.strip()
print("URL: " + url)
if requests.get(url + "de_dust2_radar.dds").status_code == 200:
remote_url = url
break
for filename in FILES:
payload = '{"input":[{"type":"remote","source":"' + remote_url + filename + '.' + TYPE_IN + '"}],"conversion":[{"category":"image","target":"' + TYPE_OUT + '"}]}'
response = requests.request("POST", API_URL, data=payload, headers=HEADER)
response_json = json.loads(response.text)
job_id = response_json['id']
result = False
while not result:
sys.stdout.write("\r\nWaiting")
for i in range(0, API_REQUEST_WAIT):
sys.stdout.write(".")
time.sleep(1)
response = requests.request("GET", API_URL + "/" + job_id, headers=HEADER)
response_json = json.loads(response.text)
if len(response.text):
if response_json['status']['code'] == 'completed':
result = True
download_url = response_json['output'][0]['uri']
print("Downloading: {}".format(download_url))
urllib.urlretrieve(download_url, "./overviews/{}.{}".format(os.path.splitext(filename)[0], TYPE_OUT))
print("Done.")