nosmokingbandit / Watcher3

Other
280 stars 59 forks source link

[Feature Request] Add Support for Synology Download Station #233

Open d8ahazard opened 6 years ago

d8ahazard commented 6 years ago

Pretty straightforward. Synology download station is pretty universally supported.

Edit: In a perfect world, we could browse and select the target directory as well, as I usually split out my fetchers into different subdirs for post-processing.

API documentation can be found here:

https://global.download.synology.com/download/Document/DeveloperGuide/Synology_Download_Station_Web_API.pdf

nosmokingbandit commented 6 years ago

I'll start a new branch for this and let you know when I have made any progress. The API looks to be very well documented, but without being able to test it directly myself I don't want to push anything to the master branch until it has actually been used in the real world.

https://github.com/nosmokingbandit/Watcher3/tree/DownloadStation

d8ahazard commented 6 years ago

Tried this evening, just for kicks, get the following when adding a new download:

INFO [2018-04-04 01:59:21,845] cherrypy.error.140142727486656.error.219: [04/Apr/2018:01:59:21] HTTP TypeError: unhashable type: 'dict' return {'response': False, 'error': errors[response['error']]} File "/app/watcher/core/downloaders/DownloadStation.py", line 115, in add_torrent response = getattr(downloaders, client).add_torrent(data) File "/app/watcher/core/snatcher.py", line 247, in snatch_torrent response = self.snatch_torrent(data) File "/app/watcher/core/snatcher.py", line 181, in download return self.snatcher.download(data) File "/app/watcher/core/ajax.py", line 272, in manual_download return self.callable(*self.args, self.kwargs) File "/app/watcher/lib/cherrypy/_cpdispatch.py", line 60, in call value = cherrypy.serving.request._json_inner_handler(*args, *kwargs) File "/app/watcher/lib/cherrypy/lib/jsontools.py", line 61, in json_handler self.body = self.oldhandler(args, kwargs) File "/app/watcher/lib/cherrypy/lib/encoding.py", line 220, in call response.body = self.handler() File "/app/watcher/lib/cherrypy/_cprequest.py", line 670, in respond Traceback (most recent call last): ERROR [2018-04-04 01:59:21,684] cherrypy.error.140142727486656.error.219: [04/Apr/2018:01:59:21] HTTP

Stop hashing my dict, man! XD

nosmokingbandit commented 6 years ago

I'm not sure what is going on there.

{'response': False, 'error': errors[response['error']]} is the important line, in which response['error'] is an int that is a key of errors where the value is a string explaining the error code.

I've created many errors and haven't come across that exception yet.

I'm running the synology OS in a virtual machine, so there could be inconsistencies that arise from that as well.

I did just push a few changes as well as nzb support. Everything works for me except cancelling a download makes the webui show an error that doesn't seem to actually affect anything.

I'm also having trouble getting a post-processing script to fire. It should be easy since DownloadStation is based on Transmission, but I've done enough troubleshooting for one day.

d8ahazard commented 6 years ago

I think the response you're getting from your test Syno is different than what mine is sending back. I added a bit of logging to dump the response before you try and parse it in Downloadstation, and got the following:

After logging the URL generated, this is the error I get from DLStation:

{"error":{"code":403},"success":false}

Lastly, here's the URL generated by watcher.

https://nas.MYDOMAIN.net/webapi/DownloadStation/task.cgi?api=SYNO.DownloadStation.Task&version=2&method=create&uri=https%3A//jackett.MYDOMAIN.net/dl/iptorrents/%3Fjackett_apikey%REDACTED%26path%3Dcm00R1RRVC96eGtmZTVTbDNtZDY5SUdvNHoyNXJmWk9tWkNTd2hVUjMvTkRrRHk0WGpaYTFyVERjZm9HamZMWWwzNHhneStaK3pIVnB5L1pNVUdTZnR3R3h2Y2JjWGNlRGJMT2I2eGNKUmlOekV1SHJPTTRsc1M2QmE0Mko0aWU5UDlKZktEd2lUeTBKNlR6T0NpcEd6N3NKdjlZelBNa2xiQmYvUXRGczg1akU5TS9FbWM5NjJtQ3cveWVoZ0ppaC9IODBPM2Jjbmx5a241OU4vR0dzc0MyRWNBcERaZmtRNUE2VUdRaEJFdG5ERzIrNVFlMFhPNXpiVzMwVFMzSWhOOHlxOXFPdXBCUmdrcjN5by81ZlNSODNrcDlZRHVXVTZ1WGw5Mm8xSGZsRUhRUFBRKzhVWFAvWEtrdnJRYUI2SVdWdVp4WnBIaWlTZ1ppb3QxK3Rja045NVJrS1VWK0FpcGViSS80T3BCdE9yMmZQckltR2RsWjJ0TW1TVTFHcTdtbll1TlJHRUVwV3J4MXVKT3lXUT090%26file%3DBlue%2BVelvet%2B%5B1986%5D%2BDvDrip%2BXviD%2B%5BEng%5D%2B-%2BKole&destination=/volume1/Downloads/watcher&_sid=***

I verified that the torrent is downloaded if I manually grab it from the location in &uri=https%3A//jacket.MYDOMAIN.net...

Also, the path /volume1/Downloads/watcher is valid and exists:

Edited by @nosmokingbandit Removed your _sid. Incredibly minor security implications, but I'd rather be safe.

On Wed, Apr 4, 2018 at 10:25 PM, nosmokingbandit notifications@github.com wrote:

I'm not sure what is going on there.

{'response': False, 'error': errors[response['error']]} is the important line, in which response['error'] is an int that is a key of errors where the value is a string explaining the error code.

I've created many errors and haven't come across that exception yet.

I'm running the synology OS in a virtual machine, so there could be inconsistencies that arise from that as well.

I did just push a few changes as well as nzb support. Everything works for me except cancelling a download makes the webui show an error that doesn't seem to actually affect anything.

I'm also having trouble getting a post-processing script to fire. It should be easy since DownloadStation is based on Transmission, but I've done enough troubleshooting for one day.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nosmokingbandit/Watcher3/issues/233#issuecomment-378809912, or mute the thread https://github.com/notifications/unsubscribe-auth/ABjuNMsvUj-TrOErP7t04jCgC96VJ_q8ks5tlY65gaJpZM4S-8XW .

nosmokingbandit commented 6 years ago

I just pushed an update that will prevent this exception (though it seems the downloadstation docs are either outdated on incomplete). I also included a post-processing script, but it requires a bit of setup since DownloadStation doesn't give tons of useful information when calling the script. I'll add instruction to the wiki later.

What version of DownloadStation are you running? The version in my virtual machine is 3.5-2985.

Edit:

Wiki updated. There is a bit of setup required to get DownloadStation to do what I want. The only annoying part is that DownloadStation uses a relative path (starting with a shared folder), while everything else uses absolute paths.

I don't think there is any nzb post-processing, so this may be as good as it gets.

kxzaon commented 6 years ago

The DownloadStation merge seems to break my setup actually. Here's what I've got when I try to reach : http://localhost:9090/settings/downloader

500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last): File "/home/johndoe/Watcher3/lib/cherrypy/_cprequest.py", line 670, in respond response.body = self.handler() File "/home/johndoe/Watcher3/lib/cherrypy/lib/encoding.py", line 220, in call self.body = self.oldhandler(*args, kwargs) File "/home/johndoe/Watcher3/lib/cherrypy/_cpdispatch.py", line 60, in call return self.callable(*self.args, self.kwargs) File "/home/johndoe/Watcher3/core/app.py", line 163, in settings return App.downloader_template.render(config=core.CONFIG['Downloader'], self.defaults()) File "/home/johndoe/Watcher3/lib/mako/template.py", line 462, in render return runtime.render(self, self.callable, args, data) File "/home/johndoe/Watcher3/lib/mako/runtime.py", line 838, in _render *_kwargs_forcallable(callable, data)) File "/home/johndoe/Watcher3/lib/mako/runtime.py", line 873, in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File "/home/johndoe/Watcher3/lib/mako/runtime.py", line 899, in _exectemplate callable(context, args, kwargs) File "/home/johndoe/Watcher3/templates/cache/templates/settings/downloader.html.py", line 47, in render_body __M_writer(str(config['Usenet']['DownloadStation']['enabled'])) KeyError: 'DownloadStation'

Powered by CherryPy unknown

nosmokingbandit commented 6 years ago

Should be good in 2a4fc12f3ea0a4bec5101b7a4cf9ec75778aab66