This script updates the qbittorrent port from the port that PIA returns from its port forwarding if one is available.
This currently only does something if qbittorrent is open and running since it updates through the Web UI. There is commented code that could be changed to utilize the qbittorrent cli to change the port when the application is closed.
This requires that you have qbittorrent's web interface enabled with the "Bypass authentication for clients on localhost" enabled.