forked from eddie3/gogrepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobals.py
91 lines (78 loc) · 3.2 KB
/
globals.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
91
import sys
import logging
import http.cookiejar as cookiejar
import html5lib
# lib mods
cookiejar.MozillaCookieJar.magic_re = r'.*' # bypass the hardcoded "Netscape HTTP Cookie File" check
# filepath constants
GAME_STORAGE_DIR = r'.'
COOKIES_FILENAME = r'gog-cookies.dat'
MANIFEST_FILENAME = r'gog-manifest.dat'
SERIAL_FILENAME = r'!serial.txt'
INFO_FILENAME = r'!info.txt'
# configure logging
logFormatter = logging.Formatter("%(asctime)s | %(message)s", datefmt='%H:%M:%S')
rootLogger = logging.getLogger('ws')
rootLogger.setLevel(logging.DEBUG)
consoleHandler = logging.StreamHandler(sys.stdout)
consoleHandler.setFormatter(logFormatter)
rootLogger.addHandler(consoleHandler)
# logging aliases
info = rootLogger.info
warn = rootLogger.warning
debug = rootLogger.debug
error = rootLogger.error
log_exception = rootLogger.exception
treebuilder = html5lib.treebuilders.getTreeBuilder('etree')
parser = html5lib.HTMLParser(tree=treebuilder, namespaceHTMLElements=False)
# GOG URLs
GOG_HOME_URL = r'https://www.gog.com'
GOG_ACCOUNT_URL = r'https://www.gog.com/account'
GOG_LOGIN_URL = r'https://login.gog.com/login_check'
# GOG Constants
GOG_MEDIA_TYPE_GAME = '1'
GOG_MEDIA_TYPE_MOVIE = '2'
# HTTP request settings
HTTP_FETCH_DELAY = 1 # in seconds
HTTP_RETRY_DELAY = 5 # in seconds
HTTP_RETRY_COUNT = 3
HTTP_GAME_DOWNLOADER_THREADS = 4
HTTP_PERM_ERRORCODES = (404, 403, 503)
# Save manifest data for these os and lang combinations
DEFAULT_OS_LIST = ['windows']
DEFAULT_LANG_LIST = ['en']
# These file types don't have md5 data from GOG
SKIP_MD5_FILE_EXT = ['.txt', '.zip']
# Language table that maps two letter language to their unicode gogapi json name
LANG_TABLE = {'en': 'English', # English
'bl': '\u0431\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438', # Bulgarian
'ru': '\u0440\u0443\u0441\u0441\u043a\u0438\u0439', # Russian
'gk': '\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac', # Greek
'sb': '\u0421\u0440\u043f\u0441\u043a\u0430', # Serbian
'ar': '\u0627\u0644\u0639\u0631\u0628\u064a\u0629', # Arabic
'br': 'Portugu\xeas do Brasil', # Brazilian Portuguese
'jp': '\u65e5\u672c\u8a9e', # Japanese
'ko': '\ud55c\uad6d\uc5b4', # Korean
'fr': 'fran\xe7ais', # French
'cn': '\u4e2d\u6587', # Chinese
'cz': '\u010desk\xfd', # Czech
'hu': 'magyar', # Hungarian
'pt': 'portugu\xeas', # Portuguese
'tr': 'T\xfcrk\xe7e', # Turkish
'sk': 'slovensk\xfd', # Slovak
'nl': 'nederlands', # Dutch
'ro': 'rom\xe2n\u0103', # Romanian
'es': 'espa\xf1ol', # Spanish
'pl': 'polski', # Polish
'it': 'italiano', # Italian
'de': 'Deutsch', # German
'da': 'Dansk', # Danish
'sv': 'svenska', # Swedish
'fi': 'Suomi', # Finnish
'no': 'norsk', # Norsk
}
VALID_OS_TYPES = ['windows', 'linux', 'mac']
VALID_LANG_TYPES = list(LANG_TABLE.keys())
ORPHAN_DIR_NAME = '!orphaned'
ORPHAN_DIR_EXCLUDE_LIST = [ORPHAN_DIR_NAME, '!misc']
ORPHAN_FILE_EXCLUDE_LIST = [INFO_FILENAME, SERIAL_FILENAME]