Skip to content

Instantly share code, notes, and snippets.

@rfletchr
Last active February 20, 2024 12:12
Show Gist options
  • Save rfletchr/51552af2aac4eb9a6a5dc9ae886592a4 to your computer and use it in GitHub Desktop.
Save rfletchr/51552af2aac4eb9a6a5dc9ae886592a4 to your computer and use it in GitHub Desktop.
download the movies from a shotgrid playlist
import tank
import os
auth = tank.authentication.ShotgunAuthenticator()
user = auth.get_user()
sg = user.create_sg_connection()
playlist_ids = [23024]
playlists = sg.find("Playlist", [["id", "in", playlist_ids]], ["code", "versions"])
versions_ids = {
v["id"]
for p in playlists
for v in p["versions"]
}
versions = sg.find(
"Version",
[["id", "in", list(versions_ids)]],
["code", "sg_uploaded_movie"],
)
root = "/mnt/projects/movies/name"
for i, version in enumerate(versions):
print(f"download {i+1} of {len(versions)}")
local_file_path = os.path.join(root, version["code"])
shotgun.download_attachment(version["sg_uploaded_movie"], file_path=local_file_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment