Spaces:
Running
Running
Commit
•
b189c01
1
Parent(s):
a3db9b4
Update app.py
Browse files
app.py
CHANGED
@@ -139,9 +139,35 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], url, progress=gr.Prog
|
|
139 |
raise gr.Error("something went wrong")
|
140 |
return "Model uploaded!"
|
141 |
|
142 |
-
def check_civit_link(url):
|
143 |
info, _ = process_url(url, download_files=False)
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
def swap_fill(profile: Optional[gr.OAuthProfile]):
|
146 |
if profile is None:
|
147 |
return gr.update(visible=True), gr.update(visible=False)
|
|
|
139 |
raise gr.Error("something went wrong")
|
140 |
return "Model uploaded!"
|
141 |
|
142 |
+
def check_civit_link(profile: Optional[gr.OAuthProfile], url):
|
143 |
info, _ = process_url(url, download_files=False)
|
144 |
+
url_creator = f"https://civitai.com/user/{info["creator"]}/models"
|
145 |
+
# Open the target URL
|
146 |
+
driver.get(url_creator)
|
147 |
+
|
148 |
+
# Define the XPath expression
|
149 |
+
xpath_expression = "//a[contains(@class, 'mantine-UnstyledButton-root') and contains(@class, 'mantine-ActionIcon-root') and contains(@class, 'mantine-ubxmi3') and starts-with(@href, 'https://huggingface.co/')]"
|
150 |
+
|
151 |
+
# Find the element using the XPath expression
|
152 |
+
try:
|
153 |
+
element = WebDriverWait(driver, 10).until(
|
154 |
+
EC.presence_of_element_located((By.XPATH, xpath_expression))
|
155 |
+
)
|
156 |
+
|
157 |
+
# Extract the href attribute
|
158 |
+
href = element.get_attribute("href")
|
159 |
+
|
160 |
+
# Extract the part after 'https://huggingface.co/'
|
161 |
+
extracted_part = href.replace("https://huggingface.co/", "")
|
162 |
+
|
163 |
+
except Exception as e:
|
164 |
+
print("Element not found or error occurred:", e)
|
165 |
+
|
166 |
+
finally:
|
167 |
+
driver.quit()
|
168 |
+
|
169 |
+
return extracted_part == profile.name
|
170 |
+
|
171 |
def swap_fill(profile: Optional[gr.OAuthProfile]):
|
172 |
if profile is None:
|
173 |
return gr.update(visible=True), gr.update(visible=False)
|