dbip-city-lite url changes, get latest url from download page

This commit is contained in:
j 2020-03-22 17:21:57 +01:00
parent 6f4bdebd88
commit 4cce468dae
1 changed files with 15 additions and 8 deletions

View File

@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import
import codecs
import os
import sys
import re
import shutil
import subprocess
import sys
import time
import codecs
from os.path import dirname, exists, join
from glob import glob
@ -399,12 +400,18 @@ def update_geoip(force=False):
path = os.path.join(settings.GEOIP_PATH, 'GeoLite2-City.mmdb')
if not os.path.exists(path) or force:
url = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz'
url = 'https://download.db-ip.com/free/dbip-city-lite-2020-01.mmdb.gz'
print('download', url)
ox.net.save_url(url, "%s.gz" % path)
if os.path.exists(path):
os.unlink(path)
os.system('gunzip "%s.gz"' % path)
index = ox.net.read_url('https://db-ip.com/db/download/ip-to-country-lite').decode()
match = re.compile('href=[\'"](http.*.mmdb.gz)').findall(index)
if match:
url = match[0]
print(url)
print('download', url)
ox.net.save_url(url, "%s.gz" % path)
if os.path.exists(path):
os.unlink(path)
os.system('gunzip "%s.gz"' % path)
else:
print('failed to download dbip-country-lite-2020-03.mmdb.gz')
def init():
if not settings.RELOADER_RUNNING: