INNER CODE UNIT · Python
main
ahembree/ansible-hms-docker · roles/hmsdocker/files/scripts/monitoring/check_media_availability.py:62
def main():
host = 'localhost:32400'
logging.info(f'Checking Plex for media availability')
logging.info(f'Pulling API key from Plex Preferences.xml file')
with open(f'{HMSD_APPS_PATH}/plex/config/Library/Application Support/Plex Media Server/Preferences.xml', 'rb') as f:
plex_config = xmltodict.parse(f)
f.close()
PLEX_TOKEN = plex_config['Preferences']['@PlexOnlineToken']
session = requests.Session()
session.headers.update({
'X-Plex-Token': PLEX_TOKEN
})
session.verify = False
# Get available libraries
url = f'https://{host}/library/sections'