Created
January 7, 2015 21:42
-
-
Save neomelonas/2dc041d83a42b6a63f3d to your computer and use it in GitHub Desktop.
UGC Whitelist Checker - grab updates to whitelists!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os, time, string, datetime, sys | |
from stat import * # ST_SIZE etc | |
import requests | |
cfgs = '/path/to/configs/' | |
# Make sure both arrays are the same length and in the same order. | |
ugc_links = [ | |
"http://ugcleague.com/files/configs/6v6_whitelist/item_whitelist_ugc_6v6.txt", | |
"http://ugcleague.com/files/configs/4v4_whitelist/item_whitelist_ugc_4v4.txt", | |
"http://ugcleague.com/files/configs/HL_whitelist/item_whitelist_ugc_HL.txt" | |
] | |
local_links = [ | |
cfgs + 'item_whitelist_ugc_6v6.txt', | |
cfgs + 'item_whitelist_ugc_4v4.txt', | |
cfgs + 'item_whitelist_ugc_HL.txt' | |
] | |
for arg in sys.argv: | |
if arg.lower() == "6s": | |
lid = 0 | |
elif arg.lower() == "4s": | |
lid = 1 | |
elif arg.lower() == "hl": | |
lid = 2 | |
r = requests.get(ugc_links[lid]) | |
r_g = r.headers['last-modified'] | |
ugc = datetime.datetime.strptime(r_g,'%a, %d %b %Y %H:%M:%S %Z') | |
st = os.stat(local_links[lid]) | |
w = datetime.datetime.fromtimestamp(st[ST_MTIME]) | |
if ugc-w > datetime.timedelta(1): | |
print ugc-w | |
f = open('local_links[lid]','w') | |
f.write(r.text) | |
f.close() | |
print 'Whitelist updated.' | |
else: print 'There is no update to this whitelist.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment