Now fetches all pages of an artist. Not just the first one.
This commit is contained in:
parent
3a22f0346c
commit
13d7d37d1e
25
grab.py
25
grab.py
@ -184,11 +184,26 @@ Path("./logs/").mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
# Request project info for artist
|
||||
projects_data = requests.get(f"https://www.artstation.com/users/{artist_name}/projects.json", headers=project_fetch_headers)
|
||||
projects = projects_data.json()["data"]
|
||||
lastPageReached = False
|
||||
pageCounter = 1
|
||||
while not lastPageReached:
|
||||
logMsg(f"Fetching page {pageCounter} of {artist_name}...", "okndl")
|
||||
projects_data = requests.get(f"https://www.artstation.com/users/{artist_name}/projects.json?page={pageCounter}", headers=project_fetch_headers)
|
||||
projects = projects_data.json()["data"]
|
||||
|
||||
# For each project in all of the artists projects
|
||||
for project in projects:
|
||||
page_num_projects = len(projects)
|
||||
|
||||
lastPageReached = page_num_projects < 50 # Each full page contains 50 projects. If it has less than 50, it is the last page
|
||||
|
||||
if not lastPageReached:
|
||||
pageCounter = pageCounter + 1
|
||||
logMsg(f"Page contains {page_num_projects} projects...", "okndl")
|
||||
else:
|
||||
logMsg(f"Page contains {page_num_projects} projects... That's the last page!", "okndl")
|
||||
|
||||
|
||||
# For each project in all of the artists projects
|
||||
for project in projects:
|
||||
project_name = project["title"]
|
||||
project_hash_id = project["hash_id"]
|
||||
|
||||
@ -226,3 +241,5 @@ for project in projects:
|
||||
# Project is already downloaded
|
||||
else:
|
||||
logMsg(f"Skipping project {project_name} [{project_hash_id}] because it is already downloaded.", "okndl")
|
||||
|
||||
logMsg(f"Finished all pages of {artist_name}... Total pages of this artist scanned: {pageCounter}", "okndl")
|
||||
|
Loading…
x
Reference in New Issue
Block a user