cosmo / funtion.py
tripleS-Dev
start
14ea209
raw
history blame contribute delete
No virus
1.43 kB
import cosmo
import get_token
import os
import shutil
import search
import cosmo2hex
import sum
import concurrent.futures
def download_image(token_id, folder_name):
cosmo.download_img(token_id, folder_name)
def download(folder_name, Range=9):
adress = cosmo2hex.adress_search(folder_name)
token_ids = get_token.get_nfts(adress, Range)
if os.path.exists(folder_name):
shutil.rmtree(folder_name)
os.makedirs(folder_name)
muti(folder_name, token_ids)
sum.create_collage_image(folder_name, token_ids, 1, Range)
def download_sort(folder_name, Range=9, txt=None):
adress = cosmo2hex.adress_search(folder_name)
token_ids = get_token.get_nfts(adress, 10000)
if os.path.exists(folder_name):
shutil.rmtree(folder_name)
os.makedirs(folder_name)
muti(folder_name, token_ids)
sort_index = search.search_in_metadata(folder_name, txt)
sum.create_collage_image(f"{folder_name}_sort", sort_index, 1, Range)
print(txt)
def muti(folder_name, token_ids):
with concurrent.futures.ThreadPoolExecutor() as executor:
futures = [executor.submit(download_image, token_id, folder_name) for token_id in token_ids]
for future in concurrent.futures.as_completed(futures):
try:
future.result() # To raise any exceptions caught during download
except Exception as e:
print(f"An error occurred: {e}")