{"id":16823313,"url":"https://github.com/caronc/nzbget-dirwatch","last_synced_at":"2025-04-11T03:14:01.119Z","repository":{"id":74182984,"uuid":"72489971","full_name":"caronc/nzbget-dirwatch","owner":"caronc","description":"An NZBGet Scheduler Script that allows NZBGet to process NZB-Files from multiple drop locations that you define.","archived":false,"fork":false,"pushed_at":"2020-09-08T15:53:35.000Z","size":122,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T03:13:52.846Z","etag":null,"topics":["automation","cli","nzb","nzb-files","nzbget","scheduling-script"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/caronc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"caronc","custom":["https://www.paypal.me/lead2gold"]}},"created_at":"2016-11-01T00:38:35.000Z","updated_at":"2024-01-21T19:36:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"70a1c99c-836c-4ab6-ac44-489949b83288","html_url":"https://github.com/caronc/nzbget-dirwatch","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caronc%2Fnzbget-dirwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caronc%2Fnzbget-dirwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caronc%2Fnzbget-dirwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caronc%2Fnzbget-dirwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caronc","download_url":"https://codeload.github.com/caronc/nzbget-dirwatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248333594,"owners_count":21086200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","cli","nzb","nzb-files","nzbget","scheduling-script"],"created_at":"2024-10-13T11:07:35.629Z","updated_at":"2025-04-11T03:14:01.110Z","avatar_url":"https://github.com/caronc.png","language":"Python","funding_links":["https://github.com/sponsors/caronc","https://www.paypal.me/lead2gold","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=MHANV39UZNQ5E"],"categories":[],"sub_categories":[],"readme":"__Note:__ This script was intended to work with [NZBGet](http://nzbget.net) as a  _Scheduling_ script. However, it also works perfectly well as a standalone script for others too! It can be easily adapted to anyone's environment.\nSee the _Command Line_ section below for details how you can easily use this on it's own (without NZBGet).\n\n[![Paypal](http://repo.nuxref.com/pub/img/paypaldonate.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=MHANV39UZNQ5E)\n\nDirWatch Scheduler Script\n========================\nDirWatch is a script that allows you to identify one or more directories it\nshould scan for NZB-Files in. When an NZB-File is found (or even a zip file\ncontaining NZB-Files), it is pushed either locally or remotely (depending on\nhow it's configured) to a central NZBGet server.\n\nIt can also just perform basic moving for any NZB-Processing application (such\nas SABnzbd.  It can be easily scripted to simply read NZB-Files from multiple\nlocations and place them into a central location.\n\nWhy Would I Need This?\n======================\nNZBGet limits you to identifying _just one_ directory it should scan/watch for\nNZB-Files in (for processing). This is okay for most people, but consider a\nscenario where...\n- you have a DropBox share; you could easily download an NZB-File from your\n  tablet/phone and copy into here.  Then just know that your NZBGet server\n  back at home will processed automatically for you!\n- Maybe there are multiple users on your network who each want use\n  NZBGet too; rather then giving them your admin login (to NZBGet), you can\n  just set this script up to scan a designated folder (in each of their home\n  directories) and process everything found. Thus, there is no need to run\n  multiple instances of NZBGet.\n- Consider that you have a media server somewhere in your house but want to\n  post NZB-Files to it manually whenever they appear in your laptops Download\n  directory.\u003cbr/\u003eNo problem! This script can run on any machine and read from\n  as many directories as you want! It can also remotely post whatever it finds\n  (NZB related) to your central NZBGet server.\n\nDirectory to Category Assignments\n=================================\nWith this script, you can control what categories to assign to what NZB-Files\nyou process. So not only can allow manage mulitple directories containing\nNZB-Files, but you can associate whatever category you wish this way too!\n\nThis is done by simply adding the __?c=category.name__ to each directory you\nwish to monitor. For example, consider a layout like this on your home server:\n```bash\n   /nzbroot/Movies/\n   /nzbroot/TVShows/\n   /nzbroot/MyEBooks/\n```\n\nCategory assignments are mapped by directories, so in this case you might just\nadd the following to NZBGet (DirWatch) Script's configuration:\n```bash\n/nzbroot/Movies?c=movie, /nzbroot/TVShows?c=tv, /nzbroot/MyEBooks?c=ebooks\n```\n\nWith respect to the example above, you would have just acomplished to following\nmappings for NZBGet:\n\n| Directory                         | NZBGet Category |\n| --------------------------------- |:--------------- |\n| /nzbroot/Movies/                  | movies          |\n| /nzbroot/TVShows/                 | tv              |\n| /nzbroot/MyEBooks/                | ebooks          |\n\nEasy-Peasy Right?\n\nHow It Works\n============\nWhatever additional path you specify, the script will just move the detected NZB-Files\nout of them and into the directory NZBGet already processes (identified by _NzbDir_ in\nthe Paths section of it's configuration). If you're calling this from the command line\nthen you must provide the _NzbDir_ as an argument. There are examples of this below.\n\nInstallation Instructions\n=========================\n1. Ensure you have at least Python v2.7 or higher installed onto your system.\n```bash\n# Pull in dependencies:\npip install -r requirements.txt\n```\n2. Simply place the __DirWatch.py__ into your NZBGet scripts directory.\n   * __NZBGet users__: you will want to place these inside of your _nzbget/scripts_ directory. Please ensure you are running _(at least)_ NZBGet v11.0 or higher. You can acquire the latest version of of it from [here](http://nzbget.net/download). \u003cbr/\u003e\u003cbr/\u003eCreate a __Schedule__; you can do this from inside NZBGet. From the __Settings__ -\u003e __Scheduler__ section, you can choose to __[Add Task]__.\n3. Optionally set up an NZBGet Scheduled Task:\n   * TaskX.Time:\n      * Setting for NZBGet _Versions \u003c v18_: __*:00,*:05,*:10,*:15,*:20,*:25,*:30,*:35,*:40,*:45,*:50,*:55__ \u003cbr/\u003e This basically does a check every _5 minutes_ to see if the _DirWatch_ plugin is running. This means if you restart NZBGet or reload it's configuration for whatever reason; you'll just have to wait up to (a maximum of) 5 minutes before the script re-launches and takes over (using it's configured poll time).\n      * Setting for NZBGet _Versions \u003e= v18_: __*__\u003cbr/\u003e A new feature allowing NZBGet to automatically start up any Scheduled service if you simply define a single asterix (__*__) as it's scheduled start time. So for this version an astrix is all you need.\n   * TaskX.Weekdays: __1-7__\n   * TaskX.Command: __Script__\n   * TaskX.Param: __DirWatch.py__\n\nThe Non-NZBGet users can also use this script via a cron (or simply call it\nfrom the command line) to automatically poll directories for the latest\nsubtitles for the video content within it. See the __Command Line__ section\nbelow for more instructions on how to do this.\n\nCommand Line\n============\nDirWatch.py has a built in command line interface that can be easily tied\nto a cron entry or can be easilly called from the command line to automate\nthe fetching of subtitles.\n\nHere are the switches available to you:\n```\nUsage: DirWatch.py [options] [SrcDir1 [SrcDir2 [...]]]\n\nOptions:\n  -h, --help            show this help message and exit\n  -t DIR, --target-dir=DIR\n                        The directory you want to move found NZB-Files from\n                        the identified source directories to. This option is\n                        required if not using the --remote (-r) switch.\n  -a AGE_IN_SEC, --min-age=AGE_IN_SEC\n                        Specify the minimum age a NZB-File must be before\n                        considering it for processing. This value is\n                        interpreted in seconds and defaults to 30 sec(s). This\n                        is just a safety switch to prevent us from creating a\n                        racing condition where an NZB-File is still being\n                        written to disk at the same time as we're trying to\n                        process it.\n  -s SIZE_IN_KB, --max-archive-size=SIZE_IN_KB\n                        Specify the maximum size a detected compressed file\n                        can be before ignoring it. If the found compressed\n                        file is within this specified value, it's contents\n                        will be scanned to see if it (only) contains NZB-\n                        Files. These types of files would qualify to be moved\n                        as well. Set this value to Zero (0) to not process\n                        compressed files. The value is interpreted in\n                        Kilobytes and has a default value of 150if not\n                        otherwise specified.\n  -p, --preview         This is like a test switch; the actions the script\n                        would have otherwise performed are instead just\n                        printed to the screen.\n  -L FILE, --logfile=FILE\n                        Send output to the specified logfile instead of\n                        stdout.\n  -u API_URL, --api-url=API_URL\n                        Specify the URL of the NZB-Get API server such as:\n                        nzbget://user:pass@control.nzbget.host (to access\n                        insecure port 6789),\n                        nzbgets://user:pass@control.nzbget.host (to access\n                        secure port 6791),\n                        nzbget://user:pass@control.nzbget.host:port (to\n                        specify your own insecure port), and\n                        nzbgets://user:pass@control.nzbget.host:port (to\n                        specify your own secure port).  By default\n                        nzbget://127.0.0.1 is used.\n  -r, --remote-push     Perform a remote push to NZBGet. This allows you to\n                        scan directories for NZB-Files on different machines\n                        and still remotely push them to your central NZBGet\n                        server.\n  -c, --auto-cleanup    Removes any .dw files detected prior to the handling\n                        of detected NZB-Files (and/or ZIP files containing\n                        them).\n  -D, --debug           Debug Mode\n\n```\n\nYou can scan as many directories as you want to type inline on the shell:\n```bash\n# Scan your libraries for NZB-Files and move them\n# into: /path/to/NZBGet/NzbDir\npython DirWatch.py -t /path/to/NZBGet/NzbDir \\\n\t/home/joe/Downloads \\\n\t/home/jason/Downloads \\\n\t/home/trevor/Downloads \\\n\t/home/joe/Dropbox/NZBFiles \\\n\t/home/jason/Dropbox/NZBFiles \\\n\t/home/trevor/Dropbox/NZBFiles\n```\n\nDon't forget that if you're using the CLI, you can take advantage of wildcards\nsupported by your shell:\n```bash\n# Take advantage of shell wildcards:\npython DirWatch.py -t /path/to/NZBGet/NzbDir \\\n\t/home/*/Downloads /home/*/Dropbox/NZBFiles\n```\n\nIf the script behaves as you expect it should, you can schedule it as a cron\nto frequently move matched NZB-Files found in the specified Source Directories\n```bash\n# $\u003e crontab -e\n# Scan every 2 minutes:\n*/2 * * * * /path/to/DirWatch.py -t /path/to/NZBGet/NzbDir ~/DropBox\n```\n\nConsider different servers on your network each obtaining NZB-Files in different\nlocations, but you only have 1 NZBGet instance. Perhaps the NZBGet instance\nis even on a different network.  No problem; you can scan multiple locations for\nNZB-Files and then push them remotely to your NZBGet server:\n```bash\n# Scan your libraries for NZB-Files and move them\n# into our remote location done by the --remote (-r) switch\npython DirWatch.py -r -u nzbget://my.nzbget.host \\\n\t/path/to/nzb-files \\\n\t/another/path/to/nzb-files\n```\n\nYou can also use the category switches with the command line to force category\nassignments per directory:\n```bash\n# Assign categories per directory (optionally) if you wish:\npython DirWatch.py -t /path/to/NZBGet/NzbDir \\\n\t/home/joe/Downloads/NZBFiles/Movies?c=movie \\\n\t/home/joe/Downloads/NZBFiles/Shows?c=tv\n\t/home/joe/Downloads/NZBFiles/General\n\n# You can do this using remote calls too:\npython DirWatch.py -r -u nzbget://my.nzbget.host \\\n\t/home/joe/Downloads/NZBFiles/Movies?c=movie \\\n\t/home/joe/Downloads/NZBFiles/Shows?c=tv\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaronc%2Fnzbget-dirwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaronc%2Fnzbget-dirwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaronc%2Fnzbget-dirwatch/lists"}