Spaces:
Sleeping
Sleeping
Update dl.py
Browse files
dl.py
CHANGED
@@ -32,7 +32,7 @@ def show_f(repo,name,token):
|
|
32 |
f_ist = (api.list_repo_files(repo_id=f'{repo}/{name}', repo_type="space"))
|
33 |
print (f_ist)
|
34 |
file_list = []
|
35 |
-
file_out = []
|
36 |
if not os.path.exists(name):
|
37 |
os.makedirs(name)
|
38 |
|
@@ -64,17 +64,31 @@ def show_f(repo,name,token):
|
|
64 |
pf=d_app.split(".",1)[0]
|
65 |
f_name=f'{pf}.{sf}'
|
66 |
pass
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
with ZipFile(f"{name}.zip", "w") as zipObj:
|
80 |
for idx, file in enumerate(f_ist):
|
|
|
32 |
f_ist = (api.list_repo_files(repo_id=f'{repo}/{name}', repo_type="space"))
|
33 |
print (f_ist)
|
34 |
file_list = []
|
35 |
+
#file_out = []
|
36 |
if not os.path.exists(name):
|
37 |
os.makedirs(name)
|
38 |
|
|
|
64 |
pf=d_app.split(".",1)[0]
|
65 |
f_name=f'{pf}.{sf}'
|
66 |
pass
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
if ".png" or ".jpg" or ".gif" or ".webm" or ".mp4" in f_name:
|
71 |
+
#html_text += f'<object data="https://huggingface.co/spaces/{repo}/{name}/raw/main/{d_app}"'
|
72 |
+
#out_text = "Image File"
|
73 |
+
sav_im = Image.open(f"https://huggingface.co/spaces/{repo}/{name}/raw/main/{d_app}")
|
74 |
+
sav_im.save(f'{name}/{f_name}')
|
75 |
+
file_list.append(Path(f'{name}/{f_name}'))
|
76 |
+
#file_out.append(f"https://huggingface.co/spaces/{repo}/{name}/raw/main/{d_app}")
|
77 |
+
|
78 |
+
|
79 |
+
|
80 |
+
else:
|
81 |
+
r = requests.get(f'https://huggingface.co/spaces/{repo}/{name}/raw/main/{d_app}')
|
82 |
+
print(d_app)
|
83 |
+
#print (r.text)
|
84 |
+
uid = uuid.uuid4()
|
85 |
+
|
86 |
+
|
87 |
+
file = open(f'{name}/{f_name}','w')
|
88 |
+
file.writelines(r.text)
|
89 |
+
file.close()
|
90 |
+
file_list.append(Path(f'{name}/{f_name}'))
|
91 |
+
#file_out.append(d_app)
|
92 |
|
93 |
with ZipFile(f"{name}.zip", "w") as zipObj:
|
94 |
for idx, file in enumerate(f_ist):
|