first commit
This commit is contained in:
97
Sonarr/delete_files.py
Normal file
97
Sonarr/delete_files.py
Normal file
@ -0,0 +1,97 @@
|
||||
# #!/usr/bin/python3
|
||||
#
|
||||
# import requests
|
||||
# import os
|
||||
#
|
||||
# PATH_LIST = ["Movies", "Series", "4K-Movies", "4K-Series", "Cartoons"]
|
||||
#
|
||||
# basePath = ""
|
||||
# sourcePath = ""
|
||||
# movieFolder = ""
|
||||
#
|
||||
# def sendNotifications(title, message, priority):
|
||||
# resp = requests.post('https://gotify.rouggy.com/message?token=AKMj5SsZblmpAJ_', json={
|
||||
# "message": message,
|
||||
# "priority": priority,
|
||||
# "title": title
|
||||
# })
|
||||
#
|
||||
# try:
|
||||
#
|
||||
# eventType = os.environ.get('sonarr_eventtype')
|
||||
# sonarrMovieId = os.environ.get('sonarr_series_id')
|
||||
# sourcePath = os.environ.get('sonarr_episodefile_sourcepath')
|
||||
#
|
||||
# # 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(movieFolder)
|
||||
# except:
|
||||
# print("Cannot get env variables")
|
||||
#
|
||||
# #sendNotifications("Test of Radarr Script", f"Source Path:{sourcePath}", 10)
|
||||
#
|
||||
# if basePath not in PATH_LIST:
|
||||
# try:
|
||||
# os.remove(sourcePath)
|
||||
# os.rmdir(movieFolder)
|
||||
# except:
|
||||
# pass
|
||||
# else:
|
||||
# try:
|
||||
# os.remove(sourcePath)
|
||||
# except:
|
||||
# pass
|
||||
#!/usr/bin/python3
|
||||
|
||||
import requests
|
||||
import os
|
||||
import logging
|
||||
|
||||
logging.basicConfig(filename='/home/rouggy/Scripts/ArrDeleteFiles/Sonarr.log', encoding='utf-8', level=logging.DEBUG)
|
||||
|
||||
PATH_LIST = ["Movies", "Series", "4K-Movies", "4K-Series", "Cartoons"]
|
||||
|
||||
BasePath = ""
|
||||
SourcePath = ""
|
||||
MovieFolder = ""
|
||||
|
||||
def sendNotifications(title, message, priority):
|
||||
resp = requests.post('https://gotify.rouggy.com/message?token=AKMj5SsZblmpAJ_', json={
|
||||
"message": message,
|
||||
"priority": priority,
|
||||
"title": title
|
||||
})
|
||||
|
||||
try:
|
||||
# Sonarr
|
||||
EventType = os.environ.get('sonarr_eventtype')
|
||||
logging.debug(f"Event Type: {EventType}")
|
||||
SourcePath = os.environ.get('sonarr_episodefile_sourcepath')
|
||||
logging.debug(f"Source Path: {SourcePath}")
|
||||
SourceFolder = os.environ.get('sonarr_episodefile_sourcefolder')
|
||||
logging.debug(f"Source Folder: {SourceFolder}")
|
||||
|
||||
|
||||
# Get the folder name of the file to check if movie/serie is inside a folder or not
|
||||
MovieFolder = os.path.dirname(SourcePath)
|
||||
logging.debug(f"Serie Folder: {MovieFolder}")
|
||||
BasePath = os.path.basename(MovieFolder)
|
||||
logging.debug(f"Base Path: {BasePath}")
|
||||
except:
|
||||
logging.warning("Could not get environment variables")
|
||||
|
||||
if BasePath not in PATH_LIST:
|
||||
try:
|
||||
os.remove(SourcePath)
|
||||
logging.debug(f"Removing folder {SourcePath}")
|
||||
os.rmdir(MovieFolder)
|
||||
logging.debug(f"Deleting folder {MovieFolder}")
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
os.remove(SourcePath)
|
||||
except:
|
||||
pass
|
||||
|
||||
sendNotifications("Delete Serie", f"Source Path:{SourcePath}", 10)
|
Reference in New Issue
Block a user