I am trying to automate "Export to PDF" when using map series in ArcGis Pro. I have a project that contains a few layouts, some are a series, some are not. What I am trying to accomplish is export each page as it's own pdf if a map series is enabled in a layout. Please see below snippet.

This works to some degree, it exports the layouts that have a map series enabled but it only exports the first page of the series. I need it to export all pages as individual .pdf's. Any help would be much appreciated, thank you. I have also attached the code to a txt file, hope it helps.