2

How can I access a specific Shotgun page through python?

For example, I would like to retrieve all the shotcodes from a saved page in Shotgun using a python script. Is this possible?

4 comments

  • 0
    Avatar
    Asi Sudai

    Don't have a final solution for this, but from digging quickly, here's what i found:

    1.find the page you're looking for, example id 8094

    2.find all the pageSettings linked to this page

    3.each pageSetting have a field called "settings_json" it's a string of dict, storing all the information.

    from there you would need to find the filters used in that page and copy them to your api call.

    I hope that can help you a little.

     

    page = sg3.find('Page', filters=[['id', 'is', 8094]] )[0]

    pageSettings = sg3.find('PageSetting', filters=[['page', 'is', {'type':'Page', 'id':page['id']}]],fields=sg3.schema_field_read('PageSetting').keys() )

    pageSettings[0]['settings_json'] #< this string for dict hold the information you're looking for, but i think it's missing couple of more steps.

     

  • 0
    Avatar
    Shani Turner

    Wow this is some good information. I knew there had to be a way but had no idea how to start. So now I can start with this! Thank you sooooooooooo much Asi!

  • 0
    Avatar
    Asi Sudai

    adding the missing steps:

    page = sg3.find('Page', filters=[['id', 'is', 8094]] )[0]

    # Filter out pages of users, we should have one pageSetting with user=None

    pageSettings = sg3.find('PageSetting', filters=[ ['page', 'is', {'type':'Page', 'id':page['id']}], ['user', 'is', None] ],fields=['settings_json'] )[0]

    filters = pageSettings['settings_json']

     

    from here it's a dict with the key 'filters' which hold all the info you want.

    good luck.

     

  • 0
    Avatar
    Shani Turner

    thank you thank you thank! you made my day =)

Please sign in to leave a comment.