Compare commits

...

4 Commits

Author SHA1 Message Date
07bbb21b28 update 2023-02-15 11:16:29 +07:00
68ba468192 update 2023-02-15 11:13:48 +07:00
0e7fb14a42 update 2022-12-24 16:50:08 +07:00
95ca38921d update 2022-12-24 16:48:33 +07:00
2 changed files with 35 additions and 16 deletions

24
Readarr/delete_files.py Normal file → Executable file
View File

@ -4,6 +4,8 @@ import os
book = {}
PATH_LIST = ["EBooks"]
try:
book = {
"EventType": os.environ.get('readarr_eventtype'),
@ -29,14 +31,14 @@ for key, value in book.items():
f.write('\n')
f.close()
# if radarrBasePath not in PATH_LIST:
# try:
# os.remove(radarrSourcePath)
# os.rmdir(radarrMovieFolder)
# except:
# pass
# else:
# try:
# os.remove(radarrSourcePath)
# except:
# pass
if radarrBasePath not in PATH_LIST:
try:
os.remove(radarrSourcePath)
os.rmdir(radarrMovieFolder)
except:
pass
else:
try:
os.remove(radarrSourcePath)
except:
pass

View File

@ -14,6 +14,20 @@ BasePath = ""
SourcePath = ""
SourceFolder = ""
def checkSeasonFolder(SourceFolder):
count = 0
for file in glob.glob(SourceFolder + "/*"):
if file.endswith(".mkv"):
logging.info(f"Found mkv file {file} in the folder: {SourceFolder}")
count += 1
if count > 1:
logging.info("Identified a Season folder")
return True
else:
logging.info("This is not a Season folder")
return False
def sendNotifications(title, message, priority):
resp = requests.post('https://gotify.rouggy.com/message?token=AKMj5SsZblmpAJ_', json={
"message": message,
@ -21,6 +35,7 @@ def sendNotifications(title, message, priority):
"title": title
})
try:
# Sonarr
EventType = os.environ.get('sonarr_eventtype')
@ -42,12 +57,14 @@ if BasePath not in PATH_LIST:
os.remove(SourcePath)
logging.debug(f"Removing file {SourcePath}")
for file in glob.glob(SourceFolder + "/*"):
if not file.endswith(".mkv"):
os.remove(file)
logging.debug(f"Removing file {file} from {SourceFolder}")
if not checkSeasonFolder(SourceFolder):
os.rmdir(SourceFolder)
logging.debug(f"Deleting folder {SourceFolder}")
except:
pass
logging.warning("Error while trying to delete the files")
else:
try:
os.remove(SourcePath)