Scraping and downloading assets for a given project

Hi there. I’m attempting to build a script that will automatically download the assets (or download only new assets that haven’t been downloaded yet) for a given project.

The plan is then to be able to use that repository of downloaded assets to share with a team of editors on a local drive.

Essentially the functionality I’m after is a bit like watch folders but with a bit more flexibility and for platforms other than Mac.

I’ve managed to return a list of project IDs based on their names in my workspace but I’m struggling with how to scrape a list of assets from them. I’ve had limited success with the asset scraper in the python API but I’m struggling to work out which elements I need to extract for my purpose.

I’ve also been trying to use the fetch child assets API call but it seems to only work on folders rather than projects themselves.

Is there a way to return the assets for a given project(s) via their IDs or am I going about this wrong?

Hi there, this sounds like an interesting project!

There’s already something out there that does something similar, which I contribute to here and there.

When you’re fetching child assets for a project, you just need to get the root_folder_id of the project, which is the root folder of the project, and then list the containing items. What you’re writing is actually a recursive function then which looks inside each folder for assets and sub-folders. If it finds a sub-folder then it runs the same function again, and again until there are no more sub-folders to check.

Here’s an example of what that recursive function looks like, but I don’t think it works perfectly, hence why this version isn’t fully released on PyPI just yet.