diff --git a/gen_mirror_json.py b/gen_mirror_json.py index 5498d4e..f8a72b2 100644 --- a/gen_mirror_json.py +++ b/gen_mirror_json.py @@ -25,18 +25,23 @@ sha256 = hashlib.sha256() for buf in iter(lambda : data.read(128 * 1024), b''): sha256.update(buf) + + BASE_PATH = "home/user/updater/builds/" + filepath = filename + try: with zipfile.ZipFile('{}{}'.format(BASE_PATH, filepath), 'r') as update_zip: - build_prop = update_zip.read('system/build.prop').decode('utf-8') - timestamp = int(re.findall('ro.build.date.utc=([0-9]+)', build_prop)[0]) - except: + build_prop = update_zip.read('META-INF/com/android/metadata').decode('utf-8') + timestamp = (re.findall('post-timestamp=([0-9]+)', build_prop)[0]) + except Exception as e: + print(e) timestamp = int(mktime(datetime.strptime(builddate, '%Y%m%d').timetuple())) builds.setdefault(device, []).append({ 'sha256': sha256.hexdigest(), 'size': os.path.getsize(f), 'date': '{}-{}-{}'.format(builddate[0:4], builddate[4:6], builddate[6:8]), - 'datetime': timestamp, + 'datetime': int(timestamp), 'filename': filename, 'filepath': f.replace(FILE_BASE, ''), 'version': version,