Created
December 25, 2018 00:03
-
-
Save IvarWithoutBones/1acb30df81710dd186bd185b64f7de87 to your computer and use it in GitHub Desktop.
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 github | |
import requests | |
import os.path | |
import shutil | |
import libarchive.public | |
from clint.textui import progress | |
g = github.Github() | |
def download(url, tag, yuzu_version): | |
print(f"Now downloading {yuzu_version}") | |
r = requests.get(url) | |
with open(f"yuzu_{tag}.7z", "wb") as f: | |
total_length = int(r.headers.get('content-length')) | |
for chunk in progress.bar(r.iter_content(chunk_size=1024), expected_size=(total_length/1024) + 1): | |
if chunk: | |
f.write(chunk) | |
f.flush() | |
print(f"Succesfully downloaded {yuzu_version}") | |
def extract(filename, yuzu_version, tag): | |
with open(f"yuzu_{tag}.7z", 'rb') as f: | |
for entry in libarchive.public.memory_pour(f.read()): | |
if str(entry) == "ArchiveEntry<NAME=[canary/] SIZE=(0)>": | |
pass | |
else: | |
print(f"extracted {str(entry).partition('[')[-1].rpartition(']')[0]}") | |
try: | |
os.rename("canary/", yuzu_version) | |
except OSError: | |
shutil.rmtree(yuzu_version) | |
os.rename("canary/", yuzu_version) | |
print(f"Succesfully extracted {yuzu_version}") | |
os.remove(f"yuzu_{tag}.7z") | |
print(f"Succesfully removed yuzu_{tag}.7z") | |
class main(): | |
repo = g.get_repo(f"yuzu-emu/yuzu-canary") | |
tag_name = repo.get_latest_release().tag_name | |
commit_hash = repo.get_latest_release().target_commitish[0:7] | |
created_at = str(repo.get_latest_release().created_at)[:10].replace("-", "") | |
yuzu_version = f"yuzu {tag_name}".replace("-", " ") | |
url = f"https://github.com/yuzu-emu/yuzu-canary/releases/download/{tag_name}/yuzu-linux-{created_at}-{commit_hash}.7z" | |
if os.path.isfile(f"yuzu_{tag_name}.7z") or os.path.isdir(yuzu_version): | |
tmp = input("You already have the latest yuzu canary version downloaded! Do you want to redownload it? Y/n\n") | |
if tmp.lower() == "y": | |
download(url, tag_name, yuzu_version) | |
extract(f"yuzu_{tag_name}", yuzu_version, tag_name) | |
elif tmp.lower() == "n": | |
print("Alright. Quiting the installer script") | |
else: | |
print("Invalid input. Quiting the installer script") | |
else: | |
download(url, tag_name, yuzu_version) | |
extract(f"yuzu_{tag_name}", yuzu_version, tag_name) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment