This commit is contained in:
Gregory Salaun 2022-11-21 11:08:34 +07:00
parent a477c3a167
commit 44626d8e50
2 changed files with 13 additions and 11 deletions

View File

@ -6,9 +6,9 @@ import logging
import glob import glob
logging.basicConfig(filename='/home/rouggy/Scripts/ArrDeleteFiles/Radarr.log', encoding='utf-8', level=logging.DEBUG) logging.basicConfig(filename='/home/rouggy/Scripts/ArrDeleteFiles/Radarr/Radarr.log', encoding='utf-8', level=logging.DEBUG)
PATH_LIST = ["Movies", "Series", "4K-Movies", "4K-Series", "Cartoons"] PATH_LIST = ["Movies", "Series", "4K-Movies", "4K-Series", "Cartoons", "Kids", "Concerts"]
BasePath = "" BasePath = ""
SourcePath = "" SourcePath = ""

View File

@ -3,15 +3,16 @@
import requests import requests
import os import os
import logging import logging
import glob
logging.basicConfig(filename='/home/rouggy/Scripts/ArrDeleteFiles/Sonarr.log', level=logging.DEBUG) logging.basicConfig(filename='/home/rouggy/Scripts/ArrDeleteFiles/Sonarr/Sonarr.log', level=logging.DEBUG)
PATH_LIST = ["Movies", "Series", "4K-Movies", "4K-Series", "Cartoons"] PATH_LIST = ["Movies", "Series", "4K-Movies", "4K-Series", "Cartoons", "Kids", "Concerts"]
BasePath = "" BasePath = ""
SourcePath = "" SourcePath = ""
MovieFolder = "" SourceFolder = ""
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={
@ -31,9 +32,7 @@ try:
# Get the folder name of the file to check if movie/serie is inside a folder or not # Get the folder name of the file to check if movie/serie is inside a folder or not
MovieFolder = os.path.dirname(SourcePath) BasePath = os.path.basename(SourceFolder)
logging.debug(f"Serie Folder: {MovieFolder}")
BasePath = os.path.basename(MovieFolder)
logging.debug(f"Base Path: {BasePath}") logging.debug(f"Base Path: {BasePath}")
except: except:
logging.warning("Could not get environment variables") logging.warning("Could not get environment variables")
@ -41,9 +40,12 @@ except:
if BasePath not in PATH_LIST: if BasePath not in PATH_LIST:
try: try:
os.remove(SourcePath) os.remove(SourcePath)
logging.debug(f"Removing folder {SourcePath}") logging.debug(f"Removing file {SourcePath}")
os.rmdir(MovieFolder) for file in glob.glob(SourceFolder + "/*"):
logging.debug(f"Deleting folder {MovieFolder}") os.remove(file)
logging.debug(f"Removing file {file} from {SourceFolder}")
os.rmdir(SourceFolder)
logging.debug(f"Deleting folder {SourceFolder}")
except: except:
pass pass
else: else: