stlaurentjr commited on
Commit
8ed5915
1 Parent(s): bc928e4

Update scripts/mainrunpodA1111.py

Browse files
Files changed (1) hide show
  1. scripts/mainrunpodA1111.py +65 -42
scripts/mainrunpodA1111.py CHANGED
@@ -540,48 +540,6 @@ def save(Huggingface_Write_token):
540
  else:
541
  print('Nothing to backup')
542
 
543
-
544
-
545
-
546
- def getsrc(url):
547
-
548
- parsed_url = urlparse(url)
549
-
550
- if parsed_url.netloc == 'civitai.com':
551
- src='civitai'
552
- elif parsed_url.netloc == 'drive.google.com':
553
- src='gdrive'
554
- elif parsed_url.netloc == 'huggingface.co':
555
- src='huggingface'
556
- else:
557
- src='others'
558
- return src
559
-
560
-
561
-
562
- def get_name(url, gdrive):
563
-
564
- from gdown.download import get_url_from_gdrive_confirmation
565
-
566
- if not gdrive:
567
- response = requests.get(url, allow_redirects=False)
568
- if "Location" in response.headers:
569
- redirected_url = response.headers["Location"]
570
- quer = parse_qs(urlparse(redirected_url).query)
571
- if "response-content-disposition" in quer:
572
- disp_val = quer["response-content-disposition"][0].split(";")
573
- for vals in disp_val:
574
- if vals.strip().startswith("filename="):
575
- filenm=unquote(vals.split("=", 1)[1].strip())
576
- return filenm.replace("\"","")
577
- else:
578
- headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"}
579
- lnk="https://drive.google.com/uc?id={id}&export=download".format(id=url[url.find("/d/")+3:url.find("/view")])
580
- res = requests.session().get(lnk, headers=headers, stream=True, verify=True)
581
- res = requests.session().get(get_url_from_gdrive_confirmation(res.text), headers=headers, stream=True, verify=True)
582
- content_disposition = six.moves.urllib_parse.unquote(res.headers["Content-Disposition"])
583
- filenm = re.search('attachment; filename="(.*?)"', content_disposition).groups()[0]
584
- return filenm
585
  def download_and_install_config():
586
  target_directory = "/workspace/sd/stable-diffusion-webui/"
587
  config_url = (
@@ -739,7 +697,72 @@ def InstallWildCards():
739
 
740
  # Возвращаемся в исходную рабочую директорию
741
  os.chdir("/workspace")
 
742
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
743
 
744
 
745
  def done():
 
540
  else:
541
  print('Nothing to backup')
542
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
543
  def download_and_install_config():
544
  target_directory = "/workspace/sd/stable-diffusion-webui/"
545
  config_url = (
 
697
 
698
  # Возвращаемся в исходную рабочую директорию
699
  os.chdir("/workspace")
700
+ def getsrc(url):
701
 
702
+ parsed_url = urlparse(url)
703
+
704
+ if parsed_url.netloc == "civitai.com":
705
+ src = "civitai"
706
+ elif parsed_url.netloc == "drive.google.com":
707
+ src = "gdrive"
708
+ elif parsed_url.netloc == "huggingface.co":
709
+ src = "huggingface"
710
+ else:
711
+ src = "others"
712
+ return src
713
+
714
+
715
+ def get_true_name(url):
716
+ response = requests.get(url)
717
+ soup = BeautifulSoup(response.text, "html.parser")
718
+ title_tag = soup.find("title")
719
+ if title_tag:
720
+ title_text = title_tag.text
721
+ # Извлечение имени файла из тега title (предполагая, что имя файла указано в теге title)
722
+ file_name = title_text.split(" - ")[0]
723
+ return file_name
724
+ else:
725
+ raise RuntimeError("Could not find the title tag in the HTML")
726
+
727
+
728
+ def get_name(url, gdrive):
729
+
730
+ from gdown.download import get_url_from_gdrive_confirmation
731
+
732
+ if not gdrive:
733
+ response = requests.get(url, allow_redirects=False)
734
+ if "Location" in response.headers:
735
+ redirected_url = response.headers["Location"]
736
+ quer = parse_qs(urlparse(redirected_url).query)
737
+ if "response-content-disposition" in quer:
738
+ disp_val = quer["response-content-disposition"][0].split(";")
739
+ for vals in disp_val:
740
+ if vals.strip().startswith("filename="):
741
+ filenm = unquote(vals.split("=", 1)[1].strip())
742
+ return filenm.replace('"', "")
743
+ else:
744
+ headers = {
745
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"
746
+ }
747
+ lnk = "https://drive.google.com/uc?id={id}&export=download".format(
748
+ id=url[url.find("/d/") + 3 : url.find("/view")]
749
+ )
750
+ res = requests.session().get(lnk, headers=headers, stream=True, verify=True)
751
+ res = requests.session().get(
752
+ get_url_from_gdrive_confirmation(res.text),
753
+ headers=headers,
754
+ stream=True,
755
+ verify=True,
756
+ )
757
+ content_disposition = six.moves.urllib_parse.unquote(
758
+ res.headers["Content-Disposition"]
759
+ )
760
+ filenm = (
761
+ re.search(r"filename\*=UTF-8''(.*)", content_disposition)
762
+ .groups()[0]
763
+ .replace(os.path.sep, "_")
764
+ )
765
+ return filenm
766
 
767
 
768
  def done():