Spaces:
Running
Running
Commit
·
e48859b
1
Parent(s):
90405d9
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,7 +21,7 @@ def get_json_data(url):
|
|
| 21 |
print(f"Error fetching JSON data: {e}")
|
| 22 |
return None
|
| 23 |
|
| 24 |
-
def check_nsfw(json_data, profile
|
| 25 |
if(profile.preferred_username in TRUSTED_UPLOADERS):
|
| 26 |
return True
|
| 27 |
if json_data["nsfw"]:
|
|
@@ -86,10 +86,10 @@ def download_file(url, filename, folder="."):
|
|
| 86 |
except requests.exceptions.RequestException as e:
|
| 87 |
raise gr.Error(f"Error downloading file: {e}")
|
| 88 |
|
| 89 |
-
def process_url(url, do_download=True, folder="."):
|
| 90 |
json_data = get_json_data(url)
|
| 91 |
if json_data:
|
| 92 |
-
if check_nsfw(json_data):
|
| 93 |
info = extract_info(json_data)
|
| 94 |
if info:
|
| 95 |
if(do_download):
|
|
@@ -179,7 +179,7 @@ def extract_huggingface_username(username):
|
|
| 179 |
|
| 180 |
|
| 181 |
def check_civit_link(profile: Optional[gr.OAuthProfile], url):
|
| 182 |
-
info, _ = process_url(url, do_download=False)
|
| 183 |
hf_username = extract_huggingface_username(info['creator'])
|
| 184 |
attributes_methods = dir(profile)
|
| 185 |
|
|
@@ -210,7 +210,7 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], url, progress=gr.Prog
|
|
| 210 |
|
| 211 |
folder = str(uuid.uuid4())
|
| 212 |
os.makedirs(folder, exist_ok=False)
|
| 213 |
-
info, downloaded_files = process_url(url, folder=folder)
|
| 214 |
create_readme(info, downloaded_files, folder=folder)
|
| 215 |
try:
|
| 216 |
api = HfApi(token=os.environ["HUGGING_FACE_HUB_TOKEN"])
|
|
|
|
| 21 |
print(f"Error fetching JSON data: {e}")
|
| 22 |
return None
|
| 23 |
|
| 24 |
+
def check_nsfw(json_data, profile):
|
| 25 |
if(profile.preferred_username in TRUSTED_UPLOADERS):
|
| 26 |
return True
|
| 27 |
if json_data["nsfw"]:
|
|
|
|
| 86 |
except requests.exceptions.RequestException as e:
|
| 87 |
raise gr.Error(f"Error downloading file: {e}")
|
| 88 |
|
| 89 |
+
def process_url(url, profile, do_download=True, folder="."):
|
| 90 |
json_data = get_json_data(url)
|
| 91 |
if json_data:
|
| 92 |
+
if check_nsfw(json_data, profile):
|
| 93 |
info = extract_info(json_data)
|
| 94 |
if info:
|
| 95 |
if(do_download):
|
|
|
|
| 179 |
|
| 180 |
|
| 181 |
def check_civit_link(profile: Optional[gr.OAuthProfile], url):
|
| 182 |
+
info, _ = process_url(url, profile, do_download=False)
|
| 183 |
hf_username = extract_huggingface_username(info['creator'])
|
| 184 |
attributes_methods = dir(profile)
|
| 185 |
|
|
|
|
| 210 |
|
| 211 |
folder = str(uuid.uuid4())
|
| 212 |
os.makedirs(folder, exist_ok=False)
|
| 213 |
+
info, downloaded_files = process_url(url, profile, folder=folder)
|
| 214 |
create_readme(info, downloaded_files, folder=folder)
|
| 215 |
try:
|
| 216 |
api = HfApi(token=os.environ["HUGGING_FACE_HUB_TOKEN"])
|