From 54edfcc7a4b5f042db5e9087a2c47e24f263324f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 21 Feb 2024 10:02:48 -0500 Subject: [PATCH] test --- remove_lonely_collections.py | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 remove_lonely_collections.py diff --git a/remove_lonely_collections.py b/remove_lonely_collections.py new file mode 100644 index 0000000..ef9c5f6 --- /dev/null +++ b/remove_lonely_collections.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import sys +import pathlib +import subprocess +import requests +from plexapi.server import PlexServer +import urllib3 +urllib3.disable_warnings() + +SCRIPT_DIR = pathlib.Path(os.path.dirname(os.path.abspath(__file__))) + +# PLEX_URL = "http://127.0.0.1:32400" +# PLEX_TOKEN = 'GfMXZTPscfvLazy_pyLP' + + +class plex_info(): + + @property + def address(self): + return "127.0.0.1" + + @property + def port(self): + return "32400" + + @property + def proto(self): + return "http://" + + @property + def token(self): + token_script = pathlib.Path(SCRIPT_DIR).joinpath('plex-token.sh') + token = subprocess.run(['/bin/bash', token_script], capture_output=True, text=True).stdout + return token + + @property + def url(self): + return '%s%s:%s' % (self.proto, self.address, str(self.port)) + + +print(plex_info.token) + +#sess = requests.Session() +#sess.verify = False +#plex = PlexServer(plex_info.url, plex_info.token, session=sess) + +#all_libraries = plex.library.sections() +#for library in all_libraries: +# for collection in library.search(libtype="collection"): +# if collection.childCount == 0: +# collection.delete()