File size: 804 Bytes
939547e
85e8f07
 
939547e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d183ff1
939547e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import hashlib
import os

sha1s = {}


for root, dirs, files in os.walk("."):
    if ".git" in dirs:
        dirs.remove(".git")    
    for name in files:
        file_path = os.path.join(root, name)
        with open(file_path, "rb") as f:
            data = f.read()
            sha1 = hashlib.sha1(data).hexdigest()
            sha1s[file_path] = sha1


with open("dl.py", "w") as f:
    f.write("#!/usr/bin/env python\n\nimport os\nimport hashlib\n")
    for file_path, sha1 in sha1s.items():
        f.write(f"if not os.path.exists('{file_path}') or '{sha1}' != hashlib.sha1(open('{file_path}', 'rb').read()).hexdigest():\n")
        f.write(f"    os.system('curl -L \"https://huggingface.co/AI-Porn/AI-PORN/resolve/main/{file_path}\" --create-dirs -o \"./{file_path}\"')\n")