# To download 100 (or fewer, if there aren't enough) artworks of the search term "game of thrones", call
# python3 grab-search.py "game of thrones" 100
# If max-projects isn't specified, it will fetch them all (beware! i really mean ALL! At this time, this would be over 12000 projects for our game of thrones example).
lastPageReached=page_num_projects<50# Each full page contains 50 projects. If it has less than 50, it is the last page
ifnotlastPageReached:
pageCounter=pageCounter+1
logMsg(f"Found {result_size} projects total (all pages). Of this {page_num_projects} on this page...","okndl",search_terms_filename)
else:
logMsg(f"Found {result_size} projects total (all pages). Of this {page_num_projects} on this page... This is the last page!","okndl",search_terms_filename)
# For each project in all of the artists projects
forprojectinprojects:
ifprojectCounter>=max_projects:
logMsg(f"Reached project download limit of {max_projects}. Stopping...","okndl",search_terms_filename)
logMsg(f"Found project '{project_name}' of artist '{project_artist_name_fullname}' (user-id=[{project_artist_name}]) with project id {project_hash_id}. Fetching more info about it...","okndl",search_terms_filename)
logMsg(f"Found image-asset for project '{project_name}' [{project_hash_id}] of artist '{project_artist_name_fullname}' (user-id=[{project_artist_name}]) at position {asset_position}. Downloading to '{filename}'...","okdl",search_terms_filename)
# Download it
downloadMedia(asset_image_url,filename)
else:
logMsg(f"Found non-image-asset for project '{project_name}' [{project_hash_id}] of artist '{project_artist_name_fullname}' (user-id=[{project_artist_name}]) at position {asset_position}. Skipping...","okdl",search_terms_filename)
# After downloading all assets, mark the project as downloaded.
logMsg(f"Skipping project '{project_name}' [{project_hash_id}] of artist '{project_artist_name_fullname}' (user-id=[{project_artist_name}]) because it is already downloaded.","okndl",search_terms_filename)