Backup a specific binary release version of V2Ray.
Last active
October 5, 2018 10:58
-
-
Save jinyu121/f32724fa5993e4a4151f0f3fb19b68ba to your computer and use it in GitHub Desktop.
V2Ray backup
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
import os | |
import subprocess | |
from argparse import ArgumentParser | |
from urllib.request import urlretrieve | |
BASE_URL = "https://github.com/v2ray/v2ray-core/releases/download/{version}/{filename}" | |
parser = ArgumentParser() | |
parser.add_argument('version', type=str, help='Version') | |
version = parser.parse_args().version | |
os.makedirs(version, exist_ok=True) | |
urlretrieve(BASE_URL.format(version=version, filename="metadata.txt"), os.path.join(version, "metadata.txt")) | |
for line in open(os.path.join(version, "metadata.txt")): | |
if ".zip" in line: | |
try: | |
filename = line.replace("File:", "").strip() | |
print(version, filename) | |
urlretrieve(BASE_URL.format(version=version, filename=filename), os.path.join(version, filename)) | |
except: | |
print("Fail:", line) | |
cmd = ["7z", "a", version + ".7z", version, "-sdel"] | |
subprocess.run(cmd, stdout=subprocess.DEVNULL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment