Compare commits
4 Commits
44626d8e50
...
master
Author | SHA1 | Date | |
---|---|---|---|
07bbb21b28 | |||
68ba468192 | |||
0e7fb14a42 | |||
95ca38921d |
24
Readarr/delete_files.py
Normal file → Executable file
24
Readarr/delete_files.py
Normal file → Executable file
@ -4,6 +4,8 @@ import os
|
|||||||
|
|
||||||
book = {}
|
book = {}
|
||||||
|
|
||||||
|
PATH_LIST = ["EBooks"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
book = {
|
book = {
|
||||||
"EventType": os.environ.get('readarr_eventtype'),
|
"EventType": os.environ.get('readarr_eventtype'),
|
||||||
@ -29,14 +31,14 @@ for key, value in book.items():
|
|||||||
f.write('\n')
|
f.write('\n')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# if radarrBasePath not in PATH_LIST:
|
if radarrBasePath not in PATH_LIST:
|
||||||
# try:
|
try:
|
||||||
# os.remove(radarrSourcePath)
|
os.remove(radarrSourcePath)
|
||||||
# os.rmdir(radarrMovieFolder)
|
os.rmdir(radarrMovieFolder)
|
||||||
# except:
|
except:
|
||||||
# pass
|
pass
|
||||||
# else:
|
else:
|
||||||
# try:
|
try:
|
||||||
# os.remove(radarrSourcePath)
|
os.remove(radarrSourcePath)
|
||||||
# except:
|
except:
|
||||||
# pass
|
pass
|
||||||
|
@ -14,6 +14,20 @@ BasePath = ""
|
|||||||
SourcePath = ""
|
SourcePath = ""
|
||||||
SourceFolder = ""
|
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):
|
def sendNotifications(title, message, priority):
|
||||||
resp = requests.post('https://gotify.rouggy.com/message?token=AKMj5SsZblmpAJ_', json={
|
resp = requests.post('https://gotify.rouggy.com/message?token=AKMj5SsZblmpAJ_', json={
|
||||||
"message": message,
|
"message": message,
|
||||||
@ -21,6 +35,7 @@ def sendNotifications(title, message, priority):
|
|||||||
"title": title
|
"title": title
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Sonarr
|
# Sonarr
|
||||||
EventType = os.environ.get('sonarr_eventtype')
|
EventType = os.environ.get('sonarr_eventtype')
|
||||||
@ -42,12 +57,14 @@ if BasePath not in PATH_LIST:
|
|||||||
os.remove(SourcePath)
|
os.remove(SourcePath)
|
||||||
logging.debug(f"Removing file {SourcePath}")
|
logging.debug(f"Removing file {SourcePath}")
|
||||||
for file in glob.glob(SourceFolder + "/*"):
|
for file in glob.glob(SourceFolder + "/*"):
|
||||||
|
if not file.endswith(".mkv"):
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
logging.debug(f"Removing file {file} from {SourceFolder}")
|
logging.debug(f"Removing file {file} from {SourceFolder}")
|
||||||
|
if not checkSeasonFolder(SourceFolder):
|
||||||
os.rmdir(SourceFolder)
|
os.rmdir(SourceFolder)
|
||||||
logging.debug(f"Deleting folder {SourceFolder}")
|
logging.debug(f"Deleting folder {SourceFolder}")
|
||||||
except:
|
except:
|
||||||
pass
|
logging.warning("Error while trying to delete the files")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
os.remove(SourcePath)
|
os.remove(SourcePath)
|
||||||
|
Reference in New Issue
Block a user