This commit is contained in:
deathbybandaid 2024-02-21 10:30:59 -05:00
parent e8b5843731
commit 7cac5fd957
2 changed files with 625 additions and 174 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import sys
import pathlib import pathlib
import subprocess import subprocess
import requests import requests
@ -47,18 +46,22 @@ class PLEX_INFO():
return '%s%s:%s' % (self.proto, self.address, str(self.port)) return '%s%s:%s' % (self.proto, self.address, str(self.port))
print("Gathering local Plex information.")
plex_info = PLEX_INFO() plex_info = PLEX_INFO()
print("Plex server is running at %s and using token %s" % (plex_info.url, plex_info.token))
sess = requests.Session()
sess.verify = False
print("Connecting to Plex server API.")
plex = PlexServer(plex_info.url, plex_info.token, session=sess)
print(plex_info.token) all_libraries = plex.library.sections()
print(plex_info.url) print("Checking %s libraries" % len(all_libraries))
for library in all_libraries:
#sess = requests.Session() print("Checking library: %s" % library)
#sess.verify = False collection_delete_count = 0
#plex = PlexServer(plex_info.url, plex_info.token, session=sess) for collection in library.search(libtype="collection"):
if collection.childCount == 0:
#all_libraries = plex.library.sections() collection.delete()
#for library in all_libraries: collection_delete_count += 1
# for collection in library.search(libtype="collection"): print("Deleted %s collections from %s library" % (collection_delete_count, library))
# if collection.childCount == 0:
# collection.delete()