-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
print/discord notifications and blackhole watcher startup fixes
- Loading branch information
1 parent
5314ca5
commit a426485
Showing
5 changed files
with
180 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,48 @@ | ||
import asyncio | ||
from watchdog.observers import Observer | ||
from watchdog.events import FileSystemEventHandler | ||
from blackhole import start, getPath | ||
from blackhole import on_created, getPath | ||
|
||
class BlackholeHandler(FileSystemEventHandler): | ||
def __init__(self, is_radarr): | ||
super().__init__() | ||
self.is_radarr = is_radarr | ||
self.path_name = getPath(is_radarr, create=True) | ||
|
||
def on_created(self, event=None): | ||
if not event or (not event.is_directory and event.src_path.lower().endswith((".torrent", ".magnet"))): | ||
start(self.is_radarr) | ||
def on_created(self, event): | ||
if not event.is_directory and event.src_path.lower().endswith((".torrent", ".magnet")): | ||
asyncio.run(on_created(self.is_radarr)) | ||
|
||
if __name__ == "__main__": | ||
print("Watching blackhole") | ||
async def on_created(self): | ||
await on_created(self.is_radarr) | ||
|
||
async def main(): | ||
print("Watching blackhole") | ||
|
||
radarr_handler = BlackholeHandler(is_radarr=True) | ||
sonarr_handler = BlackholeHandler(is_radarr=False) | ||
radarr_handler = BlackholeHandler(is_radarr=True) | ||
sonarr_handler = BlackholeHandler(is_radarr=False) | ||
|
||
radarr_handler.on_created() | ||
sonarr_handler.on_created() | ||
radarr_observer = Observer() | ||
radarr_observer.schedule(radarr_handler, radarr_handler.path_name) | ||
|
||
radarr_observer = Observer() | ||
radarr_observer.schedule(radarr_handler, radarr_handler.path_name) | ||
sonarr_observer = Observer() | ||
sonarr_observer.schedule(sonarr_handler, sonarr_handler.path_name) | ||
|
||
sonarr_observer = Observer() | ||
sonarr_observer.schedule(sonarr_handler, sonarr_handler.path_name) | ||
try: | ||
radarr_observer.start() | ||
sonarr_observer.start() | ||
|
||
await asyncio.gather( | ||
radarr_handler.on_created(), | ||
sonarr_handler.on_created() | ||
) | ||
except KeyboardInterrupt: | ||
radarr_observer.stop() | ||
sonarr_observer.stop() | ||
|
||
try: | ||
radarr_observer.start() | ||
sonarr_observer.start() | ||
except KeyboardInterrupt: | ||
radarr_observer.stop() | ||
sonarr_observer.stop() | ||
radarr_observer.join() | ||
sonarr_observer.join() | ||
|
||
radarr_observer.join() | ||
sonarr_observer.join() | ||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.