plexargod
plexargod copied to clipboard
fix: handle more than 3 device entries when extracting ArgoURL
I had an issue where the device block from the Plex API contained more than 3 connection entries before the ArgoURL, for example:
<Device name="redacted" product="Plex Media Server" productVersion="1.41.5.9522-a96edc606" platform="Linux" platformVersion="6.1.0-32-amd64" device="Docker Container (LinuxServer.io)" clientIdentifier="redacted" createdAt="1617402041" lastSeenAt="1742691180" provides="server" owned="1" accessToken="redacted" publicAddress="1.2.3.4" httpsRequired="0" synced="0" relay="0" dnsRebindingProtection="0" natLoopbackSupported="1" publicAddressMatches="1" presence="1">
<Connection protocol="http" address="10.10.0.122" port="32400" uri="http://10.10.0.122:32400" local="1"/>
<Connection protocol="http" address="172.20.0.1" port="32400" uri="http://172.20.0.1:32400" local="1"/>
<Connection protocol="http" address="172.17.0.1" port="32400" uri="http://172.17.0.1:32400" local="1"/>
<Connection protocol="https" address="foo-bar-billy.trycloudflare.com" port="443" uri="https://foo-bar-billy.trycloudflare.com:443" local="0"/>
<Connection protocol="http" address="foo-bar-billy.trycloudflare.com" port="80" uri="http://foo-bar-billy.trycloudflare.com:80" local="0"/>
</Device>
And the script was never able to extract the ArgoURL.
This change makes the parsing more robust, by extracting the entire device block and then matching on *.trycloudflare.com instead of being limited to the 3-line sed pattern {n;p;n;p;n;p;}.
Thanks for making this script it's been handy. 👍