commit 1d4dc3deeb90e2b2315ae3eb95493cf56819a4e2 Author: rouggy Date: Sun Jun 5 11:25:23 2022 +0700 first commit diff --git a/Lidarr/delete_files.py b/Lidarr/delete_files.py new file mode 100644 index 0000000..f138fdc --- /dev/null +++ b/Lidarr/delete_files.py @@ -0,0 +1,31 @@ +#!/usr/bin/python3 + +import requests +import os +import shutil + +PATH_LIST = ["Music"] + +lidarrBasePath = "" +lidarrSourcePath = "" +lidarrMP3Folder = "" + + +try: + + # lidarr + lidarrEventType = os.environ.get('lidarr_eventtype') + lidarrSourcePath = os.environ.get('lidarr_moviefile_sourcepath') + + # Get the folder name of the file to check if movie/serie is inside a folder or not + lidarrMP3Folder = os.path.dirname(lidarrSourcePath) + lidarrBasePath = os.path.basename(lidarrMP3Folder) +except: + print("Cannot get env variables") + + +if lidarrBasePath not in PATH_LIST: + try: + shutil.rmtree(lidarrMP3Folder) + except: + pass diff --git a/Radarr/delete_files.py b/Radarr/delete_files.py new file mode 100644 index 0000000..1ea27bd --- /dev/null +++ b/Radarr/delete_files.py @@ -0,0 +1,55 @@ +#!/usr/bin/python3 + +import requests +import os +import logging + + +logging.basicConfig(filename='/home/rouggy/Scripts/ArrDeleteFiles/Radarr.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: + # Radarr + EventType = os.environ.get('radarr_eventtype') + logging.debug(f"Event Type: {EventType}") + SourcePath = os.environ.get('radarr_moviefile_sourcepath') + logging.debug(f"Source Path: {SourcePath}") + SourceFolder = os.environ.get('radarr_moviefile_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"Movie 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 Movie", f"Source Path:{SourcePath}", 10) \ No newline at end of file diff --git a/Readarr/delete_files.py b/Readarr/delete_files.py new file mode 100644 index 0000000..f4cb6ed --- /dev/null +++ b/Readarr/delete_files.py @@ -0,0 +1,42 @@ +#!/usr/bin/python3 +import sys +import os + +book = {} + +try: + book = { + "EventType": os.environ.get('readarr_eventtype'), + "AuthorId": os.environ.get('readarr_author_id'), + "AuthorName": os.environ.get('readarr_author_name'), + "AuthorPath": os.environ.get('readarr_author_path'), + "AuthorGrid": os.environ.get('readarr_author_grid'), + "BookId": os.environ.get('readarr_book_id'), + "BookTitle": os.environ.get('readarr_book_title'), + "BookGrid": os.environ.get('readarr_book_grid'), + "BookReleaseDate": os.environ.get('readarr_book_releasedate'), + "DownloadClient": os.environ.get('readarr_download_client'), + "DownloadId": os.environ.get('readarr_download_id'), + "AddedBookPath": os.environ.get('readarr_addedbookpaths'), + "DeletedPath": os.environ.get('readarr_deletedpaths') + } +except: + print("Cannot get env variables") + +for key, value in book.items(): + with open('/home/rouggy/Scripts/Readarr/log.txt', 'a') as f: + f.write(f"{key}: {value}") + 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 diff --git a/Sonarr/delete_files.py b/Sonarr/delete_files.py new file mode 100644 index 0000000..634ec3b --- /dev/null +++ b/Sonarr/delete_files.py @@ -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) \ No newline at end of file