2018-09-14 18:03:23 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Remove current Plex Server and a Client from MyPlex account. Useful when running tests in CI.
|
|
|
|
"""
|
|
|
|
from plexapi.myplex import MyPlexAccount
|
|
|
|
from plexapi.server import PlexServer
|
|
|
|
from plexapi import X_PLEX_IDENTIFIER
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
myplex = MyPlexAccount()
|
|
|
|
plex = PlexServer(token=myplex.authenticationToken)
|
2020-12-07 00:39:33 +00:00
|
|
|
|
|
|
|
# Remove the test server
|
2018-09-14 18:03:23 +00:00
|
|
|
for device in plex.myPlexAccount().devices():
|
|
|
|
if device.clientIdentifier == plex.machineIdentifier:
|
|
|
|
print('Removing device "%s", with id "%s"' % (device.name, device. clientIdentifier))
|
|
|
|
device.delete()
|
|
|
|
|
2020-12-07 00:39:33 +00:00
|
|
|
# Remove the test sync client
|
2020-12-07 01:35:44 +00:00
|
|
|
sync_client_identifier = 'test-sync-client-%s' % X_PLEX_IDENTIFIER
|
2020-12-07 00:39:33 +00:00
|
|
|
for device in plex.myPlexAccount().devices():
|
|
|
|
if device.clientIdentifier == sync_client_identifier:
|
|
|
|
print('Removing device "%s", with id "%s"' % (device.name, device. clientIdentifier))
|
|
|
|
device.delete()
|
|
|
|
break
|
|
|
|
|
2018-09-14 18:03:23 +00:00
|
|
|
# If we suddenly remove the client first we wouldn't be able to authenticate to delete the server
|
|
|
|
for device in plex.myPlexAccount().devices():
|
|
|
|
if device.clientIdentifier == X_PLEX_IDENTIFIER:
|
|
|
|
print('Removing device "%s", with id "%s"' % (device.name, device. clientIdentifier))
|
|
|
|
device.delete()
|
|
|
|
break
|